13.05.2011, 09:18
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.
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;
}