Damages - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Damages (
/showthread.php?tid=609262)
Damages -
GoldenLion - 10.06.2016
Hello,
This script is not working properly for some reason. Everytime I shoot someone, it gives back player's health/armor. It's supposed to take more damage when shot to head and default damage when shot to any other bodypart (e.g deagle takes 65 dmg to head and 45 dmg to other bodyparts). Anybody knows what's the problem? When I set only one damage value for a weapon (e.g case 24: damage = 45; ) then it works good.
Here's the code:
http://pastebin.com/hamuRN4r
Re: Damages -
Dayrion - 10.06.2016
Have you tried : OnPlayerTakeDamage(playerid, damagedid, Float:amount, weaponid, bodypart) instead of OnPlayerGiveDamage ?
Re: Damages -
GoldenLion - 10.06.2016
Yeah, but I'm not going to use it.
Re: Damages -
SyS - 10.06.2016
Quote:
Originally Posted by GoldenLion
Yeah, but I'm not going to use it.
|
why?
Re: Damages -
Vince - 10.06.2016
Try using the ternary operator:
PHP код:
damage = (bodypart == 9) ? 30 : 20;
Or, if you want to do it real easy for all weapons, you can multiply the damage by 1.5 after having established the base damage.
Re: Damages -
GoldenLion - 10.06.2016
Also when the target is in a vehicle it works good.
EDIT: Not anymore.
Re: Damages -
GoldenLion - 10.06.2016
Found the problem, I had a same script under OnPlayerTakeDamage for melee weapons, means I didn't have the guns' damages defined.