Jump to content

help with onPlayerCommand


X-SHADOW

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...