[Help] OnPlayerDisonnect
#1

Hi there,

I have an issue when a player disconnect, I have no clue what so ever it is. But when a player disconnect my server cashes & and I have to go inside my control panel and start the server again.

Would be great to find what the problem is...

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new pName[MAX_PLAYER_NAME], string32[350];
    GetPlayerName(playerid, pName, sizeof(pName));
    switch(reason)
    {
        case 0: format(string32, sizeof(string32), "%s has left the server. (Lost Connection)", pName);
        case 1: format(string32, sizeof(string32), "%s has left the server. (Leaving)", pName);
        case 2: format(string32, sizeof(string32), "%s has left the server. (Kicked)", pName);
    }
    if(reason == 0)
    {
        for(new slot = 0; slot != 12; slot++)
        {
            new wep, ammo;
            GetPlayerWeaponData(playerid, slot, wep, ammo);
            PlayerInfo[playerid][pCrashed] = 1;
            if(wep != 0 && ammo != 0)
            {
                if(PlayerInfo[playerid][pGun1] == 0) { PlayerInfo[playerid][pGun1] = wep; PlayerInfo[playerid][pAmmo1] = ammo; }
                else if(PlayerInfo[playerid][pGun2] == 0) { PlayerInfo[playerid][pGun2] = wep; PlayerInfo[playerid][pAmmo2] = ammo; }
                else if(PlayerInfo[playerid][pGun3] == 0) { PlayerInfo[playerid][pGun3] = wep; PlayerInfo[playerid][pAmmo3] = ammo; }
                else if(PlayerInfo[playerid][pGun4] == 0) { PlayerInfo[playerid][pGun4] = wep; PlayerInfo[playerid][pAmmo4] = ammo; }
            }
        }
    }
    if(reason == 1 || reason == 2)
    {
        for(new slot = 0; slot != 12; slot++)
        {
            new wep, ammo;
            GetPlayerWeaponData(playerid, slot, wep, ammo);
            if(wep != 0 && ammo != 0)
            {
                if(PlayerInfo[playerid][pGun1] == 0) { PlayerInfo[playerid][pGun1] = wep; PlayerInfo[playerid][pAmmo1] = ammo; }
                else if(PlayerInfo[playerid][pGun2] == 0) { PlayerInfo[playerid][pGun2] = wep; PlayerInfo[playerid][pAmmo2] = ammo; }
                else if(PlayerInfo[playerid][pGun3] == 0) { PlayerInfo[playerid][pGun3] = wep; PlayerInfo[playerid][pAmmo3] = ammo; }
                else if(PlayerInfo[playerid][pGun4] == 0) { PlayerInfo[playerid][pGun4] = wep; PlayerInfo[playerid][pAmmo4] = ammo; }
            }
        }
    }
    PlayerInfo[playerid][pInGame] = 0;
    SendAdminMessage(0xDE1BCF96, string32);
    TextDrawDestroy(Textdraw42[playerid]);
    TextDrawDestroy(Textdraw41[playerid]);
    TextDrawHideForPlayer(playerid, Text:GostergeYazi[playerid]);
    TextDrawHideForPlayer(playerid, Text:ArkaPlan0);
    TextDrawHideForPlayer(playerid, Text:ArkaPlan1);
    TextDrawHideForPlayer(playerid, Text:ArkaPlan2);
    TextDrawHideForPlayer(playerid, Text:ArkaPlan3);
    TextDrawHideForPlayer(playerid, Text:ArkaPlan4);
    TextDrawHideForPlayer(playerid, SunGlasses);
    OnPlayerUpdateEx(playerid);
    new Float:x;
    new Float:y;
    new Float:z;
    GetPlayerPos(playerid,x,y,z);
    positionx = x;
    positiony = y;
    positionz = z;
    if (!dini_Exists(FileStats(playerid)))
    {
        dini_Create(FileStats(playerid));
    }
    SaveStats(playerid);
    PlayerInfo[playerid][pAdjustable] = 1;
    MatDeliver[playerid] = 0;
    DrugDeliver[playerid] = 0;
    MatDeliver2[playerid] = 0;
    CharacterStatus[playerid] = 0;
    ToggleSounds[playerid] = 1;
    PlayingSound[playerid] = 0;
    ToggleDispatch[playerid] = 0;
    ToggleStats[playerid] = 1;
    ShowGPS[playerid] = 1;
    new playername4[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername4, sizeof(playername4));
    new string[64];
    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, 3);
                    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, 3);
                    BusCallTime[i] = 0;
                    DisablePlayerCheckpoint(i);
                }
            }
        }
    }
    if(PlayerPaintballing[playerid] != 0)
    {
        PaintballPlayers --;
    }
    if(playerrobbing[playerid] == 1)
    {
    new sendername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "(( %s has disconnected while robbing the bank ))", sendername);
    SendFamilyMessage(1,COLOR_RED, "The Los Santos Bank has not been robbed.");
    SendFamilyMessage(PlayerInfo[playerid][pMember],COLOR_LIGHTBLUE, string);
    robbed = 0;
    playerrobbing[playerid] = 0;
    }
    if(TransportCost[playerid] > 0 && TransportDriver[playerid] < 999)
    {
        if(IsPlayerConnected(TransportDriver[playerid]))
        {
            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, 3);
        }
    }
    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(PlayersChannel[playerid] < 999)
    {
        IRCInfo[PlayersChannel[playerid]][iPlayers] -= 1;
    }
    if(HireCar[playerid] != 299)
    {
        SetVehicleToRespawn(HireCar[playerid]);
        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);
                GameTextForPlayer(Boxer2, "~r~Match interupted", 5000, 3);
            }
        }
        else if(Boxer2 == playerid)
        {
            if(IsPlayerConnected(Boxer1))
            {
                PlayerBoxing[Boxer1] = 0;
                SetPlayerPos(Boxer1, 765.8433,3.2924,1000.7186);
                SetPlayerInterior(Boxer1, 5);
                GameTextForPlayer(Boxer1, "~r~Match interupted", 5000, 3);
            }
        }
        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; }
    }
    gPlayerLogged[playerid] = 0;
    Busline1[playerid][0] = 0;
    Busline2[playerid][0] = 0;
    Busline3[playerid][0] = 0;
    return 1;
}
Reply


Messages In This Thread
[Help] OnPlayerDisonnect - by tony_fitto - 14.06.2013, 13:34
Re: [Help] OnPlayerDisonnect - by Anak - 14.06.2013, 13:40
Re: [Help] OnPlayerDisonnect - by tony_fitto - 14.06.2013, 13:41
Re: [Help] OnPlayerDisonnect - by Sulps - 14.06.2013, 13:42
Re: [Help] OnPlayerDisonnect - by Anak - 14.06.2013, 13:47
Re: [Help] OnPlayerDisonnect - by tony_fitto - 14.06.2013, 13:49
Re: [Help] OnPlayerDisonnect - by Anak - 14.06.2013, 13:54
Re: [Help] OnPlayerDisonnect - by tony_fitto - 14.06.2013, 14:05

Forum Jump:


Users browsing this thread: 2 Guest(s)