INVALID_PLAYER_ID
#1

Hey there. I have a question. If i'm using a loop ( for ) and i use IsPlayerConnected(i) i need to use
pawn Code:
i != INVALID_PLAYER_ID
?

e.g.:

pawn Code:
for(new i = 0; i < GetMaxPlayers(); i++)
                {
                    if (PlayerInfo[i][Key] == PlayerInfo[playerid][Key])
                    {
                        if(IsPlayerConnected(i))
                        {
                          if(i != INVALID_PLAYER_ID)
                          {
Reply
#2

All fine except this one:
pawn Code:
for(new i = 0; i < GetMaxPlayers(); i++)
change to:
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)
Reply
#3

oh really ? Who learned you this ? Both are corectly , but GetMaxPlayers(); takes the value of my players sets from server.cfg ( if in server.cfg at maxplayers i have 100 , at GetMaxPlayers(); it allow space just for 100 players).

But I repeat my question , if i use IsPlayerConnected(i) , i must use i != INVALID_PLAYER_ID ?
Reply
#4

GetMaxPlayers() is more inefficient than MAX_PLAYERS despite the fact it should theoretically, loop less, and it can't be saved to a variable.
Reply
#5

So Basically MAX_PLAYERS works better that GetMaxPlayers();
Reply
#6

My point exactly. It's more efficient.
Reply
#7

Quote:
Originally Posted by russiany
But I repeat my question , if i use IsPlayerConnected(i) , i must use i != INVALID_PLAYER_ID ?
Reply
#8

Not necessarily.
Reply
#9

Quote:
Originally Posted by russiany
Quote:
Originally Posted by russiany
But I repeat my question , if i use IsPlayerConnected(i) , i must use i != INVALID_PLAYER_ID ?
You can do
pawn Code:
if(!IsPlayerConnected(i)) return 0;
Quote:
Originally Posted by Castle
All fine except this one:
pawn Code:
for(new i = 0; i < GetMaxPlayers(); i++)
change to:
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)
Why would he do it?
You can do GetMaxPlayer or either do MAX_PLAYERS and check if the player is connected.
Reply
#10

Quote:
Originally Posted by [XG
Lj ]
Not necessarily.
Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)