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)
+--- Thread: MAX_PLAYERS (
/showthread.php?tid=369160)
MAX_PLAYERS -
Kirollos - 16.08.2012
what's the difference if we do the following:
pawn Код:
#define MAX_PLAYERS GetMaxPlayers()
instead of:
pawn Код:
#define MAX_PLAYERS (YOUR AMOUNT HERE)
i was thinking about it but i have no idea about that.
Re: MAX_PLAYERS -
FireCat - 16.08.2012
You can put "#define MAX_PLAYERS" as 500000
While GetMaxPlayers() is the amount of slots the server has.
Re : MAX_PLAYERS -
pseudonyme - 16.08.2012
First, you should understand that
create a
macro, meaning "useless" will be replaced by "exemple" everywhere in your script when you'll compile it (in fact, it happens a bit before the compile itself).
Second, GetMaxPlayers() will read the number of slots from the server config (server.cfg) thought 500 is a constant number.
So, you can't use GetMaxPlayer() to define an array size because it should be a constant number.
So, best you have to do is using
but using foreach() for your loops.
PS: Sorry for my bad english :-'
Re: MAX_PLAYERS -
MP2 - 16.08.2012
Array sizes have to be specified at compile time, which GetMaxPlayers can't do because it is variable (it can vary).
Re: MAX_PLAYERS -
MadeMan - 19.08.2012
#define replaces something with something else.
So the only difference is:
pawn Код:
#define MAX_PLAYERS GetMaxPlayers()
new Score[MAX_PLAYERS];
would compile as
pawn Код:
new Score[GetMaxPlayers()];
and
pawn Код:
#define MAX_PLAYERS 500
new Score[MAX_PLAYERS];
would compile as
Try "Show preprocessed output" in
PAWN Playground