14.10.2009, 17:19
pawn Код:
new pOnlineTime[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
pOnlineTime[playerid] = GetTickCount();
// Maybe do some loading when the play logs in.
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new time = pOnlineTime[playerid] - GetTickCount();
// time = the time the player was online in milliseconds.
// Do saving stuff here.
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/command") && GetPlayingHours(playerid) >= 100)
{
SendClientMessage(playerid, 0x000000FF, "You have reached 100 hours!!");
return 1;
}
return 1;
}
stock GetPlayingHours(playerid)
{
return (pOnlineTime[playerid] - GetTickCount()) / 60 / 60);
}
Use GetPlayingHours to get the total playing hours the person is playing.