Page 1 of 1

Forcing a user cmd on a player at any time?

Posted: Thu Nov 23, 2017 9:07 pm
by inf
How would I go about forcing a user cmd on a player? For example to force a player to +jump. I know you can change the buttons in a user_cmd in an OnPlayerRunCommand listener to force a player to press a button but how about at any given time?

Re: Forcing a user cmd on a player at any time?

Posted: Thu Nov 23, 2017 9:12 pm
by inf
I now see that OnPlayerRunCommand calls even if the player isn't moving. I guess this could work, unless someone has a better solution.

Re: Forcing a user cmd on a player at any time?

Posted: Thu Nov 23, 2017 9:17 pm
by Ayuto
Yep, OnPlayerRunCommand is the only possibility.

Re: Forcing a user cmd on a player at any time?

Posted: Thu Nov 23, 2017 9:43 pm
by L'In20Cible
You could also use the m_afButtonForced property. For example:

Syntax: Select all

player.set_property_int('m_afButtonForced', PlayerButtons.JUMP)

Would force the player to jump. However, keep in mind that this property is not networked to clients so any button that requires client prediction won't work as intended (for instance, forcing +duck will duck the player on the server but the player's view won't be correctly offseted in his screen, etc.). So yes, depending of what buttons you want to force, OnPlayerRunCommand is the only networked way, like Ayuto said.