Page 1 of 1

[CS:S] Forcing players fire weapon when they are secondaries

Posted: Mon Aug 21, 2023 5:36 pm
by cssbestrpg
Hi, i have got an issue with OnPlayerRunCommand, when i try to force player fire his weapon secondary, but it only fires it once and doesn't work anymore. Its suppose to keep firing the weapon, but if i change code to fire only primaries it works fine without any issues, so do you have any clue why it won't work properly on secondarys?

Here is the code:

Syntax: Select all

from players.constants import PlayerButtons
from filters.weapons import WeaponClassIter
from listeners import OnPlayerRunCommand

secondaries = [weapon.name for weapon in WeaponClassIter(is_filters='pistol')]

@OnPlayerRunCommand
def on_player_run_command(player, user_cmd):
if player.dead:
return
if player.is_bot():
return

weapon = player.get_active_weapon()
if weapon is None:
return

classname = weapon.classname
if classname in secondaries:
user_cmd.buttons |= PlayerButtons.ATTACK

Re: [CS:S] Forcing players fire weapon when they are secondaries

Posted: Tue Aug 22, 2023 4:50 am
by L'In20Cible
It does not work because pistols are not automatic so the attack button must be released before it can shoot again.

Syntax: Select all

if user_cmd.buttons & PlayerButtons.ATTACK:
user_cmd.buttons &= ~PlayerButtons.ATTACK
else:
user_cmd.buttons |= PlayerButtons.ATTACK