• Make a ! command running a console command
    8 replies, posted
So basicly i need help making a !(command) code that will run a console command(which works for everyone) Does anyone know how?
[code]function chatconcommand( ply, text, Public ) if ( ply:IsValid() ) then if ( string.lower( Text ) == "!command" ) then ply:ConCommand( "sv_command" ) return "" end end end hook.Add( "PlayerSay", "chatconcommand", chatconcommand ) [/code]
where does this go ?
[QUOTE=code_gs;43454479][code]function chatconcommand( ply, text, Public ) if ( Player:IsValid() ) then if ( string.lower( Text ) == "!command" ) then Player:ConCommand( "sv_command" ) return "" end end end hook.Add( "PlayerSay", "chatconcommand", chatconcommand ) [/code][/QUOTE] Thanks mate! Needed this :3 [editline]8th January 2014[/editline] [QUOTE=code_gs;43454479][code]function chatconcommand( ply, text, Public ) if ( Player:IsValid() ) then if ( string.lower( Text ) == "!command" ) then Player:ConCommand( "sv_command" ) return "" end end end hook.Add( "PlayerSay", "chatconcommand", chatconcommand ) [/code][/QUOTE] Error appeared: attempt to index global 'Player' (a function value) did i put it wrong place maybe?
replace Player with ply..
[QUOTE=Map in a box;43455945]replace Player with ply..[/QUOTE] Fixed that; didn't know how I overlooked that.
for example: function chatconcommand( ply, text, Public ) if ( Ply:IsValid() ) then if ( string.lower( Text ) == "!kill" ) then Ply:ConCommand( "kill" ) return "" end end end hook.Add( "PlySay", "chatconcommand", chatconcommand ) doesn't seem to work. does nothing
lua is case sensitive. ply:IsValid, not Ply:IsValid.
Ninja'd.
Sorry, you need to Log In to post a reply to this thread.