Spawn Points Problem

Please post any questions about developing your plugin here. Please use the search function before posting!
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Spawn Points Problem

Postby decompile » Fri Mar 31, 2017 4:27 pm

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.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Spawn Points Problem

Postby satoon101 » Fri Mar 31, 2017 10:38 pm

We would probably need to see your code to be able to replicate and help. Also, which game are you testing this on?
Image
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: Spawn Points Problem

Postby decompile » Sat Apr 01, 2017 8:32 am

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
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Spawn Points Problem

Postby satoon101 » Sun Apr 02, 2017 3:11 pm

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():
...
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 20 guests