Forcing a user cmd on a player at any time?

Please post any questions about developing your plugin here. Please use the search function before posting!
inf
Junior Member
Posts: 20
Joined: Mon Aug 07, 2017 2:46 am

Forcing a user cmd on a player at any time?

Postby inf » Thu Nov 23, 2017 9:07 pm

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?
inf
Junior Member
Posts: 20
Joined: Mon Aug 07, 2017 2:46 am

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

Postby inf » Thu Nov 23, 2017 9:12 pm

I now see that OnPlayerRunCommand calls even if the player isn't moving. I guess this could work, unless someone has a better solution.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

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

Postby Ayuto » Thu Nov 23, 2017 9:17 pm

Yep, OnPlayerRunCommand is the only possibility.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

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

Postby L'In20Cible » Thu Nov 23, 2017 9:43 pm

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.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 38 guests