Jump to content

Recommended Posts

Alguém poderia me dizer por que eu ainda consigo ativar e desativar o modo rp quantas vezes eu quiser sem aparecer a mensagem "Erro: Aguarde 5 minutos desde a ultima utilização do sistema de invulnerabilidade", é algum problema com o setTimer??? Poderia me ajudar a corrigir

 

 

 

 

 

NexT_COMMAND = { }
NexT_TIME = 2000
function toggleAfkMode(thePlayer, playerSource)
            if getElementData(thePlayer,"AfkOFF") then
                outputChatBox ( "Aguarde alguns segundos, estamos verificando sua ultima utilização", thePlayer, 244,189,56 )
            end
            
            if getElementData(thePlayer,"AfkON") then
                outputChatBox ( "Desativando modo RP...", 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 ( "Modo RP: desativado.", thePlayer, 56,244,69 )
                
        
        
         else
            if (NexT_COMMAND[playerSource]) then
                return outputChatBox ( "Erro: Aguarde 5 minutos desde a ultima utilização do sistema de invulnerabilidade", 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 ( "Modo RP: ativado.", thePlayer, 56,244,69 )
            
            NexT_COMMAND[playerSource] = true
            setTimer( function()
                NexT_COMMAND[playerSource] = false
            end, NexT_TIME, 1)
        end
    end, 3000, 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)

Link to comment

Hello NewMemberScript and welcome to our MTA scripting forums,

could you please format your Lua code properly using the "<>" button in the richtext editor?

Also please post in English because I cannot really understand your problem... :( 

  • Like 1
Link to comment
1 hour ago, NewMemberScript said:

NexT_COMMAND = { }
NexT_TIME = 2000
function toggleAfkMode(thePlayer, playerSource)
            if getElementData(thePlayer,"AfkOFF") then
                outputChatBox ( "Aguarde alguns segundos, estamos verificando sua ultima utilização", thePlayer, 244,189,56 )
            end
            
            if getElementData(thePlayer,"AfkON") then
                outputChatBox ( "Desativando modo RP...", 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 ( "Modo RP: desativado.", thePlayer, 56,244,69 )
                
        
        
         else
            if (NexT_COMMAND[playerSource]) then
                return outputChatBox ( "Erro: Aguarde 5 minutos desde a ultima utilização do sistema de invulnerabilidade", 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 ( "Modo RP: ativado.", thePlayer, 56,244,69 )
            
            NexT_COMMAND[playerSource] = true
            setTimer( function()
                NexT_COMMAND[playerSource] = false
            end, NexT_TIME, 1)
        end
    end, 3000, 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)

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
Link to comment
4 minutes ago, NewMemberScript said:

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

I think the message is confusing. The timer just waits 2 seconds and not 5 minutes. I doubt that you are typing "/rp" two times faster than 2 seconds. But the script above does prevent ... "rapid" enabling. And then there is this weirdness about a timer inside of a timer. Maybe try increasing some timers?

  • Thanks 1
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...