Death Reasons
#1

Hello,

I am trying to make a Hospital System, but I discovered it stops working after its going to define the dead.
Example: Fists (beaten to dead), HeliBladed, Weapons, Knifes, etc.

Here is my code....

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    FadeColorForPlayer(playerid,255,0,0,0,255,0,0,255,25,1000);
    JustDied[playerid]=1;
    Player[playerid][Hospitalized] = 300;
    print("Checkpoint 1");
    Player[playerid][DeathReason] = reason;
    SetTimerEx("RespawnHospital", 1000, false, "d", playerid);
    print("Checkpoint 2");
    /*if(reason == 0)
    {
        printf("Checkpoint 3");
        JustDiedCase[playerid] = 1;
    }
    else if(reason == 51)
    {
        print("Checkpoint 4");
        JustDiedCase[playerid] = 2;
    }
    else if(reason == 53)
    {
        print("Checkpoint 5");
        JustDiedCase[playerid] = 3;
    }
    else if(reason == 54)
    {
        print("Checkpoint 6");
        JustDiedCase[playerid] = 4;
    }
    else if(reason == 50 || 49)
    {
        print("Checkpoint 7");
        JustDiedCase[playerid] = 5;
    }
    else if(reason == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13 || 14 || 15)
    {
        print("Checkpoint 8");
        JustDiedCase[playerid] = 6;
    }
    else if(reason == 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26 || 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38 || 39 || 40)
    {
        print("Checkpoint 9");
        JustDiedCase[playerid] = 7;
    }*/

   
    return 1;
}

public RespawnHospital(playerid)
{
    print("Checkpoint 3");
    if(JustDied[playerid] > 0)
    {
        FadeColorForPlayer(playerid,255,0,0,255,255,0,0,0,25,0);
        JustDied[playerid]=0;

        switch(Player[playerid][DeathReason])
        {
            case 0:
            {
                SendClientMessage(playerid, COLOR_ORANGE, ". : : All Saints General Hospital : : .");
                SendClientMessage(playerid, SERVERCOLOR, "You have been beaten unconsious!");
                SendClientMessage(playerid, SERVERCOLOR, "You are now in the All Saints General Hospital to rest!");
                //Player[playerid][Hospitalized] = 300;
                SetPlayerPos(playerid, -198.6134,-1790.6299,675.7859);
                SetPlayerFacingAngle(playerid, 351.7826);
                SetPlayerSkin(playerid, 62);
                SetPlayerInterior(playerid, 3);
                SetPlayerVirtualWorld(playerid, 3);
            }
            case 51:
            {
                SendClientMessage(playerid, COLOR_ORANGE, ". : : All Saints General Hospital : : .");
                SendClientMessage(playerid, SERVERCOLOR, "You have been in flames!");
                SendClientMessage(playerid, SERVERCOLOR, "Docters are curing your burn wounds!");
                SendClientMessage(playerid, SERVERCOLOR, "You are now in the All Saints General Hospital to rest!");
                //Player[playerid][Hospitalized] = 300;
                SetPlayerPos(playerid, -201.6592,-1788.9675,675.7859);
                SetPlayerFacingAngle(playerid, 88.7250);
                SetPlayerSkin(playerid, 62);
                SetPlayerInterior(playerid, 3);
                SetPlayerVirtualWorld(playerid, 3);
            }
            case 53:
            {
                SendClientMessage(playerid, COLOR_ORANGE, ". : : All Saints General Hospital : : .");
                SendClientMessage(playerid, SERVERCOLOR, "You have been drowned!");
                SendClientMessage(playerid, SERVERCOLOR, "Docters are pumping the water out of your lungs!");
                SendClientMessage(playerid, SERVERCOLOR, "You are now in the All Saints General Hospital to rest!");
                //Player[playerid][Hospitalized] = 300;
                SetPlayerPos(playerid, -201.6592,-1788.9675,675.7859);
                SetPlayerFacingAngle(playerid, 88.7250);
                SetPlayerSkin(playerid, 62);
                SetPlayerInterior(playerid, 3);
                SetPlayerVirtualWorld(playerid, 3);
            }
            case 54:
            {
                SendClientMessage(playerid, COLOR_ORANGE, ". : : All Saints General Hospital : : .");
                SendClientMessage(playerid, SERVERCOLOR, "You have felt from a very high hight!");
                SendClientMessage(playerid, SERVERCOLOR, "Docters are repairing your backbone!");
                SendClientMessage(playerid, SERVERCOLOR, "You are now in the All Saints General Hospital to rest!");
                //Player[playerid][Hospitalized] = 300;
                SetPlayerPos(playerid, -201.6592,-1788.9675,675.7859);
                SetPlayerFacingAngle(playerid, 88.7250);
                SetPlayerSkin(playerid, 62);
                SetPlayerInterior(playerid, 3);
                SetPlayerVirtualWorld(playerid, 3);
            }
            case 50,49:
            {
                SendClientMessage(playerid, COLOR_ORANGE, ". : : All Saints General Hospital : : .");
                SendClientMessage(playerid, SERVERCOLOR, "You have been hit by a vehicle!");
                SendClientMessage(playerid, SERVERCOLOR, "Docters are repairing your backbone!");
                SendClientMessage(playerid, SERVERCOLOR, "You are now in the All Saints General Hospital to rest!");
                //Player[playerid][Hospitalized] = 300;
                SetPlayerPos(playerid, -201.6592,-1788.9675,675.7859);
                SetPlayerFacingAngle(playerid, 88.7250);
                SetPlayerSkin(playerid, 62);
                SetPlayerInterior(playerid, 3);
                SetPlayerVirtualWorld(playerid, 3);
            }
            case 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15:
            {
                SendClientMessage(playerid, COLOR_ORANGE, ". : : All Saints General Hospital : : .");
                SendClientMessage(playerid, SERVERCOLOR, "You have been stabbed!");
                SendClientMessage(playerid, SERVERCOLOR, "Docters are cleaning your wounds!");
                SendClientMessage(playerid, SERVERCOLOR, "You are now in the All Saints General Hospital to rest!");
                //Player[playerid][Hospitalized] = 300;
                SetPlayerPos(playerid, -211.9630,-1761.9679,675.7687);
                SetPlayerFacingAngle(playerid, 309.1454);
                SetPlayerSkin(playerid, 62);
                SetPlayerInterior(playerid, 3);
                SetPlayerVirtualWorld(playerid, 3);
            }
            case 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40:
            {
                SendClientMessage(playerid, COLOR_ORANGE, ". : : All Saints General Hospital : : .");
                SendClientMessage(playerid, SERVERCOLOR, "You have been shot!");
                SendClientMessage(playerid, SERVERCOLOR, "Docters are removing the bullets!");
                SendClientMessage(playerid, SERVERCOLOR, "You are now in the All Saints General Hospital to rest!");
                //Player[playerid][Hospitalized] = 300;
                SetPlayerPos(playerid, -211.9630,-1761.9679,675.7687);
                SetPlayerFacingAngle(playerid, 309.1454);
                SetPlayerSkin(playerid, 62);
                SetPlayerInterior(playerid, 3);
                SetPlayerVirtualWorld(playerid, 3);
            }
        }
    }
    return 1;
}
Reply
#2

Try this:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    FadeColorForPlayer(playerid,255,0,0,0,255,0,0,255,25,1000);
    JustDied[playerid]=1;
    Player[playerid][Hospitalized] = 300;
   
    Player[playerid][DeathReason] = reason;
    SetTimerEx("RespawnHospital", 1000, false, "d", playerid);
   
    switch (reason)
    {
        case 0: JustDiedCase[playerid] = 1;
        case 51: JustDiedCase[playerid] = 2;
        case 53: JustDiedCase[playerid] = 3;
        case 54: JustDiedCase[playerid] = 4;
        case 49, 50: JustDiedCase[playerid] = 5;
        case 1..15: JustDiedCase[playerid] = 6;
        case 16..40: JustDiedCase[playerid] = 7;
    }
    return 1;
}
Reply
#3

Emmet_ is right but this will work only 95%
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)