Max Limit Looping every 1 Second ?
#1

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 0< ??; 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 ?
Reply
#2

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.
Reply
#3

Well, i should have mentioned this part of code:

PHP Code:
forward ClockTimerSystem();
public 
ClockTimerSystem()
{
    
Time ++;
    for(new 
0400i++)
    {
        if(
Variable[i] == 0) continue;
        if(
Variable[i] == Time)
        {
            
// Big Code includes (UPDATE statement of MySQL)
            // ..
            // ..
            // ..
        
}
    }
    return 
1;

Reply
#4

Quote:
Originally Posted by Y_Less
View Post
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)