Possible to save timer?
#8

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);
}
Not compiled and tested or anything so there could be some typos

Use GetPlayingHours to get the total playing hours the person is playing.
Reply


Messages In This Thread
Possible to save timer? - by cepiokas - 14.10.2009, 16:14
Re: Possible to save timer? - by MenaceX^ - 14.10.2009, 16:16
Re: Possible to save timer? - by shady91 - 14.10.2009, 16:18
Re: Possible to save timer? - by cepiokas - 14.10.2009, 16:21
Re: Possible to save timer? - by cepiokas - 14.10.2009, 16:43
Re: Possible to save timer? - by [nl]daplayer - 14.10.2009, 16:47
Re: Possible to save timer? - by cepiokas - 14.10.2009, 16:56
Re: Possible to save timer? - by [nl]daplayer - 14.10.2009, 17:19

Forum Jump:


Users browsing this thread: 1 Guest(s)