Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlayerUse not returning any value causes use to never work. #3330

Open
ZehMatt opened this issue Nov 16, 2017 · 12 comments
Open

PlayerUse not returning any value causes use to never work. #3330

ZehMatt opened this issue Nov 16, 2017 · 12 comments

Comments

@ZehMatt
Copy link

ZehMatt commented Nov 16, 2017

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?

@robotboy655
Copy link
Contributor

Not exactly surprising, this also goes for any hook that does something when you return false.

@thegrb93
Copy link

thegrb93 commented Nov 17, 2017

Yeah it is surprising. Other hooks use default behavior when nil is returned. This one is using false instead of default.

@robotboy655
Copy link
Contributor

This behavior happens to all engine hooks that use false as a return to do something.

@thegrb93
Copy link

thegrb93 commented Nov 17, 2017

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

@ZehMatt
Copy link
Author

ZehMatt commented Nov 18, 2017

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.

@thegrb93
Copy link

thegrb93 commented Nov 19, 2017

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.

@ZehMatt
Copy link
Author

ZehMatt commented Nov 27, 2017

The engine should not use nil as false rather as undefined and should stick to the defaults whenever this happens.

@thegrb93
Copy link

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.

@robotboy655
Copy link
Contributor

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.

@Kefta
Copy link
Contributor

Kefta commented Jul 26, 2018

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.

@ZehMatt
Copy link
Author

ZehMatt commented Jul 27, 2018

I think this leaves a bigger trail of functions that needs this kind of fix, its not just PlayerUse

@robotboy655
Copy link
Contributor

I have put in a fix for this, no other hooks are affected yet, so leaving this open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants