Time help
#1

I have a time for when vip runs out and i tryed setting it for a month but it sets it to 42. Does anyone know how to fix it?

((CODE))
Код:
	}
						case 1:
						{
						    format(string, sizeof(string), "Administrator %s has set your VIP status to Bronze.", GetName(playerid));
						    format(string2, sizeof(string2), "You have set %s's VIP status to Bronze.", GetName(id));
							dini_IntSet(file, "VipRank", 1);
							dini_IntSet(file, "VipTime", gettime() + 2592000);
							Player[id][VipRank] = 1;
Reply
#2

gettime() gets the UNIX time and then you add 2,592,000ms (which is 4.32 hours aka 0.18 days).

60,000ms = 60s
3,600,000ms = 60min
86,400,000ms = 24hr
2,678,400,000ms = 31days
Reply
#3

Quote:
Originally Posted by SKAzini
Посмотреть сообщение
gettime() gets the UNIX time and then you add 2,592,000ms (which is 4.32 hours aka 0.18 days).

60,000ms = 60min
14,440,000ms = 24hr
447,640,000ms = 31days (1 month)
When i chnage it it goes to 56 days? Why does it do that?
Reply
#4

2,678,400,000 = 31 days.
Reply
#5

Ok i've done this and it says 8 days now.Do i need any special include because at the moment i have #include <time>
}
case 1:
{
format(string, sizeof(string), "Administrator %s has set your VIP status to Bronze.", GetName(playerid));
format(string2, sizeof(string2), "You have set %s's VIP status to Bronze.", GetName(id));
dini_IntSet(file, "VipRank", 1);
dini_IntSet(file, "VipTime", gettime() + 2678400000);
Player[id][VipRank] = 1;
}
Reply
#6

bump
Reply
#7

The number in your first post was correct

First the unix timestamp is in seconds, would it be in ms the 32 bit variable would overflow after 24 days and its running since 1970...

2 592 000 secs = 43 200 mins = 720 hours = 30 days
2 678 400 secs = 31 days

Quote:
Originally Posted by arko123
Посмотреть сообщение
Ok i've done this and it says 8 days now
Show us the code which tells you that
Reply
#8

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
The number in your first post was correct

First the unix timestamp is in seconds, would it be in ms the 32 bit variable would overflow after 24 days and its running since 1970...

2 592 000 secs = 43 200 mins = 720 hours = 30 days
2 678 400 secs = 31 days



Show us the code which tells you that
Here you go
Код:
	if(Player[playerid][VipRank] > 0)
		{
         new file[256];
         format(file, 256, "Accounts/%s.ini", GetName(playerid));
		 new time = (gettime() - dini_Int(file, "VipTime"));
		 new daysleft;
		 daysleft = strval(timec(time));
  	     format(string, sizeof(string), "Married To: %s | Crimes: %d | Rank: %s | VIP: %s | VIP Expiration: %d Days", Player[id][MarriedTo], Player[id][CriminalOffences], Rank, VipDate, daysleft);
  		 SendClientMessage(playerid, WHITE, string);
		}
Reply
#9

Quote:
Originally Posted by arko123
Посмотреть сообщение
Here you go
Код:
	if(Player[playerid][VipRank] > 0)
		{
         new file[256];
         format(file, 256, "Accounts/%s.ini", GetName(playerid));
		 new time = (gettime() - dini_Int(file, "VipTime"));
		 new daysleft;
		 daysleft = strval(timec(time));
  	     format(string, sizeof(string), "Married To: %s | Crimes: %d | Rank: %s | VIP: %s | VIP Expiration: %d Days", Player[id][MarriedTo], Player[id][CriminalOffences], Rank, VipDate, daysleft);
  		 SendClientMessage(playerid, WHITE, string);
		}
Just checked out the tutorial which you mostly used, there I also found the function timec
You used it wrong, the code should look like that

timec already returns a string which looks like (x min / hour / days / months / ...)
pawn Код:
//
    if(Player[playerid][VipRank] > 0) {
        new
            file[64]
        ;
        format(file, sizeof file, "Accounts/%s.ini", GetName(playerid));
        format(string, sizeof string,
            "Married To: %s | Crimes: %d | Rank: %s | VIP: %s | VIP Expiration: %s",
            Player[id][MarriedTo],
            Player[id][CriminalOffences],
            Rank,
            VipDate,
            timec(dini_Int(file, "VipTime"))
        );
        SendClientMessage(playerid, WHITE, string);
    }
Also use [pawn][/pawn] instead of [code][/code]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)