• Concommand help
    8 replies, posted
Code: concommand.Add( "killyourself",function( ply ) ply:Kill() print( "You killed yourself!" ) end ) Location:tried all 3 (cl_init,Init and shared) Error: [ERROR] gamemodes/war/gamemode/shared.lua:34: attempt to call method 'kill' (a nil value) 1. unknown - gamemodes/war/gamemode/shared.lua:34 <---- disregard that I've tried all 3 files 2. unknown - lua/includes/modules/concommand.lua:69
[url]http://wiki.garrysmod.com/page/Player/Kill[/url] It must be ran serverside.
[code] local _ply = LocalPlayer() concommand.Add( "killyourself", "arte", function(_ply) _ply:Kill() end ) [/code] you missed the name of the concommand, print("you killed yourself") is clientside, ply:Kill() is serverside untested *ninja'd*
From what I see, your code and your error message does not match. Its saying 'kill' is a nil value when your calling "Kill()" in your code. Are you sure you posted the right code/error message? Also too, if you wanna leave it in shared, which is silly, wrap it in [code]if SERVER then end[/code].
[QUOTE=Mythikos;44821566]From what I see, your code and your error message does not match. Its saying 'kill' is a nil value when your calling "Kill()" in your code. Are you sure you posted the right code/error message? Also too, if you wanna leave it in shared, which is silly, wrap it in [code]if SERVER then end[/code].[/QUOTE] he probably just wrote it out, instead of just copying it entirely.
[QUOTE=74pantera;44821561][code] local _ply = LocalPlayer() concommand.Add( "killyourself", "arte", function(_ply) _ply:Kill() end ) [/code] you missed the name of the concommand, print("you killed yourself") is clientside, ply:Kill() is serverside untested *ninja'd*[/QUOTE] What is the point of making _ply = LocalPlayer()? That's just redundant.
[QUOTE=code_gs;44821794]What is the point of making _ply = LocalPlayer()? That's just redundant.[/QUOTE] cus yo i wanna look c00l
Ok thanks guys
[code] if SERVER then concommand.Add( "killyourself",function( ply ) ply:Kill() ply:PrintMessage( "HUD_PRINTTALK", "You killed yourself!" ) end ) end [/code]
Sorry, you need to Log In to post a reply to this thread.