Skip to content

Commit 1237596

Browse files
author
L'In20Cible
committed
Added checks into Player.spawn to make sure the player is respawnable before performing the spawn (can be forced with force=True).
1 parent 00f88cc commit 1237596

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,18 @@ def play_sound(
692692
# Play the sound to the player...
693693
sound.play(self.index)
694694

695+
def spawn(self, force=False):
696+
"""Spawn the player.
697+
698+
:param bool force: Whether or not the spawn should be forced.
699+
"""
700+
# Is the player spawnable?
701+
if not force and (self.team <= 1 or not self.dead):
702+
return
703+
704+
# Spawn the player...
705+
super().spawn()
706+
695707
# =========================================================================
696708
# >> PLAYER WEAPON FUNCTIONALITY
697709
# =========================================================================

addons/source-python/packages/source-python/players/engines/csgo/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,16 @@ def set_projectile_ammo(self, projectile, value):
140140
value,
141141
)
142142

143-
def spawn(self):
144-
"""Spawn the player."""
143+
def spawn(self, force=False):
144+
"""Spawn the player.
145+
146+
:param bool force: Whether or not the spawn should be forced.
147+
"""
148+
# Is the player spawnable?
149+
if not force and (self.team <= 1 or not self.dead):
150+
return
151+
152+
# Spawn the player...
145153
self._spawn()
146154

147155
def set_color(self, color):

addons/source-python/packages/source-python/players/engines/orangebox/cstrike.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# Source.Python Imports
99
# Engines
1010
from engines.server import engine_server
11+
# Entities
12+
from entities.entity import BaseEntity
1113
# Filters
1214
from filters.entities import EntityIter
1315
# Memory
@@ -38,11 +40,19 @@ def has_c4(self):
3840
# If no c4 is owned by the player, return False
3941
return False
4042

41-
def spawn(self):
42-
"""Spawn the player."""
43+
def spawn(self, force=False):
44+
"""Spawn the player.
45+
46+
:param bool force: Whether or not the spawn should be forced.
47+
"""
48+
# Is the player spawnable?
49+
if not force and (self.team <= 1 or not self.dead):
50+
return
51+
52+
# Spawn the player...
4353
self.player_state = 0
4454
self.life_state = LifeState.ALIVE
45-
super().spawn()
55+
BaseEntity.spawn(self)
4656

4757

4858
# =============================================================================

0 commit comments

Comments
 (0)