Facepunch / garrysmod-issues

Garry's Mod issue tracker
143 stars 56 forks source link

CMoveData:KeyPressed(IN_USE) in SetupMove always return false on server realm when trying to use items #4616

Open DBotThePony opened 4 years ago

DBotThePony commented 4 years ago

But it does work as expected on clientside.

Steps to reproduce:

  1. Spawn item_healthcharger/item_suitcharger/other "usable" entity (like sent_ball)
  2. Run
    
    hook.Add('SetupMove', 'testkeypressed', function(self, cmovedata)
    if cmovedata:KeyPressed(IN_USE) then
        print('Ding! SetupMove', CurTime(), IsFirstTimePredicted())
    end
    end)

hook.Add('Move', 'testkeypressed', function(self, cmovedata) if cmovedata:KeyPressed(IN_USE) then print('Ding! Move', CurTime(), IsFirstTimePredicted()) end end)

2. 
Server realm:
`<nothing>`
Client realm:

Ding! SetupMove 2679.8100585938 true Ding! Move 2679.8100585938 true Ding! SetupMove 2679.8100585938 false Ding! Move 2679.8100585938 false

3. Do the same while not facing any entity:
Server realm:
![browser_Xlrfb9wIas](https://user-images.githubusercontent.com/6339511/89164820-c9c80000-d5a1-11ea-8f2b-32473a229ce9.png)
Client realm:

Ding! SetupMove 2794.8298339844 true Ding! Move 2794.8298339844 true Ding! SetupMove 2794.8298339844 false Ding! Move 2794.8298339844 false

robotboy655 commented 4 years ago

This is done by GMod on purpose, but I don't know what it was trying to solve. The comment is "debounce the use key", but I can't find any scenario where there are problems without this code.

Actually this is done on purpose in base Half Life 2 as well.

Kefta commented 4 years ago

Sounds like it should be removed and restored before the item's Use is called were this to be fixed, but I don't even think that's necessary as item's don't manually check IN_USE.