Max Limit Looping every 1 Second ? - 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)
+---- Forum: Discussion (
https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: Max Limit Looping every 1 Second ? (
/showthread.php?tid=646179)
Max Limit Looping every 1 Second ? -
Juvanii - 12.12.2017
Dears ,
I wanna know what is the max number can i loop in one second ?
Situation:
I have created a system which is based on the game-time-in-seconds such as:
PHP Code:
public OnGameModeInit()
{
SetTimer("ClockTimerSystem",1000,true);
return 1;
}
forward ClockTimerSystem();
public ClockTimerSystem()
{
//code of updating time ..
// ..
// ..
// ..
// ..
for(new i = 0; i < ??; i++) // I'm checking for about 400 variables
{
if(Variable[i] == 0) continue;
// Big Code includes (UPDATE statement of MySQL)
// ..
// ..
// ..
}
return 1;
}
Everything is working fine, but the system stills new and most of the variables are equal to 0
I don't know if this will cause a lag to the server if the 400 variables were equal to 1
Do you have any advice, or leaving it like this ?
Re: Max Limit Looping every 1 Second ? -
RoboN1X - 12.12.2017
What is the purpose of storing it every seconds? If your variables are similar then a single update to multiple variables each second could be made.
Re: Max Limit Looping every 1 Second ? -
Juvanii - 12.12.2017
Well, i should have mentioned this part of code:
PHP Code:
forward ClockTimerSystem();
public ClockTimerSystem()
{
Time ++;
for(new i = 0; i < 400; i++)
{
if(Variable[i] == 0) continue;
if(Variable[i] == Time)
{
// Big Code includes (UPDATE statement of MySQL)
// ..
// ..
// ..
}
}
return 1;
}
Re: Max Limit Looping every 1 Second ? -
Juvanii - 12.12.2017
Quote:
Originally Posted by Y_Less
Why are you not using multiple timers with the correct times, instead of one monolithic piece of code that checks for elapsed times?
|
I'll loop the same loop every one second in the other timer to check if the variable equals to the game-time. It doesn't make any sense.
Sorry, maybe i didn't understand you well but i replied on what i understood from your post.