GetMaxPlayers() as a constant
#1

I've been interested in using the GetMaxPlayers() command as a constant, much like:

#define max_players GetMaxPlayers()
or
const max_players=GetMaxPlayers();

You know, so that I could build arrays based upon the server's limitations, like:
new doohickeys[max_players][3]
or something similar...

To me it seems logical that either should work but the first one just gives an error and the second causes a crash...

What is it that (in my advanced old age) has slipped through the cracks of my rapidly deteriorating grey matter? Some rule about constants I've overlooked?

Curious...
Reply
#2

GetMaxPlayers() is returning a value and isn't an actuall value itself so the compiler sees it as a function call (not a constant) and not a value hence the hissy fit (crash).

You could always use #undef on the MAX_PLAYERS define then redefine it but I understand it's not what you want.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)