Jump to content

How to set timer for this function?


Tycka

Recommended Posts

Hello, for example I have function like this:

 

function HP ( )
setElementData(source, "HP", 100)
end 
addEvent( "HP", true )
addEventHandler( "HP", getRootElement(),HP )

How to make that after this function is used, next time it can be used after 15minutes? (For every player individually)

Link to comment

is this what are you searching for?

if all this stuff must be done serverside (as i think reading your example), simply create a table that stores all these timers that you handle on player connect/quit, if the function is clientside it's as easy as creating one timer clientside. Another way to do it if the function HP() you are calling is serverside is creating timers clientside, and then triggering the event fom the client instead of managing server-side all the timers that triggers the event.

Hope i've been clear and understood what you mean.

Edited by LoPollo
Link to comment
3 hours ago, Tycka said:

Hello, for example I have function like this:

 


function HP ( )setElementData(source, "HP", 100)end addEvent( "HP", true )addEventHandler( "HP", getRootElement(),HP )

How to make that after this function is used, next time it can be used after 15minutes? (For every player individually)

function HP ()
setElementData(source, "HP", 100)
end 
addEvent("HP", true)
addEventHandler("HP", getRootElement(), HP)

setTimer(HP, 900000, 0)

or

addEvent("HP", true)
addEventHandler("HP", getRootElement(), function ()
setTimer(function()
setElementData(source, "HP", 100)
	end, 900000, 0)
end)

But if you want to health then use "setElementHealth"

Edited by 1LoL1
Link to comment
hptimer=false

function HP()
    if(hptimer==false) then
        setElementData(source, "HP", 100)
        hptimer=true
    else
        outputChatBox("Please wait atleast 15 minutes.", 255, 0, 0)
        setTimer(function() hptimer=false end, 15*60*1000, 1)
    end
end

addEvent("HP", true)
addEventHandler("HP", getRootElement(), HP)

 

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