So, I’m trying to mod TTT. One of the things I want to do is make ironsights be actual ironsights, however, the viewmodel animations on the M16 and USP are weird, so I need to set a timer on them to return them to the idle animation. I do remove the timers in the standard deploy function, but it still sometimes acts weird, especially in things with non-standard deploy functions like the crowbar. I think a better way to do it would be to simply check that the current weapon is the same as the one that set the timer, but for some reason self:GetWeapon() or self:GetWeapons() returns null. However, according to the Gmod wiki, they should be functions. Anyone have any ideas about how to do it instead?
If you are coding a swep then self will refer to the swep. GetWeapons and GetActiveWeapon exist on players, not sweps.
[lua]local ply = self:GetOwner()
local holding = ply:GetActiveWeapon()[/lua]
Thank you! I got it now.