Possible to save timer?
#1

Hey. Look, can i make to save timer time? Say that i set timer to 100 hour, and after that something happen. But i didn't believe, that player play 100 hour's without DC, sleep and other stuf.. So, can i make that Dini saving timer time? And after login timer continue.
Reply
#2

Yea, possible.
Reply
#3

can make so every hour it ++ if you know what i mean, then when player login's in it reads how much time he has say 46 it add's on from there and when it hit's 100 make it do what you do if you dont get it i can write it down for you later to night when im on my PC as im on my phone.
Reply
#4

Quote:
Originally Posted by Shady91
can make so every hour it ++ if you know what i mean, then when player login's in it reads how much time he has say 46 it add's on from there and when it hit's 100 make it do what you do if you dont get it i can write it down for you later to night when im on my PC as im on my phone.
I think i got your idea.. But i'm not good on English speak. So better be for me, that you write script or explain with codes..
Reply
#5

Can someone show me example of that?
Reply
#6

pawn Код:
new pOnlineTime[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
  pOnlineTime[playerid] = GetTickCount();
  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;
}
Not compiled or anything, so there could be some typos
Reply
#7

Ok. Say that i make it. But now how set, that when i reached 100 hours, i can to use some command?
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)