|
Notice this is untested, but should work:
GetDateAfterMinutes(minutes,&day,&month,&year) { new sec = gettime() + minutes*60; getdate(year,month,day); day+=sec / 60 / 60 / 24; new dim[12]={31,28,31,30,31,30,31,31,30,31,30,31}; while(day > dim[month-1]+(month==2 && year%4 == 0 ? 1 : 0)) { day -= dim[month-1]+(month==2 && year%4 == 0 ? 1 : 0); month++; year+=month/12; month=month%12; } } I think that works! If not, tell me!(im not on my pc and unable to test.) |
|
(Don't tell me to download a pre made tempban script, i don't like to use scripts made by others...)
|
stock Now()
{
new hour,minute,second,year,month,day;
gettime(hour, minute, second);
getdate(year, month, day);
return mktime(hour,minute,second,day,month,year);
}
PlayerInfo[playerid][pBanTime] += (Now() + 3600);
if(PlayerInfo[playerid][pBanTime] <= Now())
{
PlayerInfo[playerid][pBanTime] = 0;
}
|
The unix timestamp is fine for tempbans
To learn for noobs: https://sampforum.blast.hk/showthread.php?tid=254915 Код:
stock Now()
{
new hour,minute,second,year,month,day;
gettime(hour, minute, second);
getdate(year, month, day);
return mktime(hour,minute,second,day,month,year);
}
Код:
PlayerInfo[playerid][pBanTime] += (Now() + 3600); Код:
if(PlayerInfo[playerid][pBanTime] <= Now())
{
PlayerInfo[playerid][pBanTime] = 0;
}
|
stock mktime(hour, minute, second, day, month, year)
{
static
days_of_month[12] =
{
31,
29,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31
},
lMinute,
lHour,
lDay,
lMonth,
lYear,
lMinuteS,
lHourS,
lDayS,
lMonthS,
lYearS;
if (year != lYear)
{
lYearS = 0;
for (new j = 1970; j < year; j++)
{
lYearS += 31536000;
if ((!(j % 4) && (j % 100)) || !(j % 400)) lYearS += 86400;
}
lYear = year;
}
if (month != lMonth)
{
lMonthS = 0;
month--;
for (new i = 0; i < month; i++)
{
lMonthS += days_of_month[i] * 86400;
if ((i == 1) && ((!(year % 4) && (year % 100)) || !(year % 400))) lMonthS += 86400;
}
lMonth = month;
}
if (day != lDay)
{
lDayS = day * 86400;
lDay = day;
}
if (hour != lHour)
{
lHourS = hour * 3600;
lHour = hour;
}
if (minute != lMinute)
{
lMinuteS = minute * 60;
lMinute = minute;
}
return lYearS + lMonthS + lDayS + lHourS + lMinuteS + second;
}