Jump to content

Call a function after few days


WhoAmI

Recommended Posts

Posted

Hello.

Is there any way to call a function after 24h or after 7 days? I need it for my house system and renting house for day or 7 days. Thank you.

Posted

Hy WhoAmI,

sure, you can save the starting timestamp in a variable and check with a Timer (every Minute or if possible every hour) if the new timestamp is higher or equal to the starting timestamp+24h.

Or you can save the timestamp + 24h in the variable and check against this.

getRealTime() 
setTimer() 

Posted
Would probably be more optimal to assign the timer on resource start and let it execute with 24 hours delay.
setTimer(function, 1000*60*60*24, 0) 

And restarting the script 1 minute before 24 hours will give the player another 24 hours.

It's better you use an SQL database. Link

Posted

@Ab-47, First reply had the same issue, it's all about how often you want to execute these functions, using the start/stop events of the resource may also be a good solution that would bypass this issue, without wasting to much performance.

Posted

getTimerDetails returns how much time is left - when the resource stops, you could store all these values somewhere (preferably in a database) and when the resource starts, check if the values exist, if yes, set timers for that time, else, set for another 24 hours.

Posted

Yeah like "getRealTime()", start the timer, and when the resource stops, set the account data for the time it was stopped. Then when the resource starts again it could "getRealTime()" and add account data for the time it started again and calculate the difference between the stopped and started time. Would need a bit of math, but I'm sure it's possible.

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