Your opinion needed
#8

Quote:
Originally Posted by [MM]RoXoR[FS]
Посмотреть сообщение
Try this
pawn Код:
new AllPlayers[MAX_PLAYERS];//global
//Under OnGameModeInIt
{
   for(new i=0;i<MAX_PLAYERS;++i) AllPlayers[i] = -1;
}
//This was because if I did AllPlayers[MAX_PLAYERS] = -1 in definaion, it may have put value of -1 to just AllPlayers[0]..
//Happened to me once.

//When Player COnnects
public OnPlayerConnect(playerid)
{
 for(new i=0;i<MAX_PLAYERS;++i)
    if(AllPlayers[i] == -1) { AllPlayers[i] = playerid; break;}
//Or maybe AllPlayers[playerid] = 1;
}

//When he disconnects
{
  for(new i=0;i<MAX_PLAYERS;++i)
    if(AllPlayers[i] == playerid){AllPlayers[i] = -1; break;}
//Or maybe AllPlayers[playerid] = -1;
}
So, that's it.You may use any of the way.
Thank you very much for responding.
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
}
// make sure there is one "free" cell for next player, and -1 is also EOS(only to this array)
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.
Reply


Messages In This Thread
Your opinion needed - by Roko_foko - 30.07.2012, 08:18
Re: Your opinion needed - by SEnergy - 30.07.2012, 08:20
Re: Your opinion needed - by Roko_foko - 30.07.2012, 08:28
Re: Your opinion needed - by SEnergy - 30.07.2012, 08:35
Re: Your opinion needed - by Roko_foko - 30.07.2012, 08:36
Re: Your opinion needed - by SEnergy - 30.07.2012, 08:42
Re: Your opinion needed - by [MM]RoXoR[FS] - 30.07.2012, 09:50
Re: Your opinion needed - by Roko_foko - 30.07.2012, 10:05

Forum Jump:


Users browsing this thread: 2 Guest(s)