• Help with code
    5 replies, posted
Well im working on admin commands to help with coding and I am running in to an error [CODE]local function chatCommand( ply, text, public ) if (string.sub(text, 1, 9) == "/spectate") then ply.StartedSpecPos = ply:GetPos() ply.TheWeapons = {} for id, wep in pairs( ply:GetWeapons() ) do table.insert( ply.TheWeapons, wep:GetClass() ) end ply:StripWeapons() ply:Spectate(OBS_MODE_ROAMING) return(false) end if (string.sub(text, 1, 11) == "/unspectate") then ply:UnSpectate() ply:SetPos( ply.StartedSpecPos ) for k,v in pairs( ply.TheWeapons ) do ply:Give( v ) end return(false) end if (string.sub(text, 1, 7) == "!freeze") then for k, v in pairs( player.GetAll() ) do v:Freeze( true ) return(false) end if (string.sub(text, 1, 9) == "!unfreeze") then for k, v in pairs( player.GetAll() ) do v:Freeze( false ) return(false) end if (string.sub(text, 1 ,7) == "!slowmo") then game.SetTimeScale(0.1) return(false) end if (string.sub(text, 1 ,9) == "!unslowmo") then game.SetTimeScale (1) return(false) end if (string.sub(text, 1, 4) == "!kill") then for k, v in pairs( player.GetAll() ) do v:Kill() return(false) end end hook.Add( "PlayerSay", "chatCommand", chatCommand );[/CODE] that is the code the error is [ERROR] lua/first.lua:34: ')' expected near '1' 1. unknown - lua/first.lua:0
What line is 34? On unrelated note, you can do "return false" instead of "return(false)".
[lua] if (string.sub(text, 1, 7) == "!freeze") then for k, v in pairs( player.GetAll() ) do v:Freeze( true ) return(false) end [/lua] You're not ending your loops. End your loops for your freeze, unfreeze and kills commands. e.g [lua] if (string.sub(text, 1, 7) == "!freeze") then for k, v in pairs( player.GetAll() ) do v:Freeze( true ) end return false end [/lua] Notice I added "end" to the example.
[QUOTE=Robotboy655;45024713]What line is 34? On unrelated note, you can do "return false" instead of "return(false)".[/QUOTE] According to my Notepad++, it says its [code] if (string.sub(text, 1, 4) == "!kill") then [/code] [t]http://puu.sh/9iQI9/c96d7bbc05.png[/t]
[QUOTE=Sm63;45024728]According to my Notepad++, it says its [code] if (string.sub(text, 1, 4) == "!kill") then [/code] [t]http://puu.sh/9iQI9/c96d7bbc05.png[/t][/QUOTE] what he said is right thats line 34
[QUOTE=TehBrettJoker;45025484]what he said is right thats line 34[/QUOTE] Do what Alig said and then do this: Change [code]if (string.sub(text, 1, 4) == "!kill") then[/code] to [/code]if (string.sub(text, 1, 5) == "!kill") then[/code] As it wont work if it was 4.
Sorry, you need to Log In to post a reply to this thread.