I started another thread yesterday but wanted to make a new one to show that damage types are either incorrect, or I'm incredibly stupid and missing something. It started with a leaderboards addon not working correctly (it had actually not been working for a week) and once I took a closer look, weapons weren't returning the correct damage types. I re-installed a fresh, clean, GMod server to test it out.
Here's the hook I use for getting damage type:
[CODE]hook.Add("DoPlayerDeath", "Test", function(ply, killer, dmginfo)
killer:PrintMessage(3, dmginfo:GetDamageType())
end)[/CODE]
Which the damage types can be found here [url]http://wiki.garrysmod.com/page/Enums/DMG[/url]
But as you can see, I've tried with multiple weapons and the damage type returns this:
8194
[url]http://i.imgur.com/y3NYMWC.png[/url]
[url]http://i.imgur.com/UcgNpWx.png[/url]
4098
[url]http://i.imgur.com/e1EX6XS.png[/url]
[url]http://i.imgur.com/tAP0Xra.png[/url]
EDIT: Just came across this: [url]http://facepunch.com/showthread.php?t=1216219[/url] after googling. How come it changed from just DMG_BULLET (2) to adding DMG_ALWAYSGIB/DMG_NEVERGIB along with the damage type? It suddenly changed for no apparent reason.
My guess is that one of your addons is causing it.
[QUOTE=Robotboy655;46048953]My guess is that one of your addons is causing it.[/QUOTE]
Nope. Fresh server, no addons, nothing changed except vars in server.cfg for not having to wait a minute for a round to start on TTT.
Why does this matter anyway? You clearly shouldn't use == for damage type checks.
[QUOTE=Robotboy655;46049009]Why does this matter anyway? You clearly shouldn't use == for damage type checks.[/QUOTE]
Then what should be used?
Because one week it was working and printing DMG_BULLET, now it's adding DMG_ALWAYSGIB/DMG_NEVERGIB for no reason.
I don't know why it does that, but this should be used: [url]http://wiki.garrysmod.com/page/CTakeDamageInfo/IsDamageType[/url]
[QUOTE=Robotboy655;46049275]I don't know why it does that, but this should be used: [url]http://wiki.garrysmod.com/page/CTakeDamageInfo/IsDamageType[/url][/QUOTE]
Does the job, thanks! Relatively new to lua so I'm learning. Made the thread because it was weird how it changed like that.
If I may ask, why IsDamageType() over GetDamageType()?
GetDamageType returns a bitflag number representing all the damagetypes in one number
IsDamageType checks whether that bitflag contains given damage type or not.
Sorry, you need to Log In to post a reply to this thread.