16.06.2010, 19:14
Quote:
Originally Posted by DowNlOaD_
Quote:
and at least PlayersOnline() works in loops PS: when i'm doing something like that: new VAR[PlayersOnline()]; it crashes my pawn compiler |
Lets say you HAD 50 players... 0-46 disconnect for some unkown reason. You are left with players 47,48, and 49. You're variable says there are 3 players online (which is true) but when you loop, it'll go 1..2..3 and what ever your doing for the players in that loop WILL NOT reach the connected players.
The best way for efficient looping is a redefinition of MAX_PLAYERS like the one above, but that can get to be a pain due to having to edit when ever you switch you max players value in your server.cfg
Код:
for(new i=0, p=GetMaxPlayers(); i<p; i++) { //stuff }Код:thats the way to do it, if your looking for the most efficient dynamic way. OFF TOPIC: As for your "new VAR[PlayersOnline()];" statement, i told you: You CANT use functions outside of callbacks.