30.07.2012, 10:05
Quote:
Try this
pawn Код:
|
If you look at the part of when "he disconnects", you can see a problem there.
Lets say there AllPlayers[] look like this {1,2,3,4,5,-1,...} if 2 disconnects array will look like this {1,-1,3,4,5,-1,..} but it should look like this {1,3,4,5,-1,-1,...}
And about:" //This was because if I did AllPlayers[MAX_PLAYERS] = -1 in definaion, it may have put value of -1 to just AllPlayers[0].."
this is why I have put
pawn Код:
public OnPlayerConnect(playerid)
{
if(IsPlayerNPC(playerid)==0)
{
for(i=0;AllPlayers[i]!=-1;i++){}//finding first cell that does not have any player id.
AllPlayers[i]=playerid;// save the playerid
AllPlayers[i+1]=-1;// make sure there is one "free" cell for next player, and -1 is also EOS(only to this array)
}
//rest of the code
}
Actually this code works fine. I am asking if there is a way how can player be disconnected from server and that he avoids OnPlayerDisconnect callback.