samp-weapon-config
samp-weapon-config copied to clipboard
Custom Damage Types
It will be very nice if there is a function/way to add custom damage types overcoming the complexities.
Umm, like custom weapon ids?
Yes.
That's why we're here. That's why I suggested you add weapon id's for the water splash and vehicle rolling/bike crashing.
Adding custom ids is very complicated.
That's why slice made it simple. Just change examine how he does his. Define a new one, change to yours in the OnPlayerDeath hook, use it in ProcessDamage when needed, and InflictDamage.
Actually, there are some compile-time issues. Many arrays are declared with max value WEAPON_UNKNOWN and some runtime checks limit the value.
I think the best thing would be to just add WEAPON_CUSTOM_1-9
or more. People could just do something like this:
#define WEAPON_TAZER WEAPON_CUSTOM_1
#define WEAPON_ADMIN_SLAP WEAPON_CUSTOM_2
@Crayder Sorry for being off topic a bit, have you tested the file which I sent you ?
@codectile Actually no, haven't had the spare time for anything lately, maybe tomorrow when I get home from work. I'll get back to ya when I do though.
@oscar-broman Thanks for the headsup on that, I was just about to add a few more too.
The downside of WEAPON_CUSTOM_*
is if you use modular includes that provide custom damage types - it would be hard to decide which ID it should get.
The best solution is a convention like this:
#define WEAPON_TAZER WEAPON_CUSTOM_x
#include <tazer>
// tazer.inc
#if !defined WEAPON_TAZER
#error Define WEAPON_TAZER before including tazer.inc
#endif
Why? Because the IDs will remain the same (as decided in one place) instead of dynamically allocated depending on which order you include files. The IDs should remain the same, since they could be stored in databases or other persistent storages.