Garry's Mod

Garry's Mod

186 ratings
Addon hooks Conflict Finder
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Tool
File Size
Posted
Updated
0.003 MB
Jan 3, 2015 @ 5:00pm
May 9, 2016 @ 7:49am
12 Change Notes ( view )

Subscribe to download
Addon hooks Conflict Finder

In 5 collections by Michel CRÉMIER [GiletJaune]
Soccer by Mohamed RACHID
40 items
Université Joseph Poireau (serveur)
73 items
MR: Serveur Garry's Mod Jeu en 2D
11 items
Dev Tests Mohamed
52 items
G-1:788429
51 items
Description
Intro
This tool allows the developer or the technician to discover the name of the hook that overrides the result and stops the execution of a given event name.

Available on GitHub: Addon hooks Conflict Finder[github.com]

The problem
When an event is triggered, all the hooks (callbacks) added to it are executed in an unknown order. If the event name is listed here[wiki.garrysmod.com] then this event has a default behavior, probably that from the base gamemode. For user-created event names, the event is triggered manually.
If any hook returns a value then the event execution stops, so pending hooks are ignored as well as the default behavior. This can be correct, but some Lua coders make crap and accidentally stop the event execution list.
That is why this addon has been created! If you have dozens of addons but do not know where to search for the conflict, this addon will help. This addon does not use hooks so it will always work!

Notes
• Event names and hook names are case-sensitive!
• Because the table read order in Lua is unknown, if the failing addons work correctly right after you started the test then you may have to temporary disable the failing addons.
• This addon cannot work with event names that are not strings.
• This addon will not return a meaningful hook name if it is neither a string nor a number.

Step 1
At first, if you see an addon that obviously has an overridden behavior, look inside of the source code to find the event name. An overridden hook is never called.
-- In an addon, you will see this: hook.Add( "EventName", "HookName", ThatHookFunction ) -- In the gamemode, you will more likely find this: function GM:EventName( args ) -- Something to do after all hooks created with hook.Add() have been executed. end

Step 2
Once you get the hook that seems not to work, note the event name.
The command name is find_conflicts_hook_sv to find a hook conflict serverside, or find_conflicts_hook_cl clientside. Only superadmins can use it serverside.

To start the test, use this command:
find_conflicts_hook_sv "EventName"
To stop the test then, use this:
find_conflicts_hook_sv "EventName" 0

Step 3
The screen will display something like the following each time the specified event gets a hook that returns a value:
• for a value returned by a hook created with hook.Add():
Event "EventName", hook "HookName", returned: Arg #1 = table: 0x37e5a550
• for a value returned by the gamemode:
Event "EventName", GAMEMODE, returned: Arg #1 = table: 0x2c69db10

Step 4
Once you got the hook name that stops the event, you can look into the source code of your addons. The addon name is mostly already given in the reports.
Be sure that the selected hook has both the right EventName and the right HookName.
It is now up to you to correct / remove the addon that incorrectly stops the event!
If you can't find the involved addon, for example with Notepad++ (hotkey Ctrl+Shift+F) you can look into every *.lua and *.gma file in the garrysmod\addons folder (+subfolders) by searching for HookName.

Good luck!
< >
32 Comments
buddycat27 Mar 11 @ 3:13pm 
alright thanks!
Michel CRÉMIER [GiletJaune]  [author] Mar 11 @ 11:18am 
Yes, it can help that way, but only for hook conflicts as described and if you know the event name.
For the step 1, it is in files. The rest of the procedure assumes that you located the hook that does not work.
buddycat27 Mar 10 @ 2:31pm 
also do i ahve to go into the files of garrys mod or look at the console for step 1?
buddycat27 Mar 10 @ 2:21pm 
wait so will this help me if i am trying to find out which mod conflicts with another addon? or will this just help me with a single addon and conflict9ing strings of data in that single addon?
froggers Sep 25, 2020 @ 3:52pm 
alright, thank you for the information!
Michel CRÉMIER [GiletJaune]  [author] Sep 25, 2020 @ 3:47pm 
You are experiencing a script error. A script error is not a hook conflict as explained in the description of this add-on.

There is a conflict though, I see that the Sound() function was replaced with a string value.
My suggestion, to begin with, is to display the value of Sound . You can type in your console:
lua_run print('Sound =', Sound)
Maybe you will see a value that guides you to identify the guilty add-on.

Consider adding me on Discord if you need to share your screen or something.
froggers Sep 24, 2020 @ 10:28am 
disregard that shit is hella broken with like 50,000 lines of fucking moon runes
froggers Sep 24, 2020 @ 9:23am 
kind of a large month gap but, this is a good addon and i wanna find out how to find the conflicting hook.
froggers Sep 24, 2020 @ 9:16am 
i get how this is ment to work, but im just baffled for what i'm suppose to type. this is my issue

[Brutal Deaths] lua/autorun/server/death.lua:58: attempt to call global 'Sound' (a string value)
1. v - lua/autorun/server/death.lua:58
2. unknown - lua/includes/modules/hook.lua:84 (x2)

im unsure how to use the command properly, little help?
kapi Jul 17, 2020 @ 4:27pm 
nj