06.02.2009, 17:30
example:
It's best to change MAX_PLAYERS to your own variable, I won't explain why, because many other people have done so before, and you can get at it by searching.
pawn Код:
new PlayTime[MAX_PLAYERS];
public OnGameModeInit()
{
SetTimer("TimeUpdate",1000, 1);
}
public OnPlayerConnect(playerid)
{
PlayTime[playerid] = 0;
// load previous time stats somehow, not my problem :)
}
public OnPlayerDisconnect(playerid, reason)
{
// save previous time stats somehow, also not my problem :)
}
public TimeUpdate()
{
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
PlayTime[i]++;
if (PlayTime[i] > 3600)
SetPlayerScore(i, ((PlayTime[i] / 60) / 60));
else
SetPlayerScore(i, 0);
}
}
}