Getting the class of a TTT weapon?

Trying to get the class of a weapon in TTT (vanilla weapons) and it only returns “player” when using


But whenever I get hit by a crowbar it shows weapon_zm_improvised and when I checked weapon_zm_improvised.lua I saw this:

function SWEP:GetClass()
	return "weapon_zm_improvised"

and decided to add the same to weapon_ttt_m16 but I still only get “player” when shot with the M16. Is there something else I’m missing?

EDIT: Doing more testing and when I check the weapons by Entity:IsWeapon() the weapon_zm_improvised is returned as a weapon while the other weapons are not.

I believe that’s just because the game is treating the inflictor as the player, not the gun they’re holding.

A simple workaround is this:

if wep:GetClass() == "player" then
 wep = wep:GetActiveWeapon()

which will accurately get the weapon the player is holding. I’ve yet to find a situation where this code doesn’t work as intended in TTT

Haha thanks, that works. I just figured this out before I saw your post. Solved.