Script doesn't recognize bodyparts
#1

Hello, I've tried improving one script by adding to the custom damage a new thing, being a generated number based on which bodypart gets shot. The problem is that the script complies with no problems, no errors or anythinb but upon shooting the player, the damage is the same everywhere. Here is the code and I hope somebody could help me out as I ran out of ideas on what to do to be honest.
PHP код:
//bodyparts
#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
#define WEAPONS 2341
#define MELEE_DAMAGE 14.0
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    new 
Float:damage;
    if(
issuerid != INVALID_PLAYER_ID || bodypart == 9//head { 
        
switch(weaponid) {
            case 
WEAPON_BRASSKNUCKLEdamage MELEE_DAMAGE;
            case 
WEAPON_GOLFCLUBdamage MELEE_DAMAGE;
            case 
WEAPON_NITESTICKdamage MELEE_DAMAGE;
            case 
WEAPON_KNIFEdamage 25.0;
            case 
WEAPON_BATdamage MELEE_DAMAGE;
            case 
WEAPON_SHOVELdamage MELEE_DAMAGE;
            case 
WEAPON_POOLSTICKdamage MELEE_DAMAGE;
            case 
WEAPON_KATANAdamage 25.0;
            case 
WEAPON_CHAINSAWdamage 0.0
            case 
WEAPON_DILDOdamage MELEE_DAMAGE;
            case 
WEAPON_DILDO2damage MELEE_DAMAGE;
            case 
WEAPON_VIBRATORdamage MELEE_DAMAGE;
            case 
WEAPON_VIBRATOR2damage MELEE_DAMAGE;
            case 
WEAPON_FLOWERdamage MELEE_DAMAGE;
            case 
WEAPON_CANEdamage MELEE_DAMAGE;
            case 
WEAPON_GRENADEdamage 85.0;
            case 
WEAPON_TEARGASdamage 20.0;
            case 
WEAPON_MOLTOVdamage 25.0;
            case 
WEAPON_COLT45damage 40.0;
            case 
WEAPON_SILENCEDdamage 0.0ApplyAnimation(playerid,"CRACK","crckidle2",4,1,00,0,0);
            case 
WEAPON_DEAGLEdamage 60.0;
            case 
WEAPON_SHOTGUNdamage 55.0;
            case 
WEAPON_SAWEDOFFdamage 45.0;
            case 
WEAPON_SHOTGSPAdamage 45.0;
            case 
WEAPON_UZIdamage 40.0;
            case 
WEAPON_MP5damage 45.0;
            case 
WEAPON_AK47damage 65.0;
            case 
WEAPON_M4damage 60.0;
            case 
WEAPON_TEC9damage 40.0;
            case 
WEAPON_RIFLEdamage 65.0;
            case 
WEAPON_SNIPERdamage 75.0;
            case 
WEAPON_ROCKETLAUNCHERdamage 0.0;
            case 
WEAPON_HEATSEEKERdamage 0.0;
            case 
WEAPON_FLAMETHROWERdamage 25.0;
            case 
WEAPON_MINIGUNdamage 0.0/* disabled, never to be used */
            
default: damage MELEE_DAMAGE;
        }
         if(
bodypart == || 8//legs
        
{
            switch(
weaponid) {
            case 
WEAPON_BRASSKNUCKLEdamage MELEE_DAMAGE;
            case 
WEAPON_GOLFCLUBdamage MELEE_DAMAGE;
            case 
WEAPON_NITESTICKdamage MELEE_DAMAGE;
            case 
WEAPON_KNIFEdamage 23.0;
            case 
WEAPON_BATdamage MELEE_DAMAGE;
            case 
WEAPON_SHOVELdamage MELEE_DAMAGE;
            case 
WEAPON_POOLSTICKdamage MELEE_DAMAGE;
            case 
WEAPON_KATANAdamage 23.0;
            case 
WEAPON_CHAINSAWdamage 0.0// disabled, never to be used
            
case WEAPON_DILDOdamage MELEE_DAMAGE;
            case 
WEAPON_DILDO2damage MELEE_DAMAGE;
            case 
WEAPON_VIBRATORdamage MELEE_DAMAGE;
            case 
WEAPON_VIBRATOR2damage MELEE_DAMAGE;
            case 
WEAPON_FLOWERdamage MELEE_DAMAGE;
            case 
WEAPON_CANEdamage MELEE_DAMAGE;
            case 
WEAPON_GRENADEdamage 85.0;
            case 
WEAPON_TEARGASdamage 20.0;
            case 
WEAPON_MOLTOVdamage 25.0;
            case 
WEAPON_COLT45damage 27.0;
            case 
WEAPON_SILENCEDdamage 0.0ApplyAnimation(playerid,"CRACK","crckidle2",4,1,00,0,0);
            case 
WEAPON_DEAGLEdamage 40.0;
            case 
WEAPON_SHOTGUNdamage 40.0;
            case 
WEAPON_SAWEDOFFdamage 55.0;
            case 
WEAPON_SHOTGSPAdamage 32.0;
            case 
WEAPON_UZIdamage 27.0;
            case 
WEAPON_MP5damage 30.0;
            case 
WEAPON_AK47damage 44.0;
            case 
WEAPON_M4damage 40.0;
            case 
WEAPON_TEC9damage 27.0;
            case 
WEAPON_RIFLEdamage 65.0;
            case 
WEAPON_SNIPERdamage 75.0;
            case 
WEAPON_ROCKETLAUNCHERdamage 0.0;
            case 
WEAPON_HEATSEEKERdamage 0.0;
            case 
WEAPON_FLAMETHROWERdamage 25.0;
            case 
WEAPON_MINIGUNdamage 0.0/* disabled, never to be used */
            
}
         if(
bodypart == || 6//arms
        
{
            switch(
weaponid) {
            case 
WEAPON_BRASSKNUCKLEdamage MELEE_DAMAGE;
            case 
WEAPON_GOLFCLUBdamage MELEE_DAMAGE;
            case 
WEAPON_NITESTICKdamage MELEE_DAMAGE;
            case 
WEAPON_KNIFEdamage 23.0;
            case 
WEAPON_BATdamage MELEE_DAMAGE;
            case 
WEAPON_SHOVELdamage MELEE_DAMAGE;
            case 
WEAPON_POOLSTICKdamage MELEE_DAMAGE;
            case 
WEAPON_KATANAdamage 23.0;
            case 
WEAPON_CHAINSAWdamage 0.0// disabled, never to be used
            
case WEAPON_DILDOdamage MELEE_DAMAGE;
            case 
WEAPON_DILDO2damage MELEE_DAMAGE;
            case 
WEAPON_VIBRATORdamage MELEE_DAMAGE;
            case 
WEAPON_VIBRATOR2damage MELEE_DAMAGE;
            case 
WEAPON_FLOWERdamage MELEE_DAMAGE;
            case 
WEAPON_CANEdamage MELEE_DAMAGE;
            case 
WEAPON_GRENADEdamage 85.0;
            case 
WEAPON_TEARGASdamage 20.0;
            case 
WEAPON_MOLTOVdamage 25.0;
            case 
WEAPON_COLT45damage 24.0;
            case 
WEAPON_SILENCEDdamage 0.0ApplyAnimation(playerid,"CRACK","crckidle2",4,1,00,0,0);
            case 
WEAPON_DEAGLEdamage 35.0;
            case 
WEAPON_SHOTGUNdamage 35.0;
            case 
WEAPON_SAWEDOFFdamage 50.0;
            case 
WEAPON_SHOTGSPAdamage 27.0;
            case 
WEAPON_UZIdamage 24.0;
            case 
WEAPON_MP5damage 27.0;
            case 
WEAPON_AK47damage 38.0;
            case 
WEAPON_M4damage 35.0;
            case 
WEAPON_TEC9damage 24.0;
            case 
WEAPON_RIFLEdamage 65.0;
            case 
WEAPON_SNIPERdamage 75.0;
            case 
WEAPON_ROCKETLAUNCHERdamage 0.0;
            case 
WEAPON_HEATSEEKERdamage 0.0;
            case 
WEAPON_FLAMETHROWERdamage 25.0;
            case 
WEAPON_MINIGUNdamage 0.0/*disabled, never to be used */
            
}
        if(
bodypart == || 4//torso
  
{
            switch(
weaponid) {
            case 
WEAPON_BRASSKNUCKLEdamage MELEE_DAMAGE;
            case 
WEAPON_GOLFCLUBdamage MELEE_DAMAGE;
            case 
WEAPON_NITESTICKdamage MELEE_DAMAGE;
            case 
WEAPON_KNIFEdamage 23.0;
            case 
WEAPON_BATdamage MELEE_DAMAGE;
            case 
WEAPON_SHOVELdamage MELEE_DAMAGE;
            case 
WEAPON_POOLSTICKdamage MELEE_DAMAGE;
            case 
WEAPON_KATANAdamage 23.0;
            case 
WEAPON_CHAINSAWdamage 0.0// disabled, never to be used
            
case WEAPON_DILDOdamage MELEE_DAMAGE;
            case 
WEAPON_DILDO2damage MELEE_DAMAGE;
            case 
WEAPON_VIBRATORdamage MELEE_DAMAGE;
            case 
WEAPON_VIBRATOR2damage MELEE_DAMAGE;
            case 
WEAPON_FLOWERdamage MELEE_DAMAGE;
            case 
WEAPON_CANEdamage MELEE_DAMAGE;
            case 
WEAPON_GRENADEdamage 85.0;
            case 
WEAPON_TEARGASdamage 20.0;
            case 
WEAPON_MOLTOVdamage 25.0;
            case 
WEAPON_COLT45damage 30.0;
            case 
WEAPON_SILENCEDdamage 0.0ApplyAnimation(playerid,"CRACK","crckidle2",4,1,00,0,0);
            case 
WEAPON_DEAGLEdamage 45.0;
            case 
WEAPON_SHOTGUNdamage 40.0;
            case 
WEAPON_SAWEDOFFdamage 65.0;
            case 
WEAPON_SHOTGSPAdamage 35.0;
            case 
WEAPON_UZIdamage 30.0;
            case 
WEAPON_MP5damage 34.0;
            case 
WEAPON_AK47damage 48.0;
            case 
WEAPON_M4damage 45.0;
            case 
WEAPON_TEC9damage 30.0;
            case 
WEAPON_RIFLEdamage 65.0;
            case 
WEAPON_SNIPERdamage 75.0;
            case 
WEAPON_ROCKETLAUNCHERdamage 0.0;
            case 
WEAPON_HEATSEEKERdamage 0.0;
            case 
WEAPON_FLAMETHROWERdamage 25.0;
            case 
WEAPON_MINIGUNdamage 0.0/* disabled, never to be used */
            
default: damage MELEE_DAMAGE;
   }
   }
   }
            }
        new 
Float:armourFloat:hp;
        
GetPlayerArmour(playeridarmour);
        
GetPlayerHealth(playeridhp);
        if(
armour && (armour damage <= 0))
            
SetPlayerArmour(playerid0.0);
        else if(
armour && (armour damage 0)) {
            
SetPlayerArmour(playeridarmour-damage);
        }
        else {
            
SetPlayerArmour(playerid0.0); /* just in case */
            
SetPlayerHealth(playeridhp-damage);
        }
        
#if defined DEBUG_ADVDAMAGE
            
printf("[DEBUG-Z] %i, %i : %.2f, %i, %i"playeridissueriddamageweaponidbodypart);
        
#endif
    
}
    
#if defined SPC_OnPlayerTakeDamage
        
return SPC_OnPlayerTakeDamage(playeridissueridamountweaponidbodypart);
    
#else
           
return 1;
    
#endif

Reply
#2

havn't read through all your code but i already see a problem here
Код:
if(issuerid != INVALID_PLAYER_ID || bodypart == 9) //head {
you're commenting out the bracket '{'
Reply
#3

Your code will cause crashes or warnings.
Use something like the code below
PHP код:
if(issuerid != INVALID_PLAYER_ID)
{
    switch(
bodypart)
    {
        case 
0:
        case 
.. 8:
    }

Reply
#4

It's not causing any crashes nor warnings, the problem is that it works the same way as if it doesn't have the bodypart script written there, they just take no effect. I am not sure how to add the bodypart switch to the weaponid switch.
Reply
#5

Use it like this, this code is faster, better and optimized.
PHP код:
if(issuerid != INVALID_PLAYER_ID)
{
    switch(
bodypart)
    {
        case 
0:
        {
            switch(
weaponid)
            {
                case 
WEAPON_KNIFEGivePlayerHealth(playeridWEAPON_KNIFE_DAMAGE);
            }
        }
        case 
.. 8:
    }

PHP код:
GivePlayerHealth(playeriddamage)
{
    new 
Float:GetPlayerHealth(playerid);
    
SetPlayerHealth(playeriddamage);
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)