Make a timer continue.
#1

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
Reply
#2

Write value to file, read when they log in.
Reply
#3

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

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
Reply
#5

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

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!");

}
Reply
#7

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.
Reply
#8

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

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 .
Reply
#10

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)