Damage System [Armor & Health]
#1

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.
Reply
#2

Help please
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)