• How do I make a console command take a player as an argument?
    3 replies, posted
For example, if I want to make a command called getmoney, and make it take an argument that is the player, so if I type getmoney 'player's name' then it would tell me how much that player has. in DarkRP.
[code] concommand.Add("getmoney", function( ply, cmd, args ) if( !IsValid( ply ) ) then return end local name = args[1] local found = NULL for k,v in pairs( player.GetAll() ) do if( string.find( v:Name(), name ) != nil ) then found = v break end end if( IsValid( found )) then print( (found == ply) and "$0 otherwise I would be on ScriptFodder" or found:GetDarkRPmonies() ) end end ) [/code]
[QUOTE=Hoffa1337;50271557][code] concommand.Add("getmoney", function( ply, cmd, args ) if( !IsValid( ply ) ) then return end local name = args[1] local found = NULL for k,v in pairs( player.GetAll() ) do if( string.find( v:Name(), name ) != nil ) then found = v break end end if( IsValid( found )) then print( (found == ply) and "$0 otherwise I would be on ScriptFodder" or found:GetDarkRPmonies() ) end end ) [/code][/QUOTE] bad argument #2 to 'find' (string expected, got nil)
What did you type?
Sorry, you need to Log In to post a reply to this thread.