Skip to content

Commit 3817074

Browse files
authored
Overloaded Weapon.remove() to properly remove the weapon if a player is carrying it
1 parent cf93be5 commit 3817074

File tree

1 file changed

+12
-0
lines changed
  • addons/source-python/packages/source-python/weapons

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,15 @@ def set_secondary_fire_ammo(self, value):
156156
def weapon_name(self):
157157
"""Return the full class name of the weapon."""
158158
return self.classname
159+
160+
def remove(self):
161+
"""Remove the weapon."""
162+
# Avoid a cyclic import
163+
from players.entity import Player
164+
165+
owner = self.owner
166+
if owner is not None and owner.is_player():
167+
player = Player(owner.index)
168+
player.drop_weapon(self)
169+
170+
super().remove()

0 commit comments

Comments
 (0)