SA-MP Forums Archive
Help less damage variable - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help less damage variable (/showthread.php?tid=554005)



Help less damage variable - luccagomes15 - 01.01.2015

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


Re: Help less damage variable - luccagomes15 - 03.01.2015

no one?


Re: Help less damage variable - luccagomes15 - 04.01.2015

any?


Re: Help less damage variable - luccagomes15 - 06.01.2015

help


AW: Help less damage variable - Nero_3D - 07.01.2015

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;
}