11.03.2019, 15:32
Quote:
There are a few issues with your health/armor code in general.
If a player has 1.0 armor, a shot would only do one damage. You need to calculate the overhead if a player has less armor than the damage done, and subtract the rest from their health. Furthermore you use switch on a Float value. It works in this very case (since you check for 0, which is the equivalent to the Float 0.0). switch does work on Float but it is the opposite of efficient since it generates a really large jump table. That complete switch is unneccessary, just use if (since you only have 2 cases anyway). Furthermore why OnPlayerTakeDamage? Do you want to have lagshooting on your server? Use OnPlayerWeaponShot to avoid lagshooting and pistol whipping (pistol whipping is not a projectile, so it won't get called). In case you do want to have lagshooting, simply check the damage value passed to the callback (pistol whipping does less damage than a bullet). Also for the bodypart damage you could rather work with a multiplier value instead of hardcoding every case for every weapon. Same for an armor hit, just do (eg) 10% less damage to armor. |
I've tried to work with what you've described, but honestly, I am quite clueless on a few things and have some questions.
How would I go over calculating the overhead to deduct health after armour? I have noticed that there is an issue in general with the index being out of bounds at the moment.
PHP код:
[debug] Run time error 4: "Array index out of bounds"
[debug] Attempted to read/write array element at index 65535 in array of size 47
[debug] AMX backtrace:
[debug] #0 0005f9d8 in public OnPlayerTakeDamage (1, 65535, 1079194420, 54, 3)
Lastly, I realized a knife's special attack doesn't work properly when you're in the same team. Do you know if there is a workaround to this issue?
Here is the full code that I currently have, I hope you can guide me further and help me turn this into an efficient, working system.
https://pastebin.com/icxScHs1