SA-MP Forums Archive
Need help on Damage Weapon - 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: Need help on Damage Weapon (/showthread.php?tid=634797)



Need help on Damage Weapon - NamBank - 26.05.2017

Currently I have code but when it shoots only blood loss when there is armor, blood and armor loss in a high rate can someone help me?
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        new Float:health;
        GetPlayerHealth(playerid, health);
        if(weaponid == 7)
                        SetPlayerHealth(playerid,health-12);
        if(weaponid == 8)
                        SetPlayerHealth(playerid,health-90);
        if(weaponid == 4)
                        SetPlayerHealth(playerid,health-78);
        if(weaponid == 3)
                        SetPlayerHealth(playerid,health-11);
        if(weaponid == 5)
                        SetPlayerHealth(playerid,health-11);
                if(weaponid == 23)
                        SetPlayerHealth(playerid,health-53);
        if(weaponid == 24)
                        SetPlayerHealth(playerid,health-90);
        if(weaponid == 22)
                        SetPlayerHealth(playerid,health-39);
        if(weaponid == 25)
                        SetPlayerHealth(playerid,health-65);
        if(weaponid == 26)
                        SetPlayerHealth(playerid,health-48);
        if(weaponid == 27)
                        SetPlayerHealth(playerid,health-32);
        if(weaponid == 28)
                        SetPlayerHealth(playerid,health-28);
        if(weaponid == 29)
                        SetPlayerHealth(playerid,health-31);
        if(weaponid == 30)
                        SetPlayerHealth(playerid,health-41);
        if(weaponid == 31)
                        SetPlayerHealth(playerid,health-41);
        if(weaponid == 32)
                        SetPlayerHealth(playerid,health-27);
        if(weaponid == 33)
                        SetPlayerHealth(playerid,health-97);
        if(weaponid == 34)
                        SetPlayerHealth(playerid,health-213);
        if(weaponid == 33)
                        SetPlayerHealth(playerid,health-97);
        if(weaponid == 33) SetPlayerHealth(playerid,health-97);
    }
    return 1;
}



Re: Need help on Damage Weapon - SaiyanZ - 26.05.2017

Cannot understand what you mean, Can you rephrase your question please?



Re: Need help on Damage Weapon - asri - 26.05.2017

delete


Re: Need help on Damage Weapon - NamBank - 26.05.2017

Meaning when shooting the player then the player will lose armor star lost all armor and then lose blood


Re: Need help on Damage Weapon - SaiyanZ - 26.05.2017

Still can't understand, What blood, What armor
Seems like you just copy/pasted it, It's the place to learn



Re: Need help on Damage Weapon - Swarn - 28.05.2017

new Float:armor
GetPlayerArmor(playerid, armor);
SetPlayerArmor(playerid, armor, -12)
this for example?


Re: Need help on Damage Weapon - Vince - 28.05.2017

This is basic math. If armor is 0 then subtract from health directly and end function. If armor is greater than or equal to damage then subtract from armor and end function. Final case when armor is greater than zero but smaller than damage: get armor points. Subtract that from the damage. Set armor to zero. Subtract the remaining damage from the player's health.

So if player has 80 health and 30 armor and you want to do 50 damage: Subtract 30 from 50. The remaining damage is now 20. Set the armor to 0. Subtract 20 from the health. Health is now 60. It helps to write stuff down on paper.

Also learn to use switch-statements. They're much faster than stacked ifs in situations like this.