MAX_SLOTS or MAX_PLAYERS - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MAX_SLOTS or MAX_PLAYERS (
/showthread.php?tid=195301)
MAX_SLOTS or MAX_PLAYERS -
Celson - 02.12.2010
I've always assumed that MAX_PLAYERS was defined by the 'maxplayers' value in the server config. Was I right?
If I was wrong. Does that mean when ever I've used the MAX_PLAYERS in a for loop, is it looping 500 times?
Re: MAX_SLOTS or MAX_PLAYERS -
MrDeath537 - 02.12.2010
MAX_PLAYERS will always 500.
Re: MAX_SLOTS or MAX_PLAYERS -
Celson - 02.12.2010
Shiiit...
Re: MAX_SLOTS or MAX_PLAYERS -
Steven82 - 02.12.2010
Unless you use these,
pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 50// 50 = Server slots
Re: MAX_SLOTS or MAX_PLAYERS -
MrDeath537 - 02.12.2010
Quote:
Originally Posted by Steven82
Unless you use these,
pawn Код:
#undef MAX_PLAYERS #define MAX_PLAYERS 50// 50 = Server slots
|
Yes, I usually use it:
pawn Код:
#define MAX_SPLAYERS (ammount)
#define MAX_SVEHICLES (ammount)
Re: MAX_SLOTS or MAX_PLAYERS -
Celson - 02.12.2010
Cheers mates! Good to get this out of the way.
Re: MAX_SLOTS or MAX_PLAYERS -
Steven82 - 02.12.2010
Quote:
Originally Posted by MrDeath
Yes, I usually use it:
pawn Код:
#define MAX_SPLAYERS (ammount) #define MAX_SVEHICLES (ammount)
|
I use that sometimes also
but not your exact defines :O
Re: MAX_SLOTS or MAX_PLAYERS -
iggy1 - 02.12.2010
To get max players from server.cfg i beleive its this, (slower than MAX_PLAYERS though)
pawn Код:
for(new i; i < GetMaxPlayers(); i++)
Re: MAX_SLOTS or MAX_PLAYERS -
TheXIII - 02.12.2010
Quote:
Originally Posted by iggy1
To get max players from server.cfg i beleive its this, (slower than MAX_PLAYERS though)
pawn Код:
for(new i; i < GetMaxPlayers(); i++)
|
You could also do this for loops:
pawn Код:
//Global variable
new TOTAL_PLAYERS;
//OnGameModeInit:
TOTAL_PLAYERS = GetMaxPlayers();
//Loop:
for(new i; i < TOTAL_PLAYERS; i++)
Should be faster than calling GetMaxPlayers() every time.
However, I would recommend simply using foreach include.
Re: MAX_SLOTS or MAX_PLAYERS -
LarzI - 02.12.2010
Quote:
Originally Posted by ******
This issue is covered in the code optimisations topic, the simple outcome is "use foreach".
|
Was just about to say the same.