Page 1 of 1

Can we make player jump with source python?

Posted: Mon Jul 12, 2021 2:46 pm
by khaimovmr
So, basically, the subject.
I need to trigger player jump at one moment with some forward velocity.
Did some of you guys do somethingn like this?

Re: Can we make player jump with source python?

Posted: Mon Jul 12, 2021 2:49 pm
by Speed0x
just search the forums for it. i think there a many topics about it.

Re: Can we make player jump with source python?

Posted: Mon Jul 12, 2021 2:51 pm
by khaimovmr
Speed0x wrote:just search the forums for it. i think there a many topics about it.

Did it. No luck so far.

Re: Can we make player jump with source python?

Posted: Mon Jul 12, 2021 3:31 pm
by Speed0x
look for onplayerruncommand for forcing the jump.
depending on what you want to with the velocity you could inject into the Event('player_jump').

i think this post can be useful or you can give more info on what exactly you want to be done.
viewtopic.php?f=7&t=2113&p=14350&hilit=velocity#p14350

Re: Can we make player jump with source python?

Posted: Mon Jul 12, 2021 3:57 pm
by Ayuto
Yes, you can either inject the jump button in PlayerRunCommand (maybe Player.buttons works as well) or emulate a jump e. g. by using Player.push.

Re: Can we make player jump with source python?

Posted: Fri Jul 16, 2021 8:41 am
by khaimovmr
That's absolutely insane, guys! Thank you. Will try on this weekend.

Re: Can we make player jump with source python?

Posted: Thu Jul 13, 2023 6:48 pm
by AncientOnes
In case anyone comes across this topic, this worked for me in TF2:

Syntax: Select all

from players.constants import PlayerButtons


def force_buttons(player, buttons, time=0.25):
"""Forces the given buttons on the given player for the given time."""
# Save the current forced buttons
forced_buttons = player.get_datamap_property_int('m_afButtonForced')

# Apply the given buttons
player.set_datamap_property_int('m_afButtonForced', forced_buttons | buttons)

# Restore the original buttons after the given time
player.delay(
time,
player.set_datamap_property_int,
('m_afButtonForced', forced_buttons))


force_buttons(player, PlayerButtons.JUMP)