28.09.2009, 20:59
Quote:
|
Originally Posted by Amit B
Maybe this will help:
pawn Код:
Example: pawn Код:
|
It would have to be:
pawn Код:
stock GetHighestID()
{
new highestID = -1;
for(new i = 0; i < MAX_PLAYERS && IsPlayerConnected(i); i++) highestID = i;
return highestID;
}
pawn Код:
stock GetHighestID()
{
new highestID = -1;
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) highestID = i;
return highestID;
}
EDIT: However, IMO, looping normally using MAX_PLAYERS then checking IsPlayerConnected would be faster than looping with GetHighestID(). Also, you would still need to check IsPlayerConnected with GetHighestID, because player ID's aren't always in order. Eg. if there are 6 players on the server (ID's 0-5), and player 5 (ID 4) leaves, then you have ID's 0,1,2,3,5; 5 is the highest ID, but not all players up to that ID are connected.

