Damage help!
#1

Hello, I am trying to script in realistic damage for a script yet I do not know how to tell the script, if the player has armor to "Attack the armor first" Not just the HP... here is it so far!

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    new Float:HP;
    GetPlayerHealth(playerid, HP);
    if(weaponid == 24) SetPlayerHealth(playerid, HP-40);//DesertEagle
    if(weaponid == 22) SetPlayerHealth(playerid, HP-30);//Colt45
    if(weaponid == 32) SetPlayerHealth(playerid, HP-15);//Tec9
    if(weaponid == 28) SetPlayerHealth(playerid, HP-15);//Uzi
    if(weaponid == 23) SetPlayerHealth(playerid, HP-35);//SilencedColt
    if(weaponid == 31) SetPlayerHealth(playerid, HP-37);//M4
    if(weaponid == 30) SetPlayerHealth(playerid, HP-34);//AK
    if(weaponid == 29) SetPlayerHealth(playerid, HP-18);//MP5
    if(weaponid == 34) SetPlayerHealth(playerid, HP-300);//SniperRifle
    if(weaponid == 33) SetPlayerHealth(playerid, HP-35);//CuntGun
    if(weaponid == 25) SetPlayerHealth(playerid, HP-40);//PumpShotgun
    if(weaponid == 27) SetPlayerHealth(playerid, HP-30);//Spaz12
    return 1;
}
Any help will be appreciated
Reply
#2

Try this
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
   if(GetPlayerArmour(playerid)<1)
   {
    new Float:ARM;
    GetPlayerArmour(playerid, ARM);
    if(weaponid == 24) SetPlayerArmour(playerid, ARM-40);//DesertEagle
   }
   else
   {
    new Float:HP
    GetPlayerHealth(playerid,HP);
    if(weaponid == 24) SetPlayerHealth(playerid, HP-40);//DesertEagle
    }
    return 1;
}
//Like that use for other also.
Sorry if there's a mistake because I didnt test/compile this.
Reply
#3

Thank you! but...
(57091) : warning 202: number of arguments does not match definition
(57100) : error 001: expected token: ";", but found "-identifier-"
Reply
#4

Bump, please help!
Reply
#5

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    new Float:Armour, Float:Health;
    GetPlayerArmour(playerid, Armour);
    GetPlayerHealth(playerid, Health);
    if(Armour > 0)
    {
        switch(weaponid)
        {
            case 22, 27: return SetPlayerArmour(playerid, Armour - 30);
            case 28, 32: return SetPlayerArmour(playerid, Armour - 15);
            case 23, 33: return SetPlayerArmour(playerid, Armour - 35);
            case 24, 25: return SetPlayerArmour(playerid, Armour - 40);
            case 29: return SetPlayerArmour(playerid, Armour - 18);
            case 30: return SetPlayerArmour(playerid, Armour - 34);
            case 31: return SetPlayerArmour(playerid, Armour - 37);
            case 34: return SetPlayerArmour(playerid, Armour - 300);
        }
    }
    else
    {
        switch(weaponid)
        {
            case 22, 27: return SetPlayerHealth(playerid, Health - 30);
            case 28, 32: return SetPlayerHealth(playerid, Health - 15);
            case 23, 33: return SetPlayerHealth(playerid, Health - 35);
            case 24, 25: return SetPlayerHealth(playerid, Health - 40);
            case 29: return SetPlayerHealth(playerid, Health - 18);
            case 30: return SetPlayerHealth(playerid, Health - 34);
            case 31: return SetPlayerHealth(playerid, Health - 37);
            case 34: return SetPlayerHealth(playerid, Health - 300);
        }
    }
    return 1;
}
Reply
#6

https://sampforum.blast.hk/showthread.php?tid=348044

pawn Код:
DealPlayerDamage(playerid, damage)
It calculates whether to take HP only, armor only, or both HP and armor.
Reply
#7

pawn Код:
#define EvaluateDamage(%0); \
if (floatcmp(%0, AP) == 1) { Remain = floatsub(%0, AP); SetPlayerArmour(playerid, 0.0); \
SetPlayerHealth(playerid, HP - Remain); } \
else { SetPlayerArmour(playerid, floatsub(AP, %0)); }

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    new Float:HP, Float:AP, Float:Remain;
    GetPlayerHealth(playerid, HP);
    GetPlayerArmour(playerid, AP);
    if(weaponid == 24) { EvaluateDamage(40); } //DesertEagle
    if(weaponid == 22) { EvaluateDamage(30); } //Colt45
    if(weaponid == 32) { EvaluateDamage(15); } //Tec9
    if(weaponid == 28) { EvaluateDamage(15); } //Uzi
    if(weaponid == 23) { EvaluateDamage(35); } //SilencedColt
    if(weaponid == 31) { EvaluateDamage(37); } //M4
    if(weaponid == 30) { EvaluateDamage(34); } //AK
    if(weaponid == 29) { EvaluateDamage(18); } //MP5
    if(weaponid == 34) { EvaluateDamage(300); } //SniperRifle
    if(weaponid == 33) { EvaluateDamage(35); } //CuntGun
    if(weaponid == 25) { EvaluateDamage(40); }//PumpShotgun
    if(weaponid == 27) { EvaluateDamage(30); } //Spaz12
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)