• Kick Command not working
    3 replies, posted
[code] for k, v in pairs(player.GetAll()) do v:SendLua([[chat.AddText(Color(0, 0, 155), '[Server]', Color(0, 0, 0), victim:Nick()..' was kicked by '..ply:Nick()..' For: '..reason)]]) end [/code] When I do my !kick command, it will kick them but I will get this error, [code] [·[FL:RP] Adam James·|2|STEAM_0:0:48101653] Lua Error: [ERROR] LuaCmd:1: attempt to index global 'victim' (a nil value) 1. unknown - LuaCmd:1 [/code] Any help on dat? Also, this is victim, local victim = GetPlayers(text[2]) GetPlayers is the function that selects the player you enter, (IE: !kick bot01)
The whole code would be nice.
You're trying to concatenate those strings clientside, where those variables do not exist. Do the concatenation serverside, like so: [code] for k, v in pairs(player.GetAll()) do v:SendLua([[chat.AddText(Color(0, 0, 155), '[Server]', Color(0, 0, 0),']]..victim:Nick()..[[ was kicked by ]]..ply:Nick()..[[ for: ]]..reason..[[')]]) end [/code] Also, consider using the [URL="http://wiki.garrysmod.com/page/Net_Library_Usage"]net library[/URL] instead to do this instead of SendLua. If you must use it, just use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/BroadcastLua]Global.BroadcastLua[/url] to send the Lua to everyone for execution.
shouldn't do it this way, what if i name myself ') cam.End3D2D() print('
Sorry, you need to Log In to post a reply to this thread.