Issue with custom damage system (pistolwhipping)
#1

So I made a custom damage system based off of this guide https://sampforum.blast.hk/showthread.php?tid=558839, but there is an issue.

If I pistol whip someone (punch someone with a gun) it bases it off torso damage. Basically, I can punch someone and hit 40 now. How do I solve this issue?

Example:



See code below.

PHP код:
#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 
my_SetPlayerArmour(playeridFloat:amount)
{
    if(
amount 0.0)
    {
        
amount 0.0;
    }
    return 
SetPlayerArmour(playeridamount);
}
#if defined _ALS_SetPlayerArmour
    #undef SetPlayerArmour
#else
    #define _ALS_SetPlayerArmour
#endif
#define SetPlayerArmour my_SetPlayerArmour
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 
24// Desert Eagle weapon ID
        
{
            switch(
armour)
            {
                case 
0:
                {
                    switch(
bodypart)
                    {
                        case 
3SetPlayerHealth(playeridhealth 40); // Torso.
                        
case 4SetPlayerHealth(playeridhealth 18); // Groin.
                        
case 5SetPlayerHealth(playeridhealth 8);  // Left Arm.
                        
case 6SetPlayerHealth(playeridhealth 8); // Right Arm.
                        
case 7SetPlayerHealth(playeridhealth 8);  // Left Leg.
                        
case 8SetPlayerHealth(playeridhealth 8); // Right Leg.
                        
case 9SetPlayerHealth(playeridhealth 50); // Head.
                    
}
                }
                default:
                {
                    switch(
bodypart)
                    {
                        case 
3SetPlayerArmour(playeridarmour 30); // Torso.
                        
case 4SetPlayerArmour(playeridarmour 14); // Groin.
                        
case 5SetPlayerArmour(playeridarmour 6);  // Left Arm.
                        
case 6SetPlayerArmour(playeridarmour 6); // Right Arm.
                        
case 7SetPlayerArmour(playeridarmour 6);  // Left Leg.
                        
case 8SetPlayerArmour(playeridarmour 6); // Right Leg.
                        
case 9SetPlayerArmour(playeridarmour 40); // Head.
                    
}
                }
            }
        }
        } 
    } 
    return 
1

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)