Custom damage system not removing health. - 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: Custom damage system not removing health. (
/showthread.php?tid=609267)
Custom damage system not removing health. -
Dokins - 10.06.2016
pawn Код:
if(armour > 0)
{
new Float: am = armour + amount;
if(weaponid == 22) SetPlayerArmour(damagedid, am-15);//m4
if(weaponid == 31) SetPlayerArmour(damagedid, am-25);//m4
if(weaponid == 30) SetPlayerArmour(damagedid, am-20);//ak
if(weaponid == 34) SetPlayerArmour(damagedid, am-90);//sniper
if(weaponid == 29) SetPlayerArmour(damagedid, am-20);//mp5
if(weaponid == 24) SetPlayerArmour(damagedid, am-30);//deagle
if(weaponid == 4) SetPlayerArmour(damagedid, am-35);//knife
if(weaponid == 26) SetPlayerArmour(damagedid, am-25);
}
if(armour == 0)
{
new Float: am2 = Health+amount;
CauseOfInjury[damagedid] = weaponid;
if(weaponid == 22)
{
SetPlayerHealth(damagedid, am2-15);//9mm
newam = Health+amount-15;
BodyPartDamage[damagedid][bodypart] += newam;
}
if(weaponid == 31)
{
SetPlayerHealth(damagedid, am2-25);//m4
newam = Health+amount-30;
BodyPartDamage[damagedid][bodypart] += newam;
}
if(weaponid == 30)
{
SetPlayerHealth(damagedid, am2-20);//ak
newam = Health+amount-25;
BodyPartDamage[damagedid][bodypart] += newam;
}
if(weaponid == 34)
{
SetPlayerHealth(damagedid, am2-90);//sniper
newam = Health+amount-90;
BodyPartDamage[damagedid][bodypart] += newam;
}
if(weaponid == 29)
{
SetPlayerHealth(damagedid, am2-20);//mp5
newam = Health+amount-20;
BodyPartDamage[damagedid][bodypart] += newam;
}
if(weaponid == 24)
{
SetPlayerHealth(damagedid, am2-30);//deagle
newam = Health+amount-30;
BodyPartDamage[damagedid][bodypart] += newam;
}
if(weaponid == 4)
{
SetPlayerHealth(damagedid, am2-35);
newam = Health+amount-35;
BodyPartDamage[damagedid][bodypart] += newam;
}
if(weaponid == 26)
{
SetPlayerHealth(damagedid, am2-25);//swn
newam = Health+amount-25;
BodyPartDamage[damagedid][bodypart] += newam;
}
else
{
BodyPartDamage[damagedid][bodypart] += amount;
}
}
Title says all, could you please assist, also doesn't remove armour correctly.
Re: Custom damage system not removing health. -
TwinkiDaBoss - 10.06.2016
On what callback are you using this code on?
Re: Custom damage system not removing health. -
GeneralAref - 10.06.2016
use this:
Код:
new Float:damage,Float:ar,Float:hp;
GetPlayerArmour(targetid,ar);
GetPlayerHealth(targetid,hp);
switch(weapondi){
case 0:damage=0;//fist damage
case 1:damge=5;//Brass Knuckles damage
//you can add some id same that
}
ar=ar-damage;
if(ar<=0){
hp=hp+ar;
if(hp<=0){
SetPlayerArmour(targetid,0.0);
SetPlayerHealth(targetid,0.0);}
else if(hp>0){
SetPlayerArmour(targetid,0.0);
SetPlayerHealth(targetid,hp);}
else if(ar>0){
SetPlayerArmour(targetid,ar);}
Re: Custom damage system not removing health. -
Dokins - 10.06.2016
OnPlayerGiveDamage, thanks for the replies.