04.03.2016, 20:11
(
Последний раз редактировалось illuminati2; 05.03.2016 в 07:22.
)
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
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
Also, you can loop by this way (If to can't just use the above).
2- Changing MAX_PLAYERS Value
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.
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.
1- Looping With Server's Max Players
PHP код:
for(new i = 0; i < GetMaxPlayers(); 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...
}
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; i <= GetPlayerPoolSize(); i++)
{
//something here...
}
PHP код:
for(new i = 0; j = GetPlayerPoolSize(); i <= j; i++)
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.
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 i = 0; i < GetMaxPlayers(); 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(i, 4000); // 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.