the time command
#3

Store a Unix Timestamp in the player's character file.

Unix Timestamps are the amount of seconds it has been since January 1 1970, these are commonly used for anything related to temporary functions in most programming languages, usage of a Unix Timestamp for this would be ideal.

Store a timestamp in the character's file (an integer) saving what time they should lose their leadership, so you get the current unix time/stamp using gettime() without any parameters, then add however many seconds you need to it, then when the player logs back in - see if their timestamp you saved exceeds the current gettime(), do it for every login.

The code below demonstrates an example of how you can get a timestamp properly.

pawn Код:
CMD:iwanttolead(playerid, params[]) {
   // gettime() + 86400; << Gets the timestamp for tomorrow, at the exact same time
   new iDays = strval(params) * 86400; // strval(params) is the days entered, multiplied by how many seconds are in a day
   new iDynamicTime = gettime() + iDays; // Add the amount of seconds we need and we've got our timestamp
   return 1;
}
Reply


Messages In This Thread
the time command - by Swiftz - 13.05.2011, 08:58
Re: the time command - by Mike Garber - 13.05.2011, 09:16
Re: the time command - by __ - 13.05.2011, 09:18
Re: the time command - by Swiftz - 13.05.2011, 14:01
Re: the time command - by __ - 13.05.2011, 14:40

Forum Jump:


Users browsing this thread: 1 Guest(s)