Help less damage variable
#1

I'm trying to get those who have variable ARMADURA, receives less damage, and it will have 3 levels, which would lose more, because it is not working properly?

code
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(ARMADURA[playerid] > 0) {
        if(ARMADURA[playerid] == 1)
        {
            new Float: Colete,
                Float: Vida;
            GetPlayerArmour(playerid, Colete);
            GetPlayerHealth(playerid, Vida);
            if(Colete-amount > 0.0)
            {
                SetPlayerArmour(playerid, Colete+amount*15.0/100.0);
            }else{
                SetPlayerHealth(playerid, Vida+amount*15.0/100.0);
            }
        }
        if(ARMADURA[playerid] == 2)
        {
            new Float: Colete,
                Float: Vida;
            GetPlayerArmour(playerid, Colete);
            GetPlayerHealth(playerid, Vida);
            if(Colete-amount > 0.0)
            {
                SetPlayerArmour(playerid, Colete+amount*30.0/100.0);
            }else{
                SetPlayerHealth(playerid, Vida+amount*30.0/100.0);
            }
        }
        if(ARMADURA[playerid] == 3)
        {
            new Float: Colete,
                Float: Vida;
            GetPlayerArmour(playerid, Colete);
            GetPlayerHealth(playerid, Vida);
            if(Colete-amount > 0.0)
            {
                SetPlayerArmour(playerid, Colete+amount*50.0/100.0);
            }else{
                SetPlayerHealth(playerid, Vida+amount*50.0/100.0);
            }
        }
    }
    return 1;
}
no errors in compilation, but in game have this error
pawn Код:
SetPlayerArmour(playerid, Colete+amount*50.0/100.0);
    }else{
        SetPlayerHealth(playerid, Vida+amount*50.0/100.0);
Life .... 100

Slapped player ARMOR == 0 (without this script)
His life was for: 81

A ARMOR player == 3 his life was for: 108
Reply
#2

no one?
Reply
#3

any?
Reply
#4

help
Reply
#5

your code missed the case where the damage is higher than the armour so you lose armour and health also you used plus instead of minus all the time

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) {
    if(ARMADURA[playerid] > 0) {
        switch(ARMADURA[playerid]) {
            case 1: amount *= 0.85;
            case 2: amount *= 0.70;
            case 3: amount *= 0.50;
        }
        new
            Float: var
        ;
        GetPlayerArmour(playerid, var);

        if(var > amount) {
            SetPlayerArmour(playerid, var - amount);
        } else {
            if(var) {
                SetPlayerArmour(playerid, 0.0);

                amount -= var;
            }
            GetPlayerHealth(playerid, var);
            SetPlayerHealth(playerid, var - amount);
        }
    }
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)