[CS:S] Forcing players fire weapon when they are secondaries
Posted: Mon Aug 21, 2023 5:36 pm
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:
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