Can we make player jump with source python?

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
khaimovmr
Member
Posts: 52
Joined: Fri Aug 25, 2017 3:15 am
Contact:

Can we make player jump with source python?

Postby khaimovmr » Mon Jul 12, 2021 2:46 pm

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?
Last edited by khaimovmr on Mon Jul 12, 2021 2:49 pm, edited 1 time in total.
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: Can we make player jump with source python?

Postby Speed0x » Mon Jul 12, 2021 2:49 pm

just search the forums for it. i think there a many topics about it.
User avatar
khaimovmr
Member
Posts: 52
Joined: Fri Aug 25, 2017 3:15 am
Contact:

Re: Can we make player jump with source python?

Postby khaimovmr » Mon Jul 12, 2021 2:51 pm

Speed0x wrote:just search the forums for it. i think there a many topics about it.

Did it. No luck so far.
Speed0x
Member
Posts: 84
Joined: Sun Feb 05, 2017 4:55 pm

Re: Can we make player jump with source python?

Postby Speed0x » Mon Jul 12, 2021 3:31 pm

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
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Can we make player jump with source python?

Postby Ayuto » Mon Jul 12, 2021 3:57 pm

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.
User avatar
khaimovmr
Member
Posts: 52
Joined: Fri Aug 25, 2017 3:15 am
Contact:

Re: Can we make player jump with source python?

Postby khaimovmr » Fri Jul 16, 2021 8:41 am

That's absolutely insane, guys! Thank you. Will try on this weekend.
AncientOnes
Junior Member
Posts: 4
Joined: Thu Jul 13, 2023 6:33 pm

Re: Can we make player jump with source python?

Postby AncientOnes » Thu Jul 13, 2023 6:48 pm

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)

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 44 guests