A way to trigger +attack player command

All other Source.Python topics and issues.
User avatar
khaimovmr
Member
Posts: 52
Joined: Fri Aug 25, 2017 3:15 am
Contact:

A way to trigger +attack player command

Postby khaimovmr » Thu Aug 12, 2021 9:52 am

Hi, guys... struggling with a player grenade throw triggering on the server side.
Do somebody know is there a way to trigger the attack with player's active weapon?
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: A way to trigger +attack player command

Postby L'In20Cible » Thu Aug 12, 2021 10:06 am

Syntax: Select all

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)
)

from players.entity import Player
from players.constants import PlayerButtons

player = Player(1)
force_buttons(player, PlayerButtons.ATTACK)
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: A way to trigger +attack player command

Postby Ayuto » Thu Aug 12, 2021 11:02 am

If that works, we should add that to the Player class. That's really cool!
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: A way to trigger +attack player command

Postby L'In20Cible » Thu Aug 12, 2021 11:40 pm

Ayuto wrote:If that works, we should add that to the Player class. That's really cool!

Not sure if it work on all games, but it works on CS:S. Though, while it work for forcing a single attack, it will cause issues if the given time is greater than the next attack. Many buttons cannot be forced as well, such as movements, and others cause replication issues because that property isn't networked and only forced server-side causing a lot of flickering and whatnot due to client prediction.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 39 guests