NexT_COMMAND = { }
NexT_TIME = 2000
function toggleAfkMode(thePlayer, playerSource)
if getElementData(thePlayer,"AfkOFF") then
outputChatBox ( "Wait a few seconds, we are checking your last use", thePlayer, 244,189,56 )
end
if getElementData(thePlayer,"AfkON") then
outputChatBox ( "Disabling mode ...", thePlayer, 244,189,56 )
end
setTimer(function()
if getElementData(thePlayer,"AfkMode") then
setElementData(thePlayer,"AfkMode",false)
setElementData(thePlayer,"AfkOFF",true)
setElementData(thePlayer,"AfkON",false)
setElementAlpha(thePlayer, 255)
toggleControl (thePlayer, "fire", true)
toggleControl (thePlayer, "next_weapon", true)
toggleControl (thePlayer, "previous_weapon", true)
toggleControl (thePlayer, "aim_weapon", true)
outputChatBox ( "PRMode: disabled.", thePlayer, 56,244,69 )
else
if (NexT_COMMAND[playerSource]) then
return outputChatBox ( "Error: Wait 5 minutes since the last use of the invulnerability system", thePlayer, 244,56,56 )
end
setElementData(thePlayer,"AfkMode",true)
setElementData(thePlayer,"AfkOFF",false)
setElementData(thePlayer,"AfkON",true)
setElementAlpha(thePlayer, 127)
toggleControl (thePlayer, "fire", false)
toggleControl (thePlayer, "next_weapon", false)
toggleControl (thePlayer, "previous_weapon", false)
toggleControl (thePlayer, "aim_weapon", false)
outputChatBox ( "RP mode: enabled.", thePlayer, 56,244,69 )
NexT_COMMAND[playerSource] = true
setTimer( function()
NexT_COMMAND[playerSource] = false
end, NexT_TIME, 1)
end
end, 1000, 1)
end
addCommandHandler("rp",toggleAfkMode)
function login_AFKOFF (thePlayer)
setElementData(thePlayer,"AfkOFF",true)
end
addEventHandler("onPlayerLogin",root, login_AFKOFF)
function logout_AFKOFF (thePlayer)
setElementData(thePlayer,"AfkOFF",true)
end
addEventHandler("onPlayerLogout",root, logout_AFKOFF)
function join_AFKOFF (thePlayer)
setElementData(thePlayer,"AfkOFF",true)
end
addEventHandler("onPlayerJoin",root, join_AFKOFF)
Could someone tell me why I can still activate and deactivate the rp mode as many times as I want without the message "Error: Wait 5 minutes since the last use of the invulnerability system", is it a problem with setTimer ??? Could you help me fix