Creating a timer
#5

it matters if you are on windows or another OC

in windows you just could use tickcount or GetTickcount

pawn Код:
new TimeAlive[MAX_PLAYERS];
pawn Код:
//OnPlayerSpawn
    TimeAlive[playerid] = tickcount();
pawn Код:
//OnPlayerDeath
    TimeAlive[playerid] = tickcount() - TimeAlive[playerid];
TimeAlive[playerid] stores, after the second call, the time in milliseconds between spawn and death


If you use any other OS in which tickcount() doesnt work you could use a reapeating 1 second timer

pawn Код:
//OnPlayerSpawn
    TimeAlive[playerid] = 0; // resets the tracker
pawn Код:
//Timer which gets called each second
    for(new i; i < MAX_PLAYERS; ++i) {
        TimeAlive[i]++;
    }
TimeAlive[playerid] stores in this case the time in seconds
Reply


Messages In This Thread
Creating a timer - by slymatt - 20.07.2011, 22:41
Re: Creating a timer - by 0_o - 20.07.2011, 22:43
Re: Creating a timer - by slymatt - 20.07.2011, 22:46
Re: Creating a timer - by Daren_Jacobson - 20.07.2011, 22:48
AW: Re: Creating a timer - by Nero_3D - 20.07.2011, 23:29

Forum Jump:


Users browsing this thread: 1 Guest(s)