garrysmod
garrysmod copied to clipboard
Add hook SANDBOX:ShouldHideTool to hide tools
Allow addons to hide tools from the tool menu. It is already possible to disallow the use of a tool by a player by means of the SANDBOX:CanTool hook, however, tools still remain visible in the tool menu.
Adding this hook would allow server owners who wish to restrict tool use to also hide these tools.
This feature is requested from the following thread: https://facepunch.com/showthread.php?t=1545453 Feature was also requested here: https://github.com/Facepunch/garrysmod-requests/issues/612
Example usage:
hook.Add( "ShouldHideTool", "TESTING", function( tool )
if ( tool.ItemName == "hoverball" ) then return true end
end)
You should probably pass the table and not just the name.
yeah... ditto @aStonedPenguin. would be a bit more helpful w/ the tool itself.
Done, Updated first post aswell
This is very useful especially for servers that wants to hide specific tools. Spawnmenu is hard to customize so this hook will definitely help.
However, hiding tools from spawnmenu doesn't prevent them from using. P.S. As mentioned in first message it can be used in conjunction with CanTool 👍
This is very useful especially for servers that wants to hide specific tools. Spawnmenu is hard to customize so this hook will definitely help.
Thanks, though this was suggested so long ago I almost had to remind myself what exactly I proposed. The change seemingly won't be implemented, so it might be worth checking dates in the future!
Best wishes
The same thing could be done for spawnmenu tabs.. 😞
EDIT: Someone did a pull request #1748 for spawnmenu tabs.
Good idea, add same to spawnmenu
This implementation does not have an effect live, which may be unwanted in case of things like hiding the tools/tabs for non admins only, which can happen mid game, not just on loading time.