Defining MAX_PLAYERS
#10

Just looping through all available player-slots and checking if they're online is fast enough.

PHP код:
    new starttimeendtimeblabla;
    
starttime GetTickCount();
    for (new 
i1000000i++)
        if (
APlayerData[0][LoggedIn] == true)
            
blabla 0;
    
endtime GetTickCount();
    
printf("Total time to loop 1.000.000 times: %i milliseconds"endtime starttime); 
I used this code to test the speed for looping 1 million times and checking if a player is connected and it's executed in only 43 milliseconds on my home-pc.
This is 1000 times more than the highest populated server, which is only a 1000-player server.
Looping through 1000 players and checking their online status would only take 43 microseconds. This would be for the highest populated server.
In your case, a 500 player server, this would only take 21 microseconds.
This is negligable.

Increasing the loop to 25 million iterations takes 1 second, I doubt anyone would use such big loops in their server.

Real servers do it even faster than my home-pc.

I'm not bothering to use foreach and other stuff.
It doesn't give a noticeable speed-increase.
My own server only has 50 players, so each time I loop through all players, it would only take 2 microseconds.



To your question: redefining MAX_PLAYERS would require a recompile of your script and a restart of your server for changes to take effect.
And don't forget to adjust the value in your server.cfg file as well to match your script.
It's not a good idea to monitor your server constantly and restart the server with an adjusted MAX_PLAYERS value when your server is getting full or empty.

Just set it to the maximum you're allowed and leave it at that.
Reply


Messages In This Thread
Defining MAX_PLAYERS - by Eyce - 15.04.2016, 13:48
Re: Defining MAX_PLAYERS - by yugecin - 15.04.2016, 13:55
Re: Defining MAX_PLAYERS - by Eyce - 15.04.2016, 14:05
Re: Defining MAX_PLAYERS - by Vince - 15.04.2016, 14:47
Re: Defining MAX_PLAYERS - by yugecin - 15.04.2016, 15:15
Re: Defining MAX_PLAYERS - by Eyce - 15.04.2016, 17:01
Re: Defining MAX_PLAYERS - by NaS - 15.04.2016, 17:07
Re: Defining MAX_PLAYERS - by AbyssMorgan - 15.04.2016, 18:05
Re: Defining MAX_PLAYERS - by Konstantinos - 15.04.2016, 18:11
Re: Defining MAX_PLAYERS - by AmigaBlizzard - 15.04.2016, 19:42

Forum Jump:


Users browsing this thread: 1 Guest(s)