Damage System [Armor & 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: Damage System [Armor & Health] (
/showthread.php?tid=412205)
Damage System [Armor & Health] -
maiky1499 - 01.02.2013
I'm working on a damage system, but I have no idea how to make that if M4 damaged 30 HP and the Target has 5 arnor how its should to remove health & armor.
That's what I got so far.
Код:
if(GetPlayerWeapon(Shooter) == 31)
{
new Float:H, Float:A;
GetPlayerArmour(Target, A);
GetPlayerHealth(Target, H);
if(A < 0 || A > 30)
{
GetPlayerArmour(Target, A);
SetPlayerArmour(Target, A-30);
}
else if(A == 0)
{
GetPlayerHealth(Target, H);
SetPlayerHealth(Target, H-30);
}
}
It's under public OnPlayerShootPlayer.
Re: Damage System [Armor & Health] -
maiky1499 - 02.02.2013
Help please
Re: Damage System [Armor & Health] -
]Rafaellos[ - 02.02.2013
Try this:
pawn Код:
if(GetPlayerWeapon(Shooter) == 31)
{
new Float:H, Float:A, Float:N;
GetPlayerArmour(Target, A);
GetPlayerHealth(Target, H);
if(A >= 30) //if Armour is bigger or equal than 30
{
GetPlayerArmour(Target, A);
SetPlayerArmour(Target, A-30); //if Armour is 30, then the result will be 0 so its ok
}
else if(A == 0)
{
GetPlayerHealth(Target, H);
SetPlayerHealth(Target, H-30);
}
else if(A < 30) //if Armour is smaller than 30
{
N = 29 - A //the maximum number here is 29, so if we minus the Armour from 29, we will save the difference into N
SetPlayerArmour(Target, 0); //setting armour into 0
GetPlayerHealth(Target, H );
SetPlayerHealth(Target, H-N); //minus the differnce
}
}
I dont test it, but i think will work.