13.08.2016, 00:15
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(playerid, issuerid, Float:amount, weaponid, bodypart)
{
new Float:damage;
if(issuerid != INVALID_PLAYER_ID || bodypart == 9) //head {
switch(weaponid) {
case WEAPON_BRASSKNUCKLE: damage = MELEE_DAMAGE;
case WEAPON_GOLFCLUB: damage = MELEE_DAMAGE;
case WEAPON_NITESTICK: damage = MELEE_DAMAGE;
case WEAPON_KNIFE: damage = 25.0;
case WEAPON_BAT: damage = MELEE_DAMAGE;
case WEAPON_SHOVEL: damage = MELEE_DAMAGE;
case WEAPON_POOLSTICK: damage = MELEE_DAMAGE;
case WEAPON_KATANA: damage = 25.0;
case WEAPON_CHAINSAW: damage = 0.0;
case WEAPON_DILDO: damage = MELEE_DAMAGE;
case WEAPON_DILDO2: damage = MELEE_DAMAGE;
case WEAPON_VIBRATOR: damage = MELEE_DAMAGE;
case WEAPON_VIBRATOR2: damage = MELEE_DAMAGE;
case WEAPON_FLOWER: damage = MELEE_DAMAGE;
case WEAPON_CANE: damage = MELEE_DAMAGE;
case WEAPON_GRENADE: damage = 85.0;
case WEAPON_TEARGAS: damage = 20.0;
case WEAPON_MOLTOV: damage = 25.0;
case WEAPON_COLT45: damage = 40.0;
case WEAPON_SILENCED: damage = 0.0, ApplyAnimation(playerid,"CRACK","crckidle2",4,1,0, 0,0,0);
case WEAPON_DEAGLE: damage = 60.0;
case WEAPON_SHOTGUN: damage = 55.0;
case WEAPON_SAWEDOFF: damage = 45.0;
case WEAPON_SHOTGSPA: damage = 45.0;
case WEAPON_UZI: damage = 40.0;
case WEAPON_MP5: damage = 45.0;
case WEAPON_AK47: damage = 65.0;
case WEAPON_M4: damage = 60.0;
case WEAPON_TEC9: damage = 40.0;
case WEAPON_RIFLE: damage = 65.0;
case WEAPON_SNIPER: damage = 75.0;
case WEAPON_ROCKETLAUNCHER: damage = 0.0;
case WEAPON_HEATSEEKER: damage = 0.0;
case WEAPON_FLAMETHROWER: damage = 25.0;
case WEAPON_MINIGUN: damage = 0.0; /* disabled, never to be used */
default: damage = MELEE_DAMAGE;
}
if(bodypart == 7 || 8) //legs
{
switch(weaponid) {
case WEAPON_BRASSKNUCKLE: damage = MELEE_DAMAGE;
case WEAPON_GOLFCLUB: damage = MELEE_DAMAGE;
case WEAPON_NITESTICK: damage = MELEE_DAMAGE;
case WEAPON_KNIFE: damage = 23.0;
case WEAPON_BAT: damage = MELEE_DAMAGE;
case WEAPON_SHOVEL: damage = MELEE_DAMAGE;
case WEAPON_POOLSTICK: damage = MELEE_DAMAGE;
case WEAPON_KATANA: damage = 23.0;
case WEAPON_CHAINSAW: damage = 0.0; // disabled, never to be used
case WEAPON_DILDO: damage = MELEE_DAMAGE;
case WEAPON_DILDO2: damage = MELEE_DAMAGE;
case WEAPON_VIBRATOR: damage = MELEE_DAMAGE;
case WEAPON_VIBRATOR2: damage = MELEE_DAMAGE;
case WEAPON_FLOWER: damage = MELEE_DAMAGE;
case WEAPON_CANE: damage = MELEE_DAMAGE;
case WEAPON_GRENADE: damage = 85.0;
case WEAPON_TEARGAS: damage = 20.0;
case WEAPON_MOLTOV: damage = 25.0;
case WEAPON_COLT45: damage = 27.0;
case WEAPON_SILENCED: damage = 0.0, ApplyAnimation(playerid,"CRACK","crckidle2",4,1,0, 0,0,0);
case WEAPON_DEAGLE: damage = 40.0;
case WEAPON_SHOTGUN: damage = 40.0;
case WEAPON_SAWEDOFF: damage = 55.0;
case WEAPON_SHOTGSPA: damage = 32.0;
case WEAPON_UZI: damage = 27.0;
case WEAPON_MP5: damage = 30.0;
case WEAPON_AK47: damage = 44.0;
case WEAPON_M4: damage = 40.0;
case WEAPON_TEC9: damage = 27.0;
case WEAPON_RIFLE: damage = 65.0;
case WEAPON_SNIPER: damage = 75.0;
case WEAPON_ROCKETLAUNCHER: damage = 0.0;
case WEAPON_HEATSEEKER: damage = 0.0;
case WEAPON_FLAMETHROWER: damage = 25.0;
case WEAPON_MINIGUN: damage = 0.0; /* disabled, never to be used */
}
if(bodypart == 5 || 6) //arms
{
switch(weaponid) {
case WEAPON_BRASSKNUCKLE: damage = MELEE_DAMAGE;
case WEAPON_GOLFCLUB: damage = MELEE_DAMAGE;
case WEAPON_NITESTICK: damage = MELEE_DAMAGE;
case WEAPON_KNIFE: damage = 23.0;
case WEAPON_BAT: damage = MELEE_DAMAGE;
case WEAPON_SHOVEL: damage = MELEE_DAMAGE;
case WEAPON_POOLSTICK: damage = MELEE_DAMAGE;
case WEAPON_KATANA: damage = 23.0;
case WEAPON_CHAINSAW: damage = 0.0; // disabled, never to be used
case WEAPON_DILDO: damage = MELEE_DAMAGE;
case WEAPON_DILDO2: damage = MELEE_DAMAGE;
case WEAPON_VIBRATOR: damage = MELEE_DAMAGE;
case WEAPON_VIBRATOR2: damage = MELEE_DAMAGE;
case WEAPON_FLOWER: damage = MELEE_DAMAGE;
case WEAPON_CANE: damage = MELEE_DAMAGE;
case WEAPON_GRENADE: damage = 85.0;
case WEAPON_TEARGAS: damage = 20.0;
case WEAPON_MOLTOV: damage = 25.0;
case WEAPON_COLT45: damage = 24.0;
case WEAPON_SILENCED: damage = 0.0, ApplyAnimation(playerid,"CRACK","crckidle2",4,1,0, 0,0,0);
case WEAPON_DEAGLE: damage = 35.0;
case WEAPON_SHOTGUN: damage = 35.0;
case WEAPON_SAWEDOFF: damage = 50.0;
case WEAPON_SHOTGSPA: damage = 27.0;
case WEAPON_UZI: damage = 24.0;
case WEAPON_MP5: damage = 27.0;
case WEAPON_AK47: damage = 38.0;
case WEAPON_M4: damage = 35.0;
case WEAPON_TEC9: damage = 24.0;
case WEAPON_RIFLE: damage = 65.0;
case WEAPON_SNIPER: damage = 75.0;
case WEAPON_ROCKETLAUNCHER: damage = 0.0;
case WEAPON_HEATSEEKER: damage = 0.0;
case WEAPON_FLAMETHROWER: damage = 25.0;
case WEAPON_MINIGUN: damage = 0.0; /*disabled, never to be used */
}
if(bodypart == 3 || 4) //torso
{
switch(weaponid) {
case WEAPON_BRASSKNUCKLE: damage = MELEE_DAMAGE;
case WEAPON_GOLFCLUB: damage = MELEE_DAMAGE;
case WEAPON_NITESTICK: damage = MELEE_DAMAGE;
case WEAPON_KNIFE: damage = 23.0;
case WEAPON_BAT: damage = MELEE_DAMAGE;
case WEAPON_SHOVEL: damage = MELEE_DAMAGE;
case WEAPON_POOLSTICK: damage = MELEE_DAMAGE;
case WEAPON_KATANA: damage = 23.0;
case WEAPON_CHAINSAW: damage = 0.0; // disabled, never to be used
case WEAPON_DILDO: damage = MELEE_DAMAGE;
case WEAPON_DILDO2: damage = MELEE_DAMAGE;
case WEAPON_VIBRATOR: damage = MELEE_DAMAGE;
case WEAPON_VIBRATOR2: damage = MELEE_DAMAGE;
case WEAPON_FLOWER: damage = MELEE_DAMAGE;
case WEAPON_CANE: damage = MELEE_DAMAGE;
case WEAPON_GRENADE: damage = 85.0;
case WEAPON_TEARGAS: damage = 20.0;
case WEAPON_MOLTOV: damage = 25.0;
case WEAPON_COLT45: damage = 30.0;
case WEAPON_SILENCED: damage = 0.0, ApplyAnimation(playerid,"CRACK","crckidle2",4,1,0, 0,0,0);
case WEAPON_DEAGLE: damage = 45.0;
case WEAPON_SHOTGUN: damage = 40.0;
case WEAPON_SAWEDOFF: damage = 65.0;
case WEAPON_SHOTGSPA: damage = 35.0;
case WEAPON_UZI: damage = 30.0;
case WEAPON_MP5: damage = 34.0;
case WEAPON_AK47: damage = 48.0;
case WEAPON_M4: damage = 45.0;
case WEAPON_TEC9: damage = 30.0;
case WEAPON_RIFLE: damage = 65.0;
case WEAPON_SNIPER: damage = 75.0;
case WEAPON_ROCKETLAUNCHER: damage = 0.0;
case WEAPON_HEATSEEKER: damage = 0.0;
case WEAPON_FLAMETHROWER: damage = 25.0;
case WEAPON_MINIGUN: damage = 0.0; /* disabled, never to be used */
default: damage = MELEE_DAMAGE;
}
}
}
}
new Float:armour, Float:hp;
GetPlayerArmour(playerid, armour);
GetPlayerHealth(playerid, hp);
if(armour > 0 && (armour - damage <= 0))
SetPlayerArmour(playerid, 0.0);
else if(armour > 0 && (armour - damage > 0)) {
SetPlayerArmour(playerid, armour-damage);
}
else {
SetPlayerArmour(playerid, 0.0); /* just in case */
SetPlayerHealth(playerid, hp-damage);
}
#if defined DEBUG_ADVDAMAGE
printf("[DEBUG-Z] %i, %i : %.2f, %i, %i", playerid, issuerid, damage, weaponid, bodypart);
#endif
}
#if defined SPC_OnPlayerTakeDamage
return SPC_OnPlayerTakeDamage(playerid, issuerid, amount, weaponid, bodypart);
#else
return 1;
#endif
}