Skip to content

Commit 99c29f3

Browse files
authored
Update _base.py
Added Player.get/set_active_weapon and added a setter method to Player.active_weapon property.
1 parent 9271488 commit 99c29f3

File tree

1 file changed

+10
-2
lines changed
  • addons/source-python/packages/source-python/players

1 file changed

+10
-2
lines changed

addons/source-python/packages/source-python/players/_base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,7 @@ def secondary(self):
723723
"""
724724
return self.get_weapon(is_filters='secondary')
725725

726-
@property
727-
def active_weapon(self):
726+
def get_active_weapon(self):
728727
"""Return the player's active weapon.
729728
730729
:return: None if the player does not have an active weapon.
@@ -737,6 +736,15 @@ def active_weapon(self):
737736

738737
return Weapon(index)
739738

739+
def set_active_weapon(self, weapon):
740+
"""Set the player's active weapon.
741+
742+
:param Weapon weapon: The weapon to set as active.
743+
"""
744+
self.active_weapon_handle = weapon.inthandle
745+
746+
active_weapon = property(get_active_weapon, set_active_weapon)
747+
740748
def get_weapon(self, classname=None, is_filters=None, not_filters=None):
741749
"""Return the first found weapon for the given arguments.
742750

0 commit comments

Comments
 (0)