Unix timestamp! -
Renaldasj - 18.02.2014
Hi,
How I have to count time when the vip goes end? with timestamp? Like: Days, Hours.
I don't know how to do it...
Re: Unix timestamp! -
SkittlesAreFalling - 18.02.2014
Use gettime(); it will give you the current timestamp based off your computer's time.
Use it to add timestamp + (60 * 60 * 24) to the VIP variable, when you check the timestamp again and it's greater than the set value, end their VIP membership.
If you don't know PAWN, learn it or pay someone to do stuff like this for you.
Re: Unix timestamp! -
Renaldasj - 18.02.2014
Quote:
Originally Posted by SkittlesAreFalling
Use gettime(); it will give you the current timestamp based off your computer's time.
Use it to add timestamp + (60 * 60 * 24) to the VIP variable, when you check the timestamp again and it's greater than the set value, end their VIP membership.
If you don't know PAWN, learn it or pay someone to do stuff like this for you.
|
I have been learning PAWN like 1 years and 2 months... with gettime(); i hadn't any work, so this is my first work with them. Anyway thanks you very much!
Re: Unix timestamp! -
SkittlesAreFalling - 18.02.2014
Code:
new VIPTime[MAX_PLAYERS];
public OnPlayerConnect(playerid) {
VIPTime[playerid] = 0;
// Load VIPTime from a file.
if(VIPTime[playerid] != 0) {
// Give them membership.
}
return 1;
}
public OnPlayerDisconnect(playerid, reason) {
// Save the VIPTime variable.
}
public OnPlayerUpdate(playerid) {
new Timestamp = gettime();
if(Timestamp >= VIPTime[playerid]) {
// Cancel their membership.
VIPTime[playerid] = 0;
}
return 1;
}
stock AddMembershipForADay(playerid) {
if(! IsPlayerConnected(playerid)) {
return false;
}
if(VIPTime[playerid] == 0) { // new member
VIPTime[playerid] += gettime();
// Give them membership.
}
VIPTime[playerid] += (60 * 60 * 24);
return true;
}
Something like this, threw it together all in 5minutes.
Re: Unix timestamp! -
Renaldasj - 18.02.2014
I know that!!!! But I want to get a time until the vip is end. Like: Days. Until VIP end: 31day.
Re: Unix timestamp! -
SkittlesAreFalling - 18.02.2014
Oh, there's a script in the code snippets forum, someone made a reversal of the timestamp system.
Hold on let me find that for you.
Re: Unix timestamp! -
Renaldasj - 18.02.2014
ok, thanks very much ^^
Re: Unix timestamp! -
SkittlesAreFalling - 18.02.2014
http://forum.sa-mp.com/showpost.php?...&postcount=471
With this all you do (based on my code) do:
Code:
stock DisplayMembershipRemaining(playerid) {
new Format[100] = "No membership!";
if(! IsPlayerConnected(playerid)) {
return '\0';
}
if(VIPTime[playerid] == 0) {
return Format;
}
new timestamp = VIPTime[playerid] - gettime();
new year = 0, day = 0, month = 0, hour = 0, mins = 0, sec = 0;
new days_of_month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
while(timestamp > 31622400){
timestamp -= 31536000;
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
timestamp -= 86400;
}
year++;
}
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
days_of_month[1] = 29;
}
else {
days_of_month[1] = 28;
}
while(timestamp > 86400) {
timestamp -= 86400;
day++;
if(day==days_of_month[month]) {
day = 0;
month++;
}
}
while(timestamp > 60){
timestamp -= 60;
mins++;
if(mins == 60) {
mins=0;
hour++;
}
}
sec = timestamp;
format(Format, 31, "VIP Time Remaining: %02d/%02d/%d %02d:%02d:%02d", day+1, month+1, year, hour, mins, sec);
return Format;
}
Re: Unix timestamp! -
Renaldasj - 18.02.2014
THANKS MAN! THANKS YOU SOOO MUCH! YOU SAVED MY LIFE! TOMORROW WHEN I WILL WAKE UP I WILL GIVE U REP! THANKS AGAIN!
Re: Unix timestamp! -
GamemodeRP123 - 19.02.2014
Just /makevip or i think setvip or refund them to a certain days
__________________________________________________ ____
Come here new special Server, very good you will be
shock when seeing this new RP server...
HostName: [ENG]Future Generation Gaming[0.3x R2]
Address: 75.71.205.53:7777
Players: 4 / 250
Ping: 632
Mode: Roleplay FGG v3.5b
Map: Los Angeles
Really good RP need to try!