garrysmod icon indicating copy to clipboard operation
garrysmod copied to clipboard

Call GM:MouthMoveAnimation via hook library

Open cannon opened this issue 7 years ago • 7 comments

I think this should be a hook, so addons that control the mouth can work without overriding the gamemode function and screwing eachother up

cannon avatar Feb 05 '18 01:02 cannon

might as well do the same for GrabEarAnimation then too

yupi2 avatar Feb 05 '18 01:02 yupi2

This function is called pretty frequently, right? I wonder about the performance impact of doing work inside hooks for this function. Then again, if addons are already doing it, providing an official method likely wouldn't make things worse.

bmwalters avatar Feb 05 '18 01:02 bmwalters

Check out how the popcorn and vape sweps deal with this. The popcorn swep overrides the global gamemode function which is obviously prone to issues, should any other code override the function. The Vape swep has an ugly solution and may break with code refreshes.

cannon avatar Feb 05 '18 02:02 cannon

When calling a hook inside of a GAMEMODE function, you should use hook.Call and pass the current table (self in this case).

Kefta avatar Feb 05 '18 06:02 Kefta

It looks like the same mistake was already in the code by calling the GAMEMODE global.

yupi, I don't agree, as I don't think addons use it. That's very subjective though. bmwalters, I don't think the hook overhead is significant here.

cannon avatar Feb 07 '18 02:02 cannon

This would finally stop addon creators from overriding this.

mcNuggets1 avatar Feb 26 '18 11:02 mcNuggets1

how u dare using hooks in gamemode

ExtReMLapin avatar Mar 23 '18 20:03 ExtReMLapin