12.02.2016, 21:45
When it is saturday and the time is 00:00 my script should update the DB using a query but it just doesn't work.
This are the timer and functions
resettimer = SetTimer("resettime", 60000, 1);
This are the timer and functions
resettimer = SetTimer("resettime", 60000, 1);
Код:
public resettime()
{
new tmphour;
new tmpminute;
new tmpsecond;
new day,month,year;
new weekday;
gettime(tmphour, tmpminute, tmpsecond);
getdate(day, month, year);
weekday = GetWeekdayNum(day, month, year);
if(weekday == 6 && tmphour == 0 && tmpminute == 0)
{
new querypanel[500];
format(querypanel, sizeof(querypanel), "UPDATE playeraccounts SET pRunners = 0, pArrests = 0, pTickets = 0, pDConf = 0, pLConf = 0, pLGive = 0, pTOrders = 0, pHealed = 0, pContracts = 0, pNews = 0, pLive = 0, pDDep = 0, pMaDep = 0, pMoDep = 0, pWK = 0, pWD = 0, pMUsed = 0");
mysql_tquery(handle, querypanel);
}
return 1;
}
public GetWeekdayNum(day,month,year) //by d.wine
{
month-=2;
if(month<=0)
{
year--;
month+=12;
}
new cen = year/100;
year=getrem(year,100);
new w = day + ((13*month-1)/5) + year + (year/4) + (cen/4) - 2*cen;
w=getrem(w,7);
if (w==0) w=7;
return w-1;
}
getrem(a,b) //get remnant of division
{
new div = a/b;
new left = a-b*div;
return left;
}


