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; }
Query doesn't contain any specific data, so this should be all that you need: http://forum.sa-mp.com/showthread.ph...vent+scheduler
Running a timer every minute is seriously inefficient considering the function itself would only get executed 0.00009920634% of the time. |
if(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 WHERE DAYOFWEEK(CURDATE()) = '6'"); mysql_tquery(handle, querypanel); }
You're completely missing the point here. No, you don't need to run it from the gamemode because a) the query itself does not contain anything special and doesn't even have to be formatted and b) because having a timer that's just eating up CPU 99.9999% of the time is totally inefficient.
|
CREATE EVENT `reset_column` ON SCHEDULE EVERY 1 WEEK STARTS '2016-02-15 00:00:00' DO BEGIN 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 END */$$ DELIMITER ;