MAX_PLAYERS v. GetMaxPlayers() - 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 v. GetMaxPlayers() (
/showthread.php?tid=540451)
MAX_PLAYERS v. GetMaxPlayers() -
Neil. - 04.10.2014
Apparently, something hit my head while scripting. I bumped into this thinking which is more efficient, GetMaxPlayers() or MAX_PLAYERS? By default MAX_PLAYERS is 500 (but can be changed) but wouldn't it create 500 instances of the variable? Is GetMaxPlayers() applicable as having 50 slots would only create 50 instances of it.
Код:
new playerInfo[MAX_PLAYERS][playerData];
Re: MAX_PLAYERS v. GetMaxPlayers() -
Dignity - 04.10.2014
Yes, I believe so.
I'm not 100% sure if it would return accurate values though, you should wait for someone to reply who has experimented with it.
Re: MAX_PLAYERS v. GetMaxPlayers() -
Neil. - 04.10.2014
Quote:
Originally Posted by Mionee
Yes, I believe so.
I'm not 100% sure if it would return accurate values though, you should wait for someone to reply who has experimented with it.
|
That lighted it up a fair bit.
Quote:
Originally Posted by [HLF]Southclaw
You can't use a function call as an array size since array sizes must be known at compile time. The compiler knows that MAX_PLAYERS means 500 because it's just a define directive (effectively just search & replace before compile time). GetMaxPlayers is unknown because it's a function call that returns whatever the server read from server.cfg.
|
Great explanation! I did thought that the function is variable (changing) but nevertheless, I did redefine the default MAX_PLAYERS which did the trick (to avoid inefficiency).