MAX_PLAYERS v. GetMaxPlayers()
#1

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];
Reply
#2

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.
Reply
#3

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).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)