timers mysql - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: timers mysql (
/showthread.php?tid=626734)
timers mysql -
LongQuad - 19.01.2017
what's the chance for server crash by handling many timers at same time ?
It's for an roleplay server and I need to handle timers like
Experience for 1 hour playing
8 hours for leave a job
Time restriction on command's use like /b, /mp
And another ones i can't remember
So, what's the correct way to handle many timers at same time with a low chance for server crash ?
Re: timers mysql -
Vince - 19.01.2017
Second and third ones can be handled with timestamps (gettime()). First one possibly too depending on how accurate it really needs to be. Timers can be avoided in lots of cases and are only really useful if something MUST happen after the set time. Command restrictions work as follows:
PHP код:
CMD:mycommand(playerid, params[])
{
static lastExecutedTime[MAX_PLAYERS]; // static so remembers value
if(gettime() - lastExecutedTime[playerid] < 60)
{
// send message about waiting
return 1;
}
lastExecutedTime[playerid] = gettime();
// rest of command here
return 1;
}
Re: timers mysql -
GhostHacker9 - 20.01.2017
Quote:
Originally Posted by Vince
Second and third ones can be handled with timestamps (gettime()). First one possibly too depending on how accurate it really needs to be. Timers can be avoided in lots of cases and are only really useful if something MUST happen after the set time. Command restrictions work as follows:
PHP код:
CMD:mycommand(playerid, params[])
{
static lastExecutedTime[MAX_PLAYERS]; // static so remembers value
if(gettime() - lastExecutedTime[playerid] < 60)
{
// send message about waiting
return 1;
}
lastExecutedTime[playerid] = gettime();
// rest of command here
return 1;
}
|
Use char arrays in this so as the code is more optimised using regular array in this case just displays a bad programming structure and habits in you.