Open ZehMatt opened 6 years ago
Not exactly surprising, this also goes for any hook that does something when you return false.
Yeah it is surprising. Other hooks use default behavior when nil is returned. This one is using false instead of default.
This behavior happens to all engine hooks that use false as a return to do something.
Ok, then it seems the problem is your gamemode doesn't have a PlayerUse hook or it's returning false.
It should be using this if your hooks don't return anything. https://github.com/Facepunch/garrysmod/blob/master/garrysmod/gamemodes/base/gamemode/player.lua#L126
I'm not exactly having issues because now I know I have to actually return true or false and not nil. I just wanted to bring up the issue since its a little weird and easy to miss. Those hooks should consider nil to use defaulted values imho.
The default is nil which is equivalent to false in an if statement. If you want the default to be true when your hooks return nil then you need GM:PlayerUse to return true.
The engine should not use nil as false rather as undefined and should stick to the defaults whenever this happens.
You can have nil default to true by using the gamemode hook like I mentioned earlier. Don't bother asking to change how the engine works because I doubt that'll ever change.
It's definitely a problem with the game/engine and needs fixing as far as I can tell, just not for the next update, because it needs a lot of testing for those addons that rely on this behavior.
Could this be implemented for the next update so we have time to test? I honestly don't think it will affect anything since PlayerUse already returns true in the base gamemode by default.
I think this leaves a bigger trail of functions that needs this kind of fix, its not just PlayerUse
I have put in a fix for this, no other hooks are affected yet, so leaving this open.
Details
As the title suggests, not returning specifically true won't allow the player to have +use. Probably better to only disable it if something returns false?