SA-MP Forums Archive
Make a timer continue. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Make a timer continue. (/showthread.php?tid=465354)



Make a timer continue. - TonyII - 22.09.2013

How can I make a timer continue from where it stopped when the player logged out? It's like a countdown timer that should continue when the player gets back into the game


Re: Make a timer continue. - Ada32 - 22.09.2013

Write value to file, read when they log in.


Re: Make a timer continue. - TonyII - 22.09.2013

How is that possible, can you show me an example or something.


Re: Make a timer continue. - Mattakil - 22.09.2013

Using DINI or something like it (I use YINI), set the timer to one second, with a variable on the player that is set when the timer is set. When the timer activates, the variable would go down by one. Then, if you want it to reset when the player logs in, use OnPlayerConnect and something like if(playerinfo[playerid][pJail]!=0) to set the timer again, if the timer variable is 0, it wont do nothing. You can PM me if you need further help with this


Re: Make a timer continue. - TonyII - 22.09.2013

I don't want to reset a down counting timer, that wouldn't make sense


Respuesta: Make a timer continue. - Alex_Obando - 22.09.2013

pawn Код:
forward message();
 
public OnGameModeInit()
{
    SetTimer("message", 1000, false); // Set a timer of 1000 miliseconds (1 second)
}
 
public message()
{
    SendClientMessage(playerid, COLOR_GREEN, "1 second has passed!");

}
public message()
{
    SendClientMessage(playerid, COLOR_GREEN, "2 seconds has passed!");

}



Re: Make a timer continue. - TonyII - 22.09.2013

Guys, :@ please read before posting. Once a player used a command a timer of 15 minutes goes in, once the player logs out after 5 minutes past I want the timer to continue from the 10 minutes that is left once he logs back in.


Re: Make a timer continue. - Luis- - 22.09.2013

When someone logs in, set a timer for x amount of ms and increment the value.


Re: Make a timer continue. - DanishHaq - 22.09.2013

Make a SecondTimer that will go down each second, which'll be reoccurring, and then use that timer to put the player's seconds down. But, when the player leaves the game, you'll have to save that variable to the player's user files which will then load back up and the timer will continue once the player logs in again. What you want ain't that simple .


Re: Make a timer continue. - Konstantinos - 22.09.2013

Actually, no need for timer. Use GetTickCount when they login and store it in a variable, when they disconnect use again GetTickCount - the variable you stored before. So you get the time he was online in milliseconds, then you can convert them to seconds/minutes/hours/days or whatever you want!