name is just a string, the players name, it isn't actually a player object. The player object isn't created until PlayerInitialSpawn:
[lua]
function player_exists(ply)
local steamID = ply:SteamID()
local name = ply:Nick()
local result = sql.Query("SELECT steam_id, money, rpname, experience, corporation FROM player_info WHERE steam_id = '"..steamID.."'")
if(result) then
sql_value_info(steamID, name)
sql_value_inventory(steamID, name)
else
new_player(steamID, name)
end
end
hook.Add("PlayerInitialSpawn", "OnPlayerInitialSpawn", player_exists)[/lua]
[QUOTE=Drakehawke;37486485]name is just a string, the players name, it isn't actually a player object. The player object isn't created until PlayerInitialSpawn:
[lua]
function player_exists(ply)
local steamID = ply:SteamID()
local name = ply:Nick()
local result = sql.Query("SELECT steam_id, money, rpname, experience, corporation FROM player_info WHERE steam_id = '"..steamID.."'")
if(result) then
sql_value_info(steamID, name)
sql_value_inventory(steamID, name)
else
new_player(steamID, name)
end
end
hook.Add("PlayerInitialSpawn", "OnPlayerInitialSpawn", player_exists)[/lua][/QUOTE]
Brilliant, that makes perfect sense. Thanks.
Hi, I'm an absolute noob at lua, beyond belief, but I am trying to do some lua for Garry's mod 13 (short version of this starts a bit lower down). I've attempted to adapt a script from this youtube video [url]http://www.youtube.com/watch?v=cJrpfS93Tgc[/url] . The original lua opens a little menu that you can type in and press enter, and by doing so sends the entered text to the consle after "say ". I've altered it so that I can type a name and send it to the console after "kick " to make a kick tool.
[[B]SHORT VERSION[/B]]I've searched for literally hours and I cannot understand why, when I type into the console, the con command that I added with the lua, it still says "unknown command".
heres the lua, any help would be very much appreciated.
function KickMenu()
local ply = LocalPlayer()
local BackGround = vgui.Create ( "DFrame" )
BackGround:SetSize( 200, 70 )
BackGround:SetPos( (ScrW()/2)-Background:GetWide(),(ScrH()/2)-BackGround:GetTall() )
BackGround:SetTitle( "Kick Player" )
BackGround:SetVisible( true )
BackGround:SetDraggable( true )
BackGround:ShowCloseButton ( true )
BackGround:MakePopup()
BackGround.Paint = function()
draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(200,0,0,200))
draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(50,50,50,200))
end
local TextEntry = vgui.Create( "DTextEntry", BackGround )
TextEntry:SetPos( 20,30 )
TextEntry:SetTall( 20 )
TextEntry:SetWide( 160 )
TextEntry:SetEnterAllowed( true )
TextEntry.OnENter = function()
ply:ConCommand("kick "..TextEntry:GetValue())
BackGround:SetVisible( false )
end
end
concommand.Add( "open_kick_menu", KickMenu )
[QUOTE=the dan dude;37487594]Hi, I'm an absolute noob at lua, beyond belief, but I am trying to do some lua for Garry's mod 13 (short version of this starts a bit lower down). I've attempted to adapt a script from this youtube video [url]http://www.youtube.com/watch?v=cJrpfS93Tgc[/url] . The original lua opens a little menu that you can type in and press enter, and by doing so sends the entered text to the consle after "say ". I've altered it so that I can type a name and send it to the console after "kick " to make a kick tool.
[[B]SHORT VERSION[/B]]I've searched for literally hours and I cannot understand why, when I type into the console, the con command that I added with the lua, it still says "unknown command".
heres the lua, any help would be very much appreciated.
[/QUOTE]
If it's a clientside script, try this (untested, hence [b]try[/b] this)
[lua]concommand.Add("open_kick_menu", function()
local ply = LocalPlayer()
local BackGround = vgui.Create ( "DFrame" )
BackGround:SetSize( 200, 70 )
BackGround:SetPos( (ScrW()/2)-Background:GetWide(),(ScrH()/2)-BackGround:GetTall() )
BackGround:SetTitle( "Kick Player" )
BackGround:SetVisible( true )
BackGround:SetDraggable( true )
BackGround:ShowCloseButton ( true )
BackGround:MakePopup()
BackGround.Paint = function()
draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(200,0,0,200))
draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(50,50,50,200))
end
local TextEntry = vgui.Create( "DTextEntry", BackGround )
TextEntry:SetPos( 20,30 )
TextEntry:SetTall( 20 )
TextEntry:SetWide( 160 )
TextEntry:SetEnterAllowed( true )
TextEntry.OnENter = function()
RunConsoleCommand("kick", TextEntry:GetValue())
BackGround:SetVisible( false )
end
end)
[/lua]
[apologies for implementing my OCD]
[QUOTE=zeppelin;37490873]If it's a clientside script, try this (untested, hence [b]try[/b] this)
[lua]concommand.Add("open_kick_menu", function()
local ply = LocalPlayer()
local BackGround = vgui.Create ( "DFrame" )
BackGround:SetSize( 200, 70 )
BackGround:SetPos( (ScrW()/2)-Background:GetWide(),(ScrH()/2)-BackGround:GetTall() )
BackGround:SetTitle( "Kick Player" )
BackGround:SetVisible( true )
BackGround:SetDraggable( true )
BackGround:ShowCloseButton ( true )
BackGround:MakePopup()
BackGround.Paint = function()
draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(200,0,0,200))
draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(50,50,50,200))
end
local TextEntry = vgui.Create( "DTextEntry", BackGround )
TextEntry:SetPos( 20,30 )
TextEntry:SetTall( 20 )
TextEntry:SetWide( 160 )
TextEntry:SetEnterAllowed( true )
TextEntry.OnENter = function()
RunConsoleCommand("kick", TextEntry:GetValue())
BackGround:SetVisible( false )
end
end)
[/lua]
[apologies for implementing my OCD][/QUOTE]
Thanks a lot for your work, its almost working now. The window/box appears when the command open_kick_menu is used. The box is called "window" along the top, and it spawns in the top left corner, which is not ideal as the only way to move the window is by opening the context menu, which brings down a task bar (on gmod 13), blocking the top of the window meaning i can't move or close the window. The text entry is also missing and the console returns the following error message
] open_kick_menu
[lua/autorun/client/kicker.lua:6] attempt to index global 'Background' (a nil value)
1. lua/autorun/client/kicker.lua:6 (?)
2. lua/includes/modules/concommand.lua:69 (unknown)
3. (tail call):-1 (unknown)
The same error message comes up in gmod 11. Again, any help or guidance is greatly appreciated.
[QUOTE=the dan dude;37491715]Thanks a lot for your work, its almost working now. The window/box appears when the command open_kick_menu is used. The box is called "window" along the top, and it spawns in the top left corner, which is not ideal as the only way to move the window is by opening the context menu, which brings down a task bar (on gmod 13), blocking the top of the window meaning i can't move or close the window. The text entry is also missing and the console returns the following error message
] open_kick_menu
[lua/autorun/client/kicker.lua:6] attempt to index global 'Background' (a nil value)
1. lua/autorun/client/kicker.lua:6 (?)
2. lua/includes/modules/concommand.lua:69 (unknown)
3. (tail call):-1 (unknown)
The same error message comes up in gmod 11. Again, any help or guidance is greatly appreciated.[/QUOTE]
BackGround:SetPos( (ScrW()/2)-Back[B][I]g[/I][/B]round:GetWide(),(ScrH()/2)-BackGround:GetTall() )
How do I get the Steam avatar of a player? Do I have to use the derma way? ([url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4933.html[/url])
Thanks
[editline]1st September 2012[/editline]
Also, the above Derma control does not appear to work even when I don't change anything
[editline]1st September 2012[/editline]
Oh, it does work, I was calling it too early! But yes, is there any alternative?
I think you can use an HTML panel, get the xml version of a profile, and display <AvatarImage>
Blimey that's even worse
Ok well thanks anyway
yeah but I'm pretty sure with the method I mentioned you can display it at a larger size without pixelization
[QUOTE=Banana Lord.;37496768]yeah but I'm pretty sure with the method I mentioned you can display it at a larger size without pixelization[/QUOTE]
I'll keep it in mind if I need to display large versions, thanks
Right now, I only need very tiny images
[lua]
function GM:CreateMove( cmd )
if cmd:GetButtons() & IN_JUMP > 0 then
cmd:SetButtons( cmd:GetButtons() - IN_JUMP )
print("test")
end
end
[/lua]
This is the example on the old wiki for disabling player movement, with a print added. It works to disable jumping.
If I switch out the IN_JUMP for IN_FORWARD, it still prints, but does not stop the forward player movement. How can I make it so that a player cannot move when movement binds are active?
edit
Here's the solution if anyone is interested, that I used to make it so that the player does not move by pressing any binds, but can move forward by pressing the left mouse button.
[lua]
function GM:GUIMousePressed(mousecode)
local ply = LocalPlayer()
if mousecode==MOUSE_LEFT then
ply:ConCommand("+forward")
ply.leftmousepressed = true
end
end
function GM:GUIMouseReleased(mousecode)
local ply = LocalPlayer()
if mousecode==MOUSE_LEFT then
ply:ConCommand("-forward")
ply.leftmousepressed = false
end
end
function GM:PlayerBindPress(ply,bind,pressed) //true = disallow
if string.find(bind,"+forward") then
if ply.leftmousepressed then
return false
else
return true
end
end
if string.find(bind,"+back") || string.find(bind,"+moveleft") || string.find(bind,"+moveright") then
return true
end
end
[/lua]
thanks, i'll try that TylerB
[editline]2nd September 2012[/editline]
[QUOTE=TylerB;37492506]BackGround:SetPos( (ScrW()/2)-Back[B][I]g[/I][/B]round:GetWide(),(ScrH()/2)-BackGround:GetTall() )[/QUOTE]
thank you so much TylerB, the window now opens in the center of the screen, is fully moveable and closeable, is the correct colour, the text entry field is working fine however, pressing enter does nothing, it should be entering "kick " into the console followed by what has been typed into the box. current lua is as follows, as always any contribution is highly valued
concommand.Add("open_kick_menu", function()
local ply = LocalPlayer()
local BackGround = vgui.Create ( "DFrame" )
BackGround:SetSize( 200, 70 )
BackGround:SetPos( (ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall() )
BackGround:SetTitle( "Kick Player" )
BackGround:SetVisible( true )
BackGround:SetDraggable( true )
BackGround:ShowCloseButton ( true )
BackGround:MakePopup()
BackGround.Paint = function()
draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(200,0,0,200))
draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(50,50,50,200))
end
local TextEntry = vgui.Create( "DTextEntry", BackGround )
TextEntry:SetPos( 20,30 )
TextEntry:SetTall( 20 )
TextEntry:SetWide( 160 )
TextEntry:SetEnterAllowed( true )
TextEntry.OnENter = function()
RunConsoleCommand("kick ", TextEntry:GetValue())
BackGround:SetVisible( false )
end
end)
as always any contribution is highly valued
TextEntry.OnE[b]n[/b]ter = function()
[QUOTE=Undefined;37501638]TextEntry.OnE[b]n[/b]ter = function()[/QUOTE]
aah thanks Undefined, i didn't realise that was a typo lol... when i input text i get a new error from the console
[lua/autorun/client/kicker.lua:23] RunConsoleCommand: Command has invalid characters! (kick (' '))
The first parameter of this function should contain only the command, the second parameter should contain arguments.
----------------------------
and this is the ammended text entry section of the lua
local TextEntry = vgui.Create( "DTextEntry", BackGround )
TextEntry:SetPos( 20,30 )
TextEntry:SetTall( 20 )
TextEntry:SetWide( 160 )
TextEntry:SetEnterAllowed( true )
TextEntry.OnEnter = function()
RunConsoleCommand("kick ", TextEntry:GetValue())
BackGround:SetVisible( false )
end
end)
all contributions are greatly appreciated, hopefully if someone finds the solution to this it should be working, fingers crossed...
To those who know about GM13:
When sending a custom file (e.g. a material file) to the client from the server in GM12 with resource.AddFile(), it material goes from the server's materials folder to the client's materials folder. Everyone is happy
I came to update my code to GM13, and found this:
[quote]Gamemode content such as maps, models and sounds should be placed in gamemodes/content/ folder. (ie gamemodes/content/models/..).[/quote]
So, if I place the content in gamemodes/content/...., does it go to the clients gamemodes/content folder or to the gamemodes/materials folder? And, as a bonus question, where would I put that in the FastDL? Same place as GM12?
Thanks
Same place as GM12 for the FastDL, and the server/client just mounts /gamemodes/yourgamemode/content/ as a root directory.
[QUOTE=the dan dude;37501932]aah thanks Undefined, i didn't realise that was a typo lol... when i input text i get a new error from the console
[lua/autorun/client/kicker.lua:23] RunConsoleCommand: Command has invalid characters! (kick (' '))
The first parameter of this function should contain only the command, the second parameter should contain arguments.
----------------------------
and this is the ammended text entry section of the lua
local TextEntry = vgui.Create( "DTextEntry", BackGround )
TextEntry:SetPos( 20,30 )
TextEntry:SetTall( 20 )
TextEntry:SetWide( 160 )
TextEntry:SetEnterAllowed( true )
TextEntry.OnEnter = function()
RunConsoleCommand("kick ", TextEntry:GetValue())
BackGround:SetVisible( false )
end
end)
all contributions are greatly appreciated, hopefully if someone finds the solution to this it should be working, fingers crossed...[/QUOTE]
RunConsoleCommand("kick", TextEntry:GetValue())
[QUOTE=Persious;37503747]RunConsoleCommand("kick", TextEntry:GetValue())[/QUOTE]
thankyou so much Persious, its fully working now :D
full working lua for anyone who may want it a pop-up kick box below
concommand.Add("open_kick_menu", function()
local ply = LocalPlayer()
local BackGround = vgui.Create ( "DFrame" )
BackGround:SetSize( 200, 70 )
BackGround:SetPos( (ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall() )
BackGround:SetTitle( "Kick Player" )
BackGround:SetVisible( true )
BackGround:SetDraggable( true )
BackGround:ShowCloseButton ( true )
BackGround:MakePopup()
BackGround.Paint = function()
draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(200,0,0,200))
draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(50,50,50,200))
end
local TextEntry = vgui.Create( "DTextEntry", BackGround )
TextEntry:SetPos( 20,30 )
TextEntry:SetTall( 20 )
TextEntry:SetWide( 160 )
TextEntry:SetEnterAllowed( true )
TextEntry.OnEnter = function()
RunConsoleCommand("kick", TextEntry:GetValue())
BackGround:SetVisible( false )
end
end)
-snip-
How can I center a DModelPanels view so the model is like, if the model is a player model?
I need help creating a simple kick system. How can I make a simple chat command such as !kick <Nickname> <Reason>, and how can I make this command restricted to a team? Any help would be appreciated, thanks.
[QUOTE=isnipeu;37467502]
Is it possible to slow down or speed up effects that are made with functions such as ParticleEffect and ParticleEffectAttach?
[/QUOTE]
Does anyone know?
[QUOTE=COBRAa;37502991]Same place as GM12 for the FastDL, and the server/client just mounts /gamemodes/yourgamemode/content/ as a root directory.[/QUOTE]
Thanks. I assume by mounting as a root directory we just have
/gamemodes/mygamemode/content/materials
/gamemodes/mygamemode/content/maps
/gamemodes/mygamemode/content/models
etc...
Is that correct? Cheers
When the game loads it will move everything in garrysmod/gamemodes/yourgm/content/* to garrysmod/ in a virtual filesystem.
I see, thanks!
Hi, I have a weapon that uses the world model of a default CSS gun but I want to change it's color to blue or silver or something when dropped and if possible when held by a player to distinguish it from it's regular counterpart, how do I do this?
Having issues with vehicles causing my server to crash. Whenever i drive around 10mph+, and cut the break (hold down space, handbreak), the server crashs.
Luckly, thank to Python1320, i could upload my crash dump. Garry's is down.
[url]http://dumps.metastruct.uk.to/dumper.py?dump=gmod13dev_srcds_1482030_crash_2012_9_2T16_54_24C0.mdmp[/url]
Heres the dump. Is this something on my part, or is it an issue with GMod 13? Perhaps it would be an issue with the map. It doesn't happen on gm_construct. I've heard something long time ago, about something in the old maps causing this crash.
Hopefully somebody knows whats up, and can help me solve this annoying issue. The map is rp_evocity_v33x if anybody is wondering.
Forgive me for this question, but how do you find the bitcount of a integer when using the new networked library? (net.WriteInt(val, bits), net.ReadInt(bits))
I don't know (I had your problem), but you can use Write/ReadFloat for the same effect without having to find it, so that the number sends correctly. You can also store everything you want to send in a table for Write/ReadTable to shorten your code.
Sorry, you need to Log In to post a reply to this thread.