the time command
#1

I want to make this command, To make someone leader for specific amount of time (in days) . If the define is playerinf(leader) = 0 (For not leader) 1 for leader. So if the time ends. It should automatically bcum playerinf(leader) = 0. leader variable will be ofcourse stored in userfiles. So how to make this? i think we need to store the days in a file and something, Please help
Reply
#2

xkirill's code wont work, You have to use SetTimerEx
Reply
#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
#4

Actually will that still count time after restart?
Reply
#5

Yes, it will if you save the timestamp to an account file or use another way of saving data.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)