This keeps resetting armour to 100.
#1

pawn Код:
new Float: armour, Float:Health;
    GetPlayerArmour(playerid, armour);
    GetPlayerHealth(playerid, Health);
    new Float: newam, Float: newam2;
    newam = armour;
    newam2 = Health;
    if(armour > 0)
    {
        if(weaponid == 22) SetPlayerArmour(playerid, newam-15);//m4
        if(weaponid == 31) SetPlayerArmour(playerid, newam-25);//m4
        if(weaponid == 30) SetPlayerArmour(playerid, newam-20);//ak
        if(weaponid == 34) SetPlayerArmour(playerid, newam-90);//sniper
        if(weaponid == 29) SetPlayerArmour(playerid, newam-20);//mp5
        if(weaponid == 24) SetPlayerArmour(playerid, newam-30);//deagle
        if(weaponid == 4) SetPlayerArmour(playerid, newam-35);//knife
        if(weaponid == 26) SetPlayerArmour(playerid, newam-25);
    }
Basically, it reduces the damage but eventually regenerates to 100% again.
This is under OnPlayerTakeDamage.
Reply
#2

Код:
	new Float: armour, Float:Health;
	GetPlayerArmour(playerid, armour);
	GetPlayerHealth(playerid, Health);
 	if(armour > 0)
	{
		if(weaponid == 22) SetPlayerArmour(playerid, amour-15.0);//m4
		if(weaponid == 31) SetPlayerArmour(playerid, Health-25.0);//m4
	    if(weaponid == 30) SetPlayerArmour(playerid, amour-20.0);//ak
	    if(weaponid == 34) SetPlayerArmour(playerid, amour-90.0);//sniper
	    if(weaponid == 29) SetPlayerArmour(playerid, amour-20.0);//mp5
	    if(weaponid == 24) SetPlayerArmour(playerid, amour-30.0);//deagle
	    if(weaponid == 4) SetPlayerArmour(playerid, amour-35.0);//knife
	    if(weaponid == 26) SetPlayerArmour(playerid, amour-25.0);
	}
Reply
#3

That won't make a difference..
Reply
#4

Try adding an else statement.
pawn Код:
else {
    SetPlayerArmour(playerid, 0);
}
Reply
#5

Try using switch.
Reply
#6

Tried both.
Reply
#7

As above, switch may work too.

EDIT: Didn't see your above post saying you tried.
pawn Код:
switch(armour)
    {
        case 1..100:
        {
            switch(weaponid)
            {
                case 22: { SetPlayerArmour(playerid, newam-15); }
                case 31: { SetPlayerArmour(playerid, newam-25); }
                case 30: { SetPlayerArmour(playerid, newam-20); }
                case 34: { SetPlayerArmour(playerid, newam-90); }
                case 29: { SetPlayerArmour(playerid, newam-20); }
                case 24: { SetPlayerArmour(playerid, newam-30); }
                case 4: { SetPlayerArmour(playerid, newam-35); }
                case 26: { SetPlayerArmour(playerid, newam-25); }
            }
        }
    }
When does it restart to 100 exactly?
Reply
#8

Maybe try something like this?

pawn Код:
new Float: armour, Float:Health, Float: newarm[6], Float: newam2;
GetPlayerArmour(playerid, armour);
GetPlayerHealth(playerid, Health);
newarm[0] = 15; newarm[1] = 25;
newarm[2] = 20; newarm[3] = 90;
newarm[4] = 30; newarm[5] = 35;
newam2 = Health;

if(weaponid == 22 && armour >= newarm[0]) {
    SetPlayerArmour(playerid, armour-newarm[0]);//m4
}
else if(weaponid == 31 && armour >= newarm[1]) {
    SetPlayerArmour(playerid, newam-newarm[1]);//m4
}
else if(weaponid == 30 && armour >= newarm[2]) {
    SetPlayerArmour(playerid, newam-newarm[2]);//ak
}
else if(weaponid == 34 && armour >= newarm[3]) {
    SetPlayerArmour(playerid, newam-newarm[3]);//sniper
}
else if(weaponid == 29 && armour >= newarm[2]) {
    SetPlayerArmour(playerid, newam-newarm[2]);//mp5
}
else if(weaponid == 24 && armour >= newarm[4]) {
    SetPlayerArmour(playerid, newam-newarm[4]);//deagle
}
else if(weaponid == 4 && armour >= newarm[5]) {
    SetPlayerArmour(playerid, newam-newarm[5]);//knife
}
else if(weaponid == 26 && armour >= newarm[1]) {
    SetPlayerArmour(playerid, newam-newarm[1]);
}
Reply
#9

PHP код:
                new Float:armourFloat:hp;
                
GetPlayerArmour(playeridarmour);
                if(
Float:armour 0.0)
                {
                    if(
Float:armour FIST_DAMAGE)
                    {
                        
GetPlayerArmour(playeridarmour);
                        
SetPlayerArmour(playeridarmour FIST_DAMAGE);
                    }
                    else
                    {
                        new 
Float:newer;
                        
newer FIST_DAMAGE armour;
                        
SetPlayerArmour(playerid0);
                        
GetPlayerHealth(playeridhp);
                        
SetPlayerHealth(playeridhp newer);
                    }
                }
                else
                {
                    
GetPlayerHealth(playeridhp);
                    
SetPlayerHealth(playeridhp FIST_DAMAGE);
                }
            } 
Your code isn't perfect, see my code and you will understand, and yes, its your anti-cheat fucking with it.
Reply
#10

If "newam" is less than the amount of damage to begin with then you will end up with a negative number. That's basic math. Since SetPlayerArmour presumbably only works with unsigned number it will interpret a negative number as an extremely huge positive number.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)