[Tutorial] Set Max Players to Server's Max Players
#1

This tutorial will show you how to loop with your server's max players not the default MAX_PLAYERS. also it will show you how to set MAX_PLAYERS Value to another way.

1- Looping With Server's Max Players
PHP код:
    for(new 0GetMaxPlayers(); i++) // GetMaxPlayers(); gets your server's max players, use it instead of MAX_PLAYERS as MAX_PLAYERS is 500 maybe your server is more than 500 or less than it.
    
{
        
//something here...
    

Now, you can loop using your server's max players not the default MAX_PLAYERS value. You can also change the MAX_PLAYERS Value instead.

You can also, loop using the current online players so it's not 100, 500 or even 1000 it will be the amount of your In Game players. Like in the code below

PHP код:
    for(new i=0<= GetPlayerPoolSize(); i++)
    {
        
//something here...
    

Also, you can loop by this way (If to can't just use the above).
PHP код:
for(new 0;  GetPlayerPoolSize(); <= ji++) 
2- Changing MAX_PLAYERS Value
PHP код:
#if defined MAX_PLAYERS //checks if MAX_PLAYERS if defined
    #undef MAX_PLAYERS // undefines max players so we can re define it with the new value we want.
    #define MAX_PLAYERS 100 // This is just an example of max players, change this 100 to whatever you like.
#endif // Now we finished it. 
Now, you can Loop with MAX_PLAYERS, but to be honest GetMaxPlayers(); is better as it will be set on server's Max Players not the default MAX_PLAYERS also, it will make it easier for you than changing the MAX_PLAYERS value everytime.


Some mistakes many beginners do, like using playerid in a loop. You should use the word you used in the loop for example "i" in the code below.
PHP код:
    for(new 0GetMaxPlayers(); i++) // GetMaxPlayers(); gets your server's max players, use it instead of MAX_PLAYERS as MAX_PLAYERS is 500 maybe your server is more than 500 or less than it.
    
{
        
GivePlayerMoney(i4000); // Do NOT Use playerid, in loops you've to use i, or any word you used. (Not Random)
    



This tutorial is 100% Clean after the re wrote of it. Special thanks to Sascha for pointing out some mistakes. Now the tutorial has been re wrote in a shorter way and easier. Without doing anything that may lead to a server crash. NOTE: the tutorial name maybe different to this current tutorial as it has been re wrote with some idea changes. Don't worry the replies below has been fixed.
Reply


Messages In This Thread
Changing MAX_PLAYERS value & Another way to loop. - by illuminati2 - 04.03.2016, 20:11
Re: Set Max Players to Server's Max Players - by Sascha - 04.03.2016, 20:25
Re: Set Max Players to Server's Max Players - by illuminati2 - 04.03.2016, 20:36
Re: Set Max Players to Server's Max Players - by Sascha - 04.03.2016, 20:52
Re: Set Max Players to Server's Max Players - by Crayder - 04.03.2016, 20:57
Re: Set Max Players to Server's Max Players - by illuminati2 - 04.03.2016, 20:58
Re: Set Max Players to Server's Max Players - by AndySedeyn - 05.03.2016, 06:58

Forum Jump:


Users browsing this thread: 1 Guest(s)