timer save. Help please
#1

Hey guys.
I know how to save things like variables.
But maybe a strange question:

How to save the time from a timer when it's not finished yet?
Like a jail timer.

My jail timer:

pawn Код:
SetTimerEx("outjail", GetPlayerWantedLevel(id)*60000*5, false, "i", id);
So when a player leaves. How can I save the time he has to do when he comes back online?

Thanks
Reply
#2

guys please
Reply
#3

ok i can help, in the function it should be something like:

public outjail (playerid, jailtime, blah,blah,blah)

Make a global variable (variable at top of script Ex: new JailTime[MAX_PLAYERS]

and in the timer add

Код:
JailTime[playerid] = jailtime;
Done.
Reply
#4

Quote:
Originally Posted by coole210
Посмотреть сообщение
ok i can help, in the function it should be something like:

public outjail (playerid, jailtime, blah,blah,blah)

Make a global variable (variable at top of script Ex: new JailTime[MAX_PLAYERS]

and in the timer add

Код:
JailTime[playerid] = jailtime;
Done.
Thanks, but not really what I needed.
I want that the time that the player still has when he disconnects saves.

this is how I save money:

dini_IntSet(udb_encode(playername), "money", money[playerid]);

But how will I save the time when a player connects taht he still has to sit in jail.
Reply
#5

Create a variable to store the amount of time left for the player, and run the timer every 5 seconds. Each time the timer is called, decrease the variable by 5. The, when it's zero, release them. If they leave the server, and their variable is greater than 0, they left while in jail, so you can save the variable in the file like you would anything else.

Also, I suggest you use another system besides dini, as it's the slowest INI system around. Look up SII, Y-ini or djSon.
Reply
#6

So if i'm right

When someone gets arrested:
pawn Код:
SetTimerEx("outjail", GetPlayerWantedLevel(id)*60000*5, false, "i", id);
So I will also make a new variable: new jailtime[MAX_PLAYERS];

And then @ my arrest command:
jailtime[id] = GetPlayerWantedLevel(id)*60000*5;

Then I'll start a new timer that will repeat.

First:
forward jailtime(playerid);

public jailtime(playerid)
{
jailtime[playerid] -= 5000
return 1;
}


Like that?
Reply
#7

Yeah that will work. Just make sure to assign the timer to a variable, that way once the player is released from jail, you kill the timer. (Or you could alternatively have the timer call re-call the timer, but that's a mess sometimes)
Reply
#8

Grim_ From when I know you you're my hero.And I know who you are for a long time already :P

Thanks in advance
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)