Spawn Points Problem
Posted: Fri Mar 31, 2017 4:27 pm
by decompile
Hey,
I currently have written a Spawn Points Plugin which simply extends the spawn points for each class based on max clients of the server.
Im calling it during 'round_start' event. It does completly its job (len(entityiter..), but when I try to add lets say a bot, to figure out if it works, it tells me the game is full, even if just 1 player is in the team. (1 spawnpoint for each class).
Do I need to call the spawn point creation somewhere earlier, or why does the game not realise it has more spawn points available.
Re: Spawn Points Problem
Posted: Fri Mar 31, 2017 10:38 pm
by satoon101
We would probably need to see your code to be able to replicate and help. Also, which game are you testing this on?
Re: Spawn Points Problem
Posted: Sat Apr 01, 2017 8:32 am
by decompile
Syntax: Select all
MAX_CLIENTS = global_vars.max_clients
@Event("round_start")
def round_start(mapName):
spawn_classes = ["info_player_counterterrorist", "info_player_terrorist"]
spawn_points = GetNumByClass(spawn_classes)
print(spawn_points)
if MAX_CLIENTS > spawn_points:
additional_spawn_points = int((MAX_CLIENTS - spawn_points) / 2)
CreateSpawnForClass(spawn_classes, additional_spawn_points)
def GetNumByClass(spawn_classes):
spawn_points = len(EntityIter(spawn_classes))
return spawn_points
def CreateSpawnForClass(spawn_classes, additional_spawn_points):
for spawn_class in spawn_classes:
spawn_entity = Entity.find(spawn_class)
if not spawn_entity:
continue
spawn_class_origin = spawn_entity.origin
for i in range(additional_spawn_points):
new_spawn_entity = Entity.create(spawn_class)
new_spawn_entity.origin = spawn_class_origin
new_spawn_entity.spawn()
CS:S
Re: Spawn Points Problem
Posted: Sun Apr 02, 2017 3:11 pm
by satoon101
I'm pretty sure that your issue is because
round_start fires AFTER
player_spawn. You could always try to spawn players that are on a team but dead on
round_start.
Though, I am not sure why you are doing this every single round. I think you would be better off waiting 1 tick after the map loads to accomplish this.
Syntax: Select all
from engines.server import global_vars
from listeners import OnLevelInit
from listeners.tick import Delay
# Call this function "load" so that it gets called the first time if loaded after the level has started
@OnLevelInit
def load(map_name=None):
Delay(0, get_needed_spawn_points)
def get_needed_spawn_points():
...