[HELP] Server crash when someone disconnects
#1

Like the title says, whoever will go to server, and then /q, the server crashes after him.

Here is my OnPlayerDisconnect:
pawn Код:
public OnPlayerDisconnect(playerid)
{  print("1");
  new i2;
    for(i2=0;i2<MAX_VEHICLES;i2++)
    {
        if (locked[playerid][i2] == 1)
        {
            new i;
            for(i=0;i<MAX_PLAYERS;i++)
            {
                SetVehicleParamsForPlayer(i2,i, 0, 0);
            }
        }
        locked[playerid][i2] = 0;
    }
  print("2");
    playerbackup(playerid);
  new weap0, ammo0, weap1, ammo1, weap2, ammo2, weap3, ammo3, weap4, ammo4, weap5, ammo5, weap6, ammo6, weap7, ammo7;
  GetPlayerWeaponData(playerid,0,weap0,ammo0);
  GetPlayerWeaponData(playerid,1,weap1,ammo1);
  GetPlayerWeaponData(playerid,2,weap2,ammo2);
  GetPlayerWeaponData(playerid,3,weap3,ammo3);
  GetPlayerWeaponData(playerid,4,weap4,ammo4);
  GetPlayerWeaponData(playerid,5,weap5,ammo5);
  GetPlayerWeaponData(playerid,6,weap6,ammo6);
  GetPlayerWeaponData(playerid,7,weap7,ammo7);
  GetPlayerWeaponData(playerid,0,PlayerInfo[playerid][pGun0],PlayerInfo[playerid][pAmmo0]);
  GetPlayerWeaponData(playerid,1,PlayerInfo[playerid][pGun1],PlayerInfo[playerid][pAmmo1]);
  GetPlayerWeaponData(playerid,2,PlayerInfo[playerid][pGun2],PlayerInfo[playerid][pAmmo2]);
  GetPlayerWeaponData(playerid,3,PlayerInfo[playerid][pGun3],PlayerInfo[playerid][pAmmo3]);
  GetPlayerWeaponData(playerid,4,PlayerInfo[playerid][pGun4],PlayerInfo[playerid][pAmmo4]);
  GetPlayerWeaponData(playerid,5,PlayerInfo[playerid][pGun5],PlayerInfo[playerid][pAmmo5]);
  GetPlayerWeaponData(playerid,6,PlayerInfo[playerid][pGun6],PlayerInfo[playerid][pAmmo6]);
  GetPlayerWeaponData(playerid,7,PlayerInfo[playerid][pGun7],PlayerInfo[playerid][pAmmo7]);
  GetPlayerWeaponData(playerid,8,PlayerInfo[playerid][pGun8],PlayerInfo[playerid][pAmmo8]);
  drivingtest[playerid] = 0;
  drivingtestcheck[playerid] = 0;
  drivingtesttime[playerid] = 0;
  smokepottime[playerid] = 0;
  smokecracktime[playerid] = 0;
    PlayerInfo[playerid][pRentCar] = 0;
    rentask[playerid] = 0;
    hospitalbill[playerid] = 0;
    gActivePlayers[playerid]--;
    numplayers--;
    PlayerInfo[playerid][pAdjustable] = 1;
    TextDrawHideForPlayer ( playerid , RocketWarning );
  DOO_OnPlayerDisconnect(playerid);
  ResetMapIconVariables(playerid);
    OnPlayerUpdate(playerid);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if(IsPlayerConnected(i))
      {
        if(TaxiAccepted[i] < 999)
        {
            if(TaxiAccepted[i] == playerid)
            {
              TaxiAccepted[i] = 999;
              GameTextForPlayer(i, "~w~Taxi Caller~n~~r~Left the game", 5000, 1);
              TaxiCallTime[i] = 0;
              DisablePlayerCheckpoint(i);
            }
        }
        else if(BusAccepted[i] < 999)
        {
            if(BusAccepted[i] == playerid)
            {
              BusAccepted[i] = 999;
              GameTextForPlayer(i, "~w~Bus Caller~n~~r~Left the game", 5000, 1);
              BusCallTime[i] = 0;
              DisablePlayerCheckpoint(i);
            }
        }
      }
    }
    if(TransportCost[playerid] > 0 && TransportDriver[playerid] < 999)
    {
      if(IsPlayerConnected(TransportDriver[playerid]))
        {
          new string[64];
          TransportMoney[TransportDriver[playerid]] += TransportCost[playerid];
          TransportTime[TransportDriver[playerid]] = 0;
          TransportCost[TransportDriver[playerid]] = 0;
          format(string, sizeof(string), "~w~Passenger left~n~~g~Earned $%d",TransportCost[playerid]);
          GameTextForPlayer(TransportDriver[playerid], string, 5000, 1);
        }
    }
    if(GotHit[playerid] > 0)
    {
      if(GetChased[playerid] < 999)
      {
        if(IsPlayerConnected(GetChased[playerid]))
        {
            SendClientMessage(GetChased[playerid], COLOR_YELLOW, "Your Hit has left the server.");
          GoChase[GetChased[playerid]] = 999;
            }
      }
    }
    if(PlayerPaintballing[playerid] != 0)
    {
      PaintballPlayers --;
    }
    if(PlayerKarting[playerid] > 0 && PlayerInKart[playerid] > 0)
    {
      KartingPlayers --;
    }
    if(HireCar[playerid] != 299)
    {
        gLastDriver[HireCar[playerid]] = 300;
        gCarLock[HireCar[playerid]] = 0;
        UnLockCar(HireCar[playerid]);
    }
    if (gLastCar[playerid] > 0)
    {
        gLastDriver[gLastCar[playerid]] = 300;
        if(PlayerInfo[playerid][pPhousekey] != gLastCar[playerid]-1)
        {
            gCarLock[gLastCar[playerid]] = 0;
            UnLockCar(gLastCar[playerid]);
        }
    }
    if(PlayerBoxing[playerid] > 0)
    {
      if(Boxer1 == playerid)
      {
        if(IsPlayerConnected(Boxer2))
        {
            PlayerBoxing[Boxer2] = 0;
            SetPlayerPos(Boxer2, 765.8433,3.2924,1000.7186);
            SetPlayerInterior(Boxer2, 5);
            PlayerInfo[Boxer2][pInt] = 5;
            GameTextForPlayer(Boxer2, "~r~Match interupted", 5000, 1);
            }
      }
      else if(Boxer2 == playerid)
      {
        if(IsPlayerConnected(Boxer1))
        {
            PlayerBoxing[Boxer1] = 0;
            SetPlayerPos(Boxer1, 765.8433,3.2924,1000.7186);
            SetPlayerInterior(Boxer1, 5);
            PlayerInfo[Boxer2][pInt] = 5;
            GameTextForPlayer(Boxer1, "~r~Match interupted", 5000, 1);
            }
      }
      InRing = 0;
    RoundStarted = 0;
        Boxer1 = 255;
        Boxer2 = 255;
        TBoxer = 255;
    }
  if(TransportDuty[playerid] == 1)
    {
        TaxiDrivers -= 1;
    }
  else if(TransportDuty[playerid] == 2)
    {
        BusDrivers -= 1;
    }
    if(PlayerInfo[playerid][pJob] == 11)
    {
      if(JobDuty[playerid] == 1) { Medics -= 1; }
    }
    else if(PlayerInfo[playerid][pJob] == 7)
    {
      if(JobDuty[playerid] == 1) { Mechanics -= 1; }
    }
    if (PlayerInfo[playerid][pRoadblock] != 0)
    {
        RemoveRoadblock(playerid);
    }
}
Reply
#2

That code isn't small.. add debug messages to see where crash appears.
Reply
#3

Quote:
Originally Posted by Don Correlli
That code isn't small.. add debug messages to see where crash appears.
Like to all lines for example:

Quote:

ResetPlayerWeapons(playerid); print("1");

Or?
Reply
#4

Any example how to debug?
Reply
#5

Example:
pawn Код:
Function3465();
printf("DEBUG: bla bla bla");
Add it after every function to see where it stops.
Reply
#6

Quote:
Originally Posted by Don Correlli
Example:
pawn Код:
Function3465();
printf("DEBUG: bla bla bla");
Add it after every function to see where it stops.
Okay i did Debug, and it didnt make in server_log nothing about debug(on host). But when i did it with MY PC it worked well, and even the server didnt crash on MY pc... WHats the problem?
Reply
#7

Quote:
Originally Posted by KeyWay
Okay i did Debug, and it didnt make in server_log nothing about debug(on host). But when i did it with MY PC it worked well, and even the server didnt crash on MY pc... WHats the problem?
Your hoster? Does it run on Debian?
I had the same problem, when writing/reading from files which worked fine on Windows but on Debian/Linux the server crashed.
Reply
#8

Quote:
Originally Posted by //exora
Quote:
Originally Posted by KeyWay
Okay i did Debug, and it didnt make in server_log nothing about debug(on host). But when i did it with MY PC it worked well, and even the server didnt crash on MY pc... WHats the problem?
Your hoster? Does it run on Debian?
I had the same problem, when writing/reading from files which worked fine on Windows but on Debian/Linux the server crashed.
Yea it runs on Linux :/
Reply
#9

I hope i dont need to change host, do i?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)