Create a file named viptime.ini inside the scriptfiles folder then copy this code:
BTW: This may not be an efficient way; just the first thing that came to my head :P
Код:
forward GiveVIPTime(playerid);
forward CheckVIPTime(playerid);
public GiveVIPTime(playerid) //use when he gets vip
{
new hour, minute, second, day,month,year;
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
new string[128];
format(string, sizeof(string), "%s", PlayerName);
mktime(hour,minute,second,day,month,year);
dini_Set("viptime.ini", string, month);
return 1;
}
public CheckVIPTime(playerid)
{
new hour, minute, second, day,month,year;
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
new string[128];
format(string, sizeof(string), "%s", PlayerName);
new result[64];
result = dini_Get("viptime.ini", string);
mktime(hour,minute,second,day,month,year);
if(strcmp(result, month, true) != 0)
{
dini_Unset("viptime.ini", string); //vip time ran out
}
return 1;
}
public OnPlayerConnect(playerid)
{
CheckVIPTime(playerid);
return 1;
}
stock mktime(hour,minute,second,day,month,year) {
new timestamp2;
timestamp2 = second + (minute * 60) + (hour * 3600);
new days_of_month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) ) {
days_of_month[1] = 29; // Schaltjahr
} else {
days_of_month[1] = 28; // keins
}
new days_this_year = 0;
days_this_year = --day;
if(month > 1) { // No January Calculation, because its always the 0 past months
for(new i=0; i<month-1;i++) {
days_this_year += days_of_month[i];
}
}
timestamp2 += days_this_year * 86400;
for(new j=1970;j<year;j++) {
timestamp2 += 31536000;
if ( ((j % 4 == 0) && (j % 100 != 0)) || (j % 400 == 0) ) timestamp2 += 86400; // Schaltjahr + 1 Tag
}
return timestamp2;
}
Have fun!
Quote:
Originally Posted by ("GгNSTг")
Why can't u just remove it urself saves time :P
|
It doesnt save time, this is actually easier and this is a good help thread that he made because many other people will probably have the same question.