Quote:
Originally Posted by pan0s
For the listen server, client index over 18 will have the exception "Client index 19 is invalid", so I define it to 18.
Of course, for the server who have 20+ players, they can change it back to 20+ because the dedicated server has no this problem.
|
That's not how you fix that error. The variable MaxClients is dynamic and can change depending on how many players a server can handle. MAXPLAYERS + 1 handles up to 64 players + world/server index which is what you use for global variables.
To fix the "Client X is invalid" error you usually include this check:
PHP Code:
if (0 < client <= MaxClients)
It will make sure that only clients between index 1 to MaxClients will be affected.
You also need to loop through clients consistently. Even on listen servers, this is still the ideal loop:
PHP Code:
for (int i = 1; i <= MaxClients; i++)
In your current code, I see loops like this:
PHP Code:
for (int i = 0; i < MaxClients + 1; i++)
There are only certain cases where you would need to directly affect index 0 for listen servers, but most of the time, index 1 still works.
__________________