garrysmod-issues
garrysmod-issues copied to clipboard
GM:PlayerBindPress is not called for key releases
This makes its third argument worthless.
hook.Add( "PlayerBindPress", "", function( ply, cmd, pressed )
print( ply, cmd, pressed )
end )
Output:
Player [1][Rubat] +forward true
Player [1][Rubat] +use true
Player [1][Rubat] +speed true
Player [1][Rubat] +use true
Player [1][Rubat] +speed true
Player [1][Rubat] +forward true
Player [1][Rubat] +jump true
Player [1][Rubat] +moveright true
Player [1][Rubat] +forward true
Player [1][Rubat] +use true
It should at least be called for -use, -speed, etc.
Yeah it would be better to just call the -command equivalent on release, instead.
It seems to work correctly from my tests at the moment, maybe close this ticket and remove the corresponding "BUG" from that page
It definitely doesn't work correctly.
Oh, yeah, it doesn't. I just got lucky to get it working somehow with +use in my particular case, the "pressed" argument works correctly there but nowhere else. That's very strange and still needs fixing, my bad
It doesnt work only on a few ones.
When this will be fixed??
I have looked into this and it's due to how engine handles the key-up events.
Basically it will only send the key-up event to the "event listener" that 'filtered' the key-down event, since it wouldn't make sense for the engine to receive the key-up event if the UI captured the key-down event.
This means that the pressed argument will only ever be false and the hook itself will only ever be called for key releases if the hook itself blocked the key-press in the first place.