Playing hours not working
#1

its not incrementing by minutes as intended

pawn Код:
public PlayingHours(playerid)
{

      playerVariables[playerid][pMinutes]++;
      if(playerVariables[playerid][pMinutes] == 60)
      {
      playerVariables[playerid][pPlayingHours]++;
      playerVariables[playerid][pMinutes] = 0;
      }
      return 1;

public OnPlayerConnect(playerid)
{
    SetTimerEx("PlayingHours", 60000, true, "i", playerid);
    return 1;
}
Reply
#2

Try to replace SetTimerEx("PlayingHours", 60000, true, "i", playerid); with SetTimerEx("PlayingHours", 10000, true, "i", playerid); and add a new variable, second?

pawn Код:
public PlayingHours(playerid)
{
playerVariables[playerid][pSeconds]++;
if(playerVariables[playerid][pSeconds] == 60)
{
      playerVariables[playerid][pMinutes]++;
      playerVariables[playerid][pSeconds] = 0;
}
      if(playerVariables[playerid][pMinutes] == 60)
      {
      playerVariables[playerid][pPlayingHours]++;
      playerVariables[playerid][pMinutes] = 0;
      }
      return 1;
}
Reply
#3

a timer that repeats every 1 second? i doubt thats an efficient way to do it
Reply
#4

I use it. I could give you my script of it.
And it's working.
Reply
#5

Well, i prefer a more if not the most efficient way to work with this snippet
Reply
#6

most simple/efficient/reliable/less memory usage connected time check
NetStats_GetConnectedTime(playerid);

returns the players connected time for the session in milli seconds 1000ms/sec

EX:
(this is just an example and i havent tested it yet but you can use my stock BTW)
pawn Код:
enum PLAYER_ENUM{ // change this to your own enum
pMinutes,
pPlayingHours,
pMilliseconds, // add this one to your player enum
...
}



CMD:mytime(playerid,params[])
{
    new Float:hours,Float:minutes,Float:seconds,msg[128];
    MyTimeInHMS(playerid,hours,minutes,seconds);
    format(msg,sizeof(msg),"Your connected time Hour:%0.f Minutes:%0.f Seconds:%0.f",hours,minutes,seconds);
    return 1;
}

stock MyTimeInHMS(playerid,&Float:hours,&Float:minutes,&Float:seconds)
{
    new Float:milliseconds=NetStats_GetConnectedTime(playerid)+playerVariables[playerid][pMilliseconds];
    hours=milliseconds/3600000;
    milliseconds%=36000000;
    minutes=milliseconds/60000;
    milliseconds%=60000;
    seconds=milliseconds/1000;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)