X-SHADOW Posted March 16, 2012 Share Posted March 16, 2012 Hi all iam trying to make commands script see but i think i did not make it right local spam = {} function list () if(not spam[source]) then spam[source] = 1 elseif (spam[source] == 5) then cancelevent() outputChatBox("Please refrain From Command Spamming !", source, 255, 0, 0) else spam[source] == spam[source] + 1 end end addEventHandler("onPlayerCommand", root, list) setTimer(function list = {} end, 2000, 0) function sa (cmd) if cmd == 'gun' then outputChatBox(getPlayerName(source) .. "Has Write [Gun] !",255,255,0) elseif cmd == 'rsp' then outputChatBox(getPlayerName(source) .. "Has Write [rsp] ! ",255,255,0) end end addEventHandler("onPlayerCommand", root, sa) Link to comment
Al3grab Posted March 16, 2012 Share Posted March 16, 2012 cancelevent() should be cancelEvent() Link to comment
arezu Posted March 16, 2012 Share Posted March 16, 2012 There were lots of syntax errors, and it would not work either way. (Lua tag doesn't work correctly) function handleCommands() local commandCount = getElementData(source, "command.count") or 0 if(commandCount == 5) then cancelEvent() outputChatBox("Please refrain From Command Spamming !", source, 255, 0, 0) else setElementData(source, "command.count", commandCount + 1) end end addEventHandler("onPlayerCommand", root, handleCommands) setTimer( function() for k, player in pairs(getElementsByType("player")) do setElementData(player, "command.count", 0) end end, 5000, 0) function sa (cmd) if cmd == 'gun' then outputChatBox(getPlayerName(source) .. Has Write [Gun] !,255,255,0) else if cmd == 'rsp' then outputChatBox(getPlayerName(source) .. Has Write [rsp] ! ,255,255,0) end end addEventHandler("onPlayerCommand", root, sa) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now