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