20.07.2011, 23:29
it matters if you are on windows or another OC
in windows you just could use tickcount or GetTickcount
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
TimeAlive[playerid] stores in this case the time in seconds
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];
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]++;
}