• Chat kick system
    6 replies, posted
im trying to make a system thats let admins kick players via the chat [PHP]function Kick(ply, text) local Array = string.Explode( " ", text ); if Array[1] == "/kick" & ply:IsAdmin() then for k , t in ipairs(player.GetAll()) do if string.find(string.lower(t:Nick()) , string.lower(Array[2])) then t:Kick(Array[3]) WriteToLog( ply.GetName() .." kicked: ".. Kick:GetName() ); else ply:PrintMessage( HUD_PRINTTALK, "Player name wasnt valid!"); end end return false end end[/PHP]if you wana kick someone you should type /kick <player name> <reason> I get a error dont remember what it stood. Please help!
What error? :geno:
[PHP]Hook 'Kick' Failed: autorun/functions.lua:24: attempt to perform arithmetic on a string value[/PHP]^^This
[lua]if Array[1] == "/kick" & << Error ply:IsAdmin() then[/lua] To [lua]if Array[1] == "/kick" && ply:IsAdmin() then [/lua] :science: :3: [code] /kick cubar pie Disconnect: Kicked by Console : pie. [/code]
oh didnt know you needed to use two & thanks Admin can lock now
A single '&' is usually a Bitwise or, so if you have 12 and 5 you get 4 because 12 is 0b1100 and 5 is 0b0101, the bitwise and ands each bit in the first number with the second, so you get 0b0100 because that's the only bit that's in both and 0b0100 is 4. This can have the same effect on some languages, but will be less efficient because you can't do what's called 'shortcut evaluation'. If the left operand of an and operation evaluates to false you don't have to evaluate the rest of the expression because you know it will be false. '&&' and 'and' are the shortcut evaluation or logical boolean operators. '&&' is from C like languages whereas 'and' is from languages like lua and python, where they try to improve readability by using natural language. Most languages don't let you choose between '&&' and 'and' but Garrysmod's implementation of lua allows some C like operators, however it is still mostly lua.
[QUOTE=fishface60;20589089]A single '&' is usually a Bitwise or, so if you have 12 and 5 you get 4 because 12 is 0b1100 and 5 is 0b0101, the bitwise and ands each bit in the first number with the second, so you get 0b0100 because that's the only bit that's in both and 0b0100 is 4. This can have the same effect on some languages, but will be less efficient because you can't do what's called 'shortcut evaluation'. If the left operand of an and operation evaluates to false you don't have to evaluate the rest of the expression because you know it will be false. '&&' and 'and' are the shortcut evaluation or logical boolean operators. '&&' is from C like languages whereas 'and' is from languages like lua and python, where they try to improve readability by using natural language. Most languages don't let you choose between '&&' and 'and' but Garrysmod's implementation of lua allows some C like operators, however it is still mostly lua.[/QUOTE] duurhh... o.O
Sorry, you need to Log In to post a reply to this thread.