garrysmod icon indicating copy to clipboard operation
garrysmod copied to clipboard

Add hook SANDBOX:ShouldHideTool to hide tools

Open jamesrswift opened this issue 8 years ago • 9 comments
trafficstars

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)

jamesrswift avatar Dec 16 '16 21:12 jamesrswift

You should probably pass the table and not just the name.

aStonePenguin avatar Dec 17 '16 00:12 aStonePenguin

yeah... ditto @aStonedPenguin. would be a bit more helpful w/ the tool itself.

SpencerSharkey avatar Dec 17 '16 01:12 SpencerSharkey

Done, Updated first post aswell

jamesrswift avatar Dec 17 '16 13:12 jamesrswift

This is very useful especially for servers that wants to hide specific tools. Spawnmenu is hard to customize so this hook will definitely help.

GitSparTV avatar Oct 02 '20 17:10 GitSparTV

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 👍

GitSparTV avatar Oct 02 '20 17:10 GitSparTV

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

jamesrswift avatar Oct 02 '20 17:10 jamesrswift

The same thing could be done for spawnmenu tabs.. 😞

EDIT: Someone did a pull request #1748 for spawnmenu tabs.

FlorianLeChat avatar Oct 09 '20 16:10 FlorianLeChat

Good idea, add same to spawnmenu

REALalphas avatar Jan 04 '21 20:01 REALalphas

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.

robotboy655 avatar Jan 05 '21 18:01 robotboy655