Jump to content

damageTimer


WiBox

Recommended Posts

Hello, I'm trying to add a damageTimer as if the player was damaged last 20 second he can't use a specific command...

damageTimer = {}
function test()
    if ( isTimer(damageTimer) ) then 
        killTimer(damageTimer)
    end
    setElementData(source, "damage", "yes")
    if ( getElementData(source,"damage") == "yes" ) then
        setElementData(source,"damage", "no")
        setTimer(
            function ()
                removeCommandhandler("ldm")
            end
        end,15000,1)
    end
    addCommandhandler("ldm", LAJDM)
end
addEventHandler("onPlayerDamage", test)

Well, it didn't work shamefully, but I just need to know where are my mistakes... Thanks.

" No error in /debugscript 3 " 

Edited by SSKE
Link to comment
  • Moderators

Mistakes:

1. You didn't save your timer. + A timer isn't the same as table.

2. If you set the element data to "no" before you set the timer = it has no function at all. You might consider remove it.

 

 

Link to comment
damageTimer = {}
addEventHandler("onPlayerDamage", root,
	function()
		if not isTimer(damageTimer[source]) then
			removeCommandHandler("ldm")
			damageTimer[source] = setTimer(function(source)
				damageTimer[source] = nil
				addCommandHandler("ldm")
			end, 20000, 1, source)
		end
	end
)

 

 

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...