OnPlayerTakeDamage.
#1

Well, what I want is if the player's armour is 100 it would take the armour first, for now it takes HP more than armour :3 , which means he dies before his armour is taken.

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    new Float:HP;
    GetPlayerHealth(playerid, HP);
    if(weaponid == 24) SetPlayerHealth(playerid, HP-110);
    if(weaponid == 22) SetPlayerHealth(playerid, HP-10);
    if(weaponid == 32) SetPlayerHealth(playerid, HP-35);
    if(weaponid == 28) SetPlayerHealth(playerid, HP-35);
    if(weaponid == 23) SetPlayerHealth(playerid, HP-30);
    if(weaponid == 31) SetPlayerHealth(playerid, HP-40);
    if(weaponid == 30) SetPlayerHealth(playerid, HP-40);
    if(weaponid == 29) SetPlayerHealth(playerid, HP-25);
    if(weaponid == 34) SetPlayerHealth(playerid, HP-199);
    if(weaponid == 33) SetPlayerHealth(playerid, HP-100);
    if(weaponid == 25) SetPlayerHealth(playerid, HP-35);
    if(weaponid == 27) SetPlayerHealth(playerid, HP-45); 
    return 1;
}
Thank you!
Reply
#2

1) Do it like this

pawn Код:
switch(weaponid)
{
    case 24: { amount = 110; }
    case 22: { amount = 10; }
    ......
}
2)

pawn Код:
new Float:HP;
new Float:Armour;
GetPlayerHealth(playerid, HP);
GetPlayerArmour(playerid, Armour);

Armour -= amount;
HP -= Armour;
if(Armour > 0.0) SetPlayerArmour(playerid, Armour);
else
{
    SetPlayerArmour(playerid, 0.0);
    if(HP <= 0.0) SetPlayerHealth(playerid, 0.0);
    else SetPlayerHealth(playerid, HP);
}
Reply
#3

I'll test it, thanks for replying.
Reply
#4

It's not working, when someone is getting shot his HP will be restored.
Reply
#5

Here's mine code for health and armour adjusting.

pawn Код:
HealthAdjust(playerid, Float:Health, Float:Armour, Float:Damage)
{
    if(armour <= 100.0)
        Armour -= Damage;
    if(armour <= 0.0)
    {
        Armour = 0.0;
        Health -= Damage;
        if(Health <= 0.0) Health = 0.0;
    }
    SetPlayerHealth(playerid, Health);
    SetPlayerArmour(playerid, Armour);
    return 1;
}
Example:

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    new Float:health, Float:armour;
    GetPlayerHealth(playerid, health);
    GetPlayerArmour(playerid, armour);
    if(issuerid != INVALID_PLAYER_ID)
    {
        switch(weaponid)
        {
            case 22: { //Colt
                HealthAdjust(playerid, health, armour, amount+27.0);
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)