TotalHealth+Armor
#1

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
     new Float:health;
     GetPlayerHealth(playerid, health);
        if(weaponid == 7)
   SetPlayerHealth(playerid,health-10);
        if(weaponid == 8)
   SetPlayerHealth(playerid,health-10);
        if(weaponid == 4)
   SetPlayerHealth(playerid,health-30);
        if(weaponid == 3)
   SetPlayerHealth(playerid,health-11);
        if(weaponid == 5)
   SetPlayerHealth(playerid,health-11);
     if(weaponid == 23)
   SetPlayerHealth(playerid,health-20);
        if(weaponid == 24)
   SetPlayerHealth(playerid,health-70);
        if(weaponid == 22)
   SetPlayerHealth(playerid,health-20);
        if(weaponid == 25)
   SetPlayerHealth(playerid,health-60);
        if(weaponid == 26)
   SetPlayerHealth(playerid,health-48);
        if(weaponid == 27)
   SetPlayerHealth(playerid,health-100);
        if(weaponid == 28)
   SetPlayerHealth(playerid,health-30);
        if(weaponid == 29)
   SetPlayerHealth(playerid,health-35);
        if(weaponid == 30)
   SetPlayerHealth(playerid,health-42);
        if(weaponid == 31)
   SetPlayerHealth(playerid,health-48);
        if(weaponid == 32)
   SetPlayerHealth(playerid,health-32);
        if(weaponid == 33)
   SetPlayerHealth(playerid,health-40);
        if(weaponid == 34)
   SetPlayerHealth(playerid,health-100);
        if(weaponid == 33)
   SetPlayerHealth(playerid,health-40);
        if(weaponid == 33) SetPlayerHealth(playerid,health-40);
    }
    return 1;
}
This is the code now I want to change this:
Код:
 SetPlayerHealth(playerid,health-40);
to this
Код:
 SetPlayerHealth(playerid,TotalHealth-40);
for example.

that if I'm shooting someone it will give him -40 from his health and his armor together..

currently, if a player has 100% armor, and 100% HP, and the code is
Код:
 SetPlayerHealth(playerid,health-40);
so it will lower his armor as the weapon lowering default, and it will lower the health -40.

which mean according to this idiot system: a player can die with 0 HP and 50 armor.

I want it to low his total health, like if he got armor 100 and HP 100 so it will lower -40 from his armor first.

Kind of a problem, does anyone knows what can I do? I'm a begginer, do not expect me for a lot.
Reply
#2

pawn Код:
enum E_DATA
{
    gID,
    Float:gHP
};
new TakeHP[18][E_DATA] = {
    {WEAPON_NITESTICK,11.0},
    {WEAPON_KNIFE,30.0},
    {WEAPON_BAT,11.0},
    {WEAPON_POOLSTICK,10.0},
    {WEAPON_KATANA,10.0},
    {WEAPON_COLT45,20.0},
    {WEAPON_SILENCED,20.0},
    {WEAPON_DEAGLE,70.0},
    {WEAPON_SHOTGUN,60.0},
    {WEAPON_SAWEDOFF,48.0},
    {WEAPON_SHOTGSPA,100.0},
    {WEAPON_UZI,30.0},
    {WEAPON_MP5,35.0},
    {WEAPON_AK47,42.0},
    {WEAPON_M4,48.0},
    {WEAPON_TEC9,32.0},
    {WEAPON_RIFLE,40.0},
    {WEAPON_SNIPER,100.0}
};


public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        new Float:health[2];
        GetPlayerHealth(playerid, health[0]);
        GetPlayerArmour(playerid, health[1]);
        for(new d; d < sizeof(TakeHP); d++)
            if(weaponid == TakeHP[d][gID])
            {
                if(health[1] >= TakeHP[d][gHP]) SetPlayerArmour(playerid,health[1]-TakeHP[d][gHP]);
                else{
                    if(health[1] >= 1.0)
                    {
                        new Float:HP = (TakeHP[d][gHP] - health[1]);
                        SetPlayerArmour(playerid,0.0);
                        SetPlayerHealth(playerid,health[0]-HP);
                    }else{
                        SetPlayerHealth(playerid,health[0]-TakeHP[d][gHP]);
                    }
                }
                break;
            }
    }
    return 1;
}
Reply
#3

Can you be more specific man? where do I put this
pawn Код:
enum E_DATA
{
    gID,
    Float:gHP
};
new TakeHP[18][E_DATA] = {
    {WEAPON_NITESTICK,11.0},
    {WEAPON_KNIFE,30.0},
    {WEAPON_BAT,11.0},
    {WEAPON_POOLSTICK,10.0},
    {WEAPON_KATANA,10.0},
    {WEAPON_COLT45,20.0},
    {WEAPON_SILENCED,20.0},
    {WEAPON_DEAGLE,70.0},
    {WEAPON_SHOTGUN,60.0},
    {WEAPON_SAWEDOFF,48.0},
    {WEAPON_SHOTGSPA,100.0},
    {WEAPON_UZI,30.0},
    {WEAPON_MP5,35.0},
    {WEAPON_AK47,42.0},
    {WEAPON_M4,48.0},
    {WEAPON_TEC9,32.0},
    {WEAPON_RIFLE,40.0},
    {WEAPON_SNIPER,100.0}
};
?

please give me a little explaination.
Reply
#4

Quote:
Originally Posted by slerox
Посмотреть сообщение
Can you be more specific man? where do I put this

please give me a little explaination.
That's a global variable put it at the top of your code with the rest of the global variables.
Reply
#5

It's just doesn't do anything, like lowering my armor / hp defaultly as the game suppost to..
Reply
#6

Nevermind - it works!, thank you guys +REP for both of you (:
Reply
#7

thanks it worked!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)