SetTimer for so many days?
#3

Step 1 - How many seconds in a day?
60 seconds in a minute
60 minutes in an hour
24 hours in a day
60 * 60 * 24 = 86400

Step 2 - Save the current timestamp PLUS 86400 in their account
gettime() returns the number of seconds passed since 1 Jan 1970 (or something). Using this, get the current timestamp and add 86400 to it and save that to their account, this can then to be used to tell whether a day (86400 seconds) has passed. You'll want to save it in mySQL/files because of course variables get reset.

Step 3 - Check if it's been a day
Very simple:

pawn Код:
if(gettime() < the_value_you_saved_to_their_account) return SendClientMessage(playerid, COLOR_RED, "You can only use this command once a day.");
To find out how long until they can use the command (in seconds):

gettime() - the_value_you_saved_to_their_account



For example, say the current timestamp is a million: 1,000,000

At this time, they use the command, the value of when they can use it again gets saved to their account:

1,000,000
+ 86400
= 1,086,400

They can only use this command after the timestamp is over 1,086,400, meaning a day has passed.
Reply


Messages In This Thread
SetTimer for so many days? - by Goldilox - 17.06.2013, 05:18
Respuesta: SetTimer for so many days? - by JustBored - 17.06.2013, 05:26
Re: SetTimer for so many days? - by MP2 - 17.06.2013, 05:35
Re: SetTimer for so many days? - by Goldilox - 17.06.2013, 20:19
AW: SetTimer for so many days? - by BigETI - 17.06.2013, 20:28
Re: SetTimer for so many days? - by Goldilox - 17.06.2013, 21:02
AW: SetTimer for so many days? - by BigETI - 17.06.2013, 22:51
Re: SetTimer for so many days? - by cessil - 17.06.2013, 23:26
Re: SetTimer for so many days? - by Goldilox - 18.06.2013, 16:27

Forum Jump:


Users browsing this thread: 2 Guest(s)