OnPlayerDeath bugged
#1

I got this
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    Goto[playerid] = 0;
    InShamal[playerid] = 0;
    OnDuty[playerid] = 0;
    StealBank[playerid] = 999;
    new Random=random(100); // 100%
    if(Goto[playerid] == 0)
    {
        if(Random<=50)
        {
            Account[playerid][pGun0] = 0;
            Account[playerid][pGun1] = 0;
            Account[playerid][pGun2] = 0;
            Account[playerid][pAmmo0] = 0;
            Account[playerid][pAmmo1] = 0;
            Account[playerid][pAmmo2] = 0;
        }
        else { }
    }
    if(IsACop(playerid))
    {
        Account[playerid][pGun0] = 0;
        Account[playerid][pGun1] = 0;
        Account[playerid][pGun2] = 0;
        Account[playerid][pAmmo0] = 0;
        Account[playerid][pAmmo1] = 0;
        Account[playerid][pAmmo2] = 0;
    }
    if(reason == 0 || reason == 1)
    {
        Hospital[playerid]=1;
        NeedMedicTime[playerid] = 14;
    }
    if(reason == 3 || reason == 2 || reason == 53)
    {
        Hospital[playerid]=1;
        NeedMedicTime[playerid] = 18;
    }
    if(reason == 49 || reason == 4 || reason == 5 || reason == 8 || reason == 9 || reason == 41 || reason == 42 || reason == 43 || reason == 44 || reason == 45 || reason == 46)
    {
        Hospital[playerid]=1;
        NeedMedicTime[playerid] = 20;
    }
    if(reason == 10 || reason == 11 || reason == 12 || reason == 13 || reason == 14 || reason == 15)
    {
        Hospital[playerid]=1;
        NeedMedicTime[playerid] = 15;
    }
    if(reason == 23 || reason == 24 || reason == 30 || reason == 32 || reason == 25 || reason == 26 || reason == 28 || reason == 27 || reason == 29 || reason == 31)
    {
        Hospital[playerid]=1;
        NeedMedicTime[playerid] = 30;
    }
    if(reason == 33 || reason == 34 || reason == 35 || reason == 36 || reason == 37 || reason == 38)
    {
        Hospital[playerid]=1;
        NeedMedicTime[playerid] = 36;
    }
    if(reason == 39 || reason == 40 || reason == 16 || reason == 17 || reason == 18)
    {
        Hospital[playerid]=1;
        NeedMedicTime[playerid] = 40;
    }
    if(reason == 19 || reason == 20 || reason == 21 || reason == 22)
    {
        Hospital[playerid]=1;
        NeedMedicTime[playerid] = 44;
    }
    if(reason == 50 || reason == 51 || reason == 54)
    {
        Hospital[playerid]=1;
        NeedMedicTime[playerid] = 46;
    }
    if(DMVTest[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_LIGHTRED,"You died during a driving test. Therefore, it has been cancelled.");
        DisablePlayerCheckpoint(playerid);
        DMVCP[playerid] = -1;
        DMVTest[playerid] = 0;
        KillTimer(DMVT);
    }
    if(DrivingTestingStart[playerid] == 1)
    {
        DrivingTestingStart[playerid] = 0;
    }
    if(DrivingTestingStartScooter[playerid] == 1)
    {
        DrivingTestingStartScooter[playerid] = 0;
    }
    if(DrivingTestingStart[playerid] == 1)
    {
        DrivingTestingStartBigBike[playerid] = 0;
    }
    new caller = Mobile[playerid];
    if(caller != 255)
    {
        if(caller < 255)
        {
            SendClientMessage(caller,  COLOR_YELLOW2, "The line just went dead....");
            CellTime[caller] = 0;
            CellTime[playerid] = 0;
            Mobile[caller] = 255;
        }
        Mobile[playerid] = 255;
        CellTime[playerid] = 0;
    }
    if (BusrouteEast[playerid][0] != 0 || BusrouteWest[playerid][0] != 0)
    {
        if (BusrouteEast[playerid][0] != 0) BusrouteEnd(playerid, BusrouteEast[playerid][1]);
        else if (BusrouteWest[playerid][0] != 0) BusrouteEnd(playerid, BusrouteWest[playerid][1]);
        else BusrouteEnd(playerid, 0);
    }
    OnPlayerUpdate(playerid);
    if(aduty[playerid]==1)
    {
        SetPlayerColor(playerid,TEAM_ADMIN_COLOR);
        SetPlayerMarkerForPlayer( 42, 1, 0xFFFFFF00 );
    }
    else
    {
        SetPlayerColor(playerid,COLOR_GRAD2);
    }
    return true;
}
pawn Код:
if(Hospital[playerid] == 1 && Account[playerid][pJailed] == 0)
        {
            if(FirstSpawn[playerid] != 1)
            {
                /*SetPlayerHealth(playerid, 25.0);
                SetPlayerInterior(playerid, 0);
                Account[playerid][pInt] = 0;
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "Doctor: Hope your feeling better, please be aware next time.");
                TogglePlayerControllable(playerid, true);
                SetPlayerPos(playerid, 1178.1443,-1323.3268,14.1056);
                SetPlayerFacingAngle(playerid, 270.9733);
                SetCameraBehindPlayer(playerid);
                return true;*/

                new rand;
                SetPlayerPos(playerid, 1160.8542,-1330.8306,1499.4673);
                SetPlayerFacingAngle(playerid, 357.6145);
                SetPlayerInterior(playerid, 0);
                Account[playerid][pInt] = 0;
                rand = 1+random(200);
                SetPlayerVirtualWorld(playerid,rand);
                Account[playerid][pVirtualWorld] = rand;
                SetPlayerCameraPos(playerid, 1152.0311,-1325.3153,1498.6328);
                SetPlayerCameraLookAt(playerid,1160.3467,-1332.2661,1498.6328);
                TogglePlayerControllable(playerid, false);
                ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
                MedicTime[playerid] = 1;
                //
                TextDrawHideForPlayer(playerid,Textdrawz[playerid]);
                TextDrawSetString(Textdrawz[playerid],"~w~You are resting due ~r~brutally wounds~w~, you will be out when the doctor says so.~n~ The time in, depends on your 'Death Way'");
                //
                TextDrawShowForPlayer(playerid,Textdrawz[playerid]);
                PlayerPlaySound(playerid, 1062, 0.0, 0.0, 0.0);
                return true;
            }
        }
Sometimes it works just perfectly, but sometimes I spawn at blueberry, and some random textdraws appear (Were hidden already). any help ?
Reply
#2

anyone ?
Reply
#3

i would suggest using returns or case's on you if statments so the right check only gets called.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)