SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 12/12/2017, 08:27 AM   #1
Juvanii
Huge Clucker
 
Juvanii's Avatar
 
Join Date: Jun 2014
Location: San Andreas
Posts: 352
Reputation: 21
Default Max Limit Looping every 1 Second ?

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 ?
__________________
Juvanii is offline   Reply With Quote
Old 12/12/2017, 08:46 AM   #2
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 277
Reputation: 56
Default Re: Max Limit Looping every 1 Second ?

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.
__________________
Need Help? Use Search, WIKI, and FAQ
RoboN1X is offline   Reply With Quote
Old 12/12/2017, 08:53 AM   #3
Juvanii
Huge Clucker
 
Juvanii's Avatar
 
Join Date: Jun 2014
Location: San Andreas
Posts: 352
Reputation: 21
Default Re: Max Limit Looping every 1 Second ?

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;

__________________
Juvanii is offline   Reply With Quote
Old 12/12/2017, 10:03 AM   #4
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,554
Reputation: 2998
Default Re: Max Limit Looping every 1 Second ?

Why are you not using multiple timers with the correct times, instead of one monolithic piece of code that checks for elapsed times?
Y_Less is offline   Reply With Quote
Old 12/12/2017, 11:43 AM   #5
Juvanii
Huge Clucker
 
Juvanii's Avatar
 
Join Date: Jun 2014
Location: San Andreas
Posts: 352
Reputation: 21
Default Re: Max Limit Looping every 1 Second ?

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.
__________________
Juvanii is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping Darkwood17 Scripting Help 10 11/07/2015 07:54 AM
Object Limit/Mapping Limit? EdwardOwen Server Support 5 08/07/2014 11:12 PM
Looping Glint Scripting Help 10 19/10/2012 07:23 PM
SAMP 0.3D TextDraw Limit (Text Limit) Grimrandomer Scripting Help 3 21/03/2012 08:11 PM
Looping cu MOA Alxxie Romānă/Romanian 4 03/04/2010 07:56 PM


All times are GMT. The time now is 02:59 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.