Armor goes up to 250 when it's ment to become 0.
#1

I'm trying to make a custom damage system following this guide https://sampforum.blast.hk/showthread.php?tid=558839, but there is an issue.

For health, it works fine. But in the case of armour, it just goes back up to 250 if it doesn't end perfectly on 0.

How do I solve this issue? Code below.

PHP Code:
#define BODY_PART_TORSO 3
#define BODY_PART_GROIN 4
#define BODY_PART_LEFT_ARM 5
#define BODY_PART_RIGHT_ARM 6
#define BODY_PART_LEFT_LEG 7
#define BODY_PART_RIGHT_LEG 8
#define BODY_PART_HEAD 9
public OnPlayerConnect(playerid)
{
    
SetPlayerTeam(playerid0);
    return 
1;
}
public 
OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    new 
Floathealth,Floatarmour;
    
GetPlayerHealth(playeridhealth);
    
GetPlayerArmour(playeridarmour);
    switch(
weaponid// Starts the switch, and switches through the variable "weaponid". (declared in callback)
    
{
        case 
34// Sniper Rifle weapon ID
        
{
            switch(
armour// Creates a switch that switches through the armour float, and checks the value.
            
{
                case 
0// If the value is 0, the codes underneath will activate.
                
{
                    switch(
bodypart// Under case 0.
                    
{
                        case 
3SetPlayerHealth(playeridhealth 70); // Torso.
                        
case 4SetPlayerHealth(playeridhealth 40); // Groin.
                        
case 5SetPlayerHealth(playeridhealth 15);  // Left Arm.
                        
case 6SetPlayerHealth(playeridhealth 15); // Right Arm.
                        
case 7SetPlayerHealth(playeridhealth 15);  // Left Leg.
                        
case 8SetPlayerHealth(playeridhealth 15); // Right Leg.
                        
case 9SetPlayerHealth(playeridhealth 100); // Head.
                    
}
                }
                default: 
// Otherwise the codes underneath will activate.
                
{
                    switch(
bodypart// Under case 0.
                    
{
                        case 
3SetPlayerArmour(playeridarmour 35); // Torso.
                        
case 4SetPlayerArmour(playeridarmour 20); // Groin.
                        
case 5SetPlayerArmour(playeridarmour 7);  // Left Arm.
                        
case 6SetPlayerArmour(playeridarmour 7); // Right Arm.
                        
case 7SetPlayerArmour(playeridarmour 7);  // Left Leg.
                        
case 8SetPlayerArmour(playeridarmour 7); // Right Leg.
                        
case 9SetPlayerArmour(playeridarmour 50); // Head.
                    
}
                }
            }
        }
    }
    return 
1;

Reply


Messages In This Thread
Armor goes up to 250 when it's ment to become 0. - by Stefhan - 10.03.2019, 15:54
Re: Armor goes up to 250 when it's ment to become 0. - by Stefhan - 10.03.2019, 16:15

Forum Jump:


Users browsing this thread: 2 Guest(s)