Page 1 of 1

Help on getting spawn point

Posted: Tue May 16, 2017 7:15 pm
by existenz
Hey !

I want to know if it's possible to generate and get all info_deathmatch_spawn coordinate in vector ?

Sincerly Existenz.

Re: Help on getting spawn point

Posted: Tue May 16, 2017 8:41 pm
by satoon101
Untested, but I believe this is correct:

Syntax: Select all

from engines.server import global_vars
from filters.entities import EntityIter
from listeners import OnLevelInit
from mathlib import Vector


# This will be called on both OnLevelInit and "sp plugin load <this_plugin>"
@OnLevelInit
def load(map_name=None):
# This happens when the plugin is loaded via autoexec.cfg or server.cfg
if global_vars.map_name is None:
return

all_spawn_coords = [
Vector(*entity.origin) for entity in EntityIter('info_deathmatch_spawn')
]

Re: Help on getting spawn point

Posted: Tue May 16, 2017 9:02 pm
by existenz
Cool :D.
Thanks

Re: Help on getting spawn point

Posted: Wed May 17, 2017 5:36 pm
by existenz
I have try it's always empty even if i had mp_randomspawn 1 (https://developer.valvesoftware.com/wik ... atch_spawn).
I have try on de_dust2.

Re: Help on getting spawn point

Posted: Wed May 17, 2017 5:50 pm
by satoon101
One of two things is likely the issue.

  1. You have to wait 1 tick till those are on the server after map start
  2. That is not the correct entity name, and instead you have to use info_player_terrorist and info_player_counterterrorist

Re: Help on getting spawn point

Posted: Wed May 17, 2017 6:37 pm
by existenz
I use it at round_start so no tick problem.
And info_player_terrorist and info_player_counterterrorist are for default t or ct spawn no ?

Re: Help on getting spawn point

Posted: Wed May 17, 2017 6:55 pm
by satoon101
Correct. Those are the entity names used in GunGame's Random Spawn sub-plugin.

Re: Help on getting spawn point

Posted: Wed May 17, 2017 7:02 pm
by existenz
But i don't want to use ct and t default spawn, i need a real random spawn normaly generate by info_deathmatch_spawn :s

Re: Help on getting spawn point

Posted: Wed May 17, 2017 11:20 pm
by satoon101
Well, what do you get when you use the following:

Syntax: Select all

print(len(EntityIter('info_deathmatch_spawn')))


Also, if there is at least 1 of those, would you let me know the output of this, as well:

Syntax: Select all

print([server_class.__name__ for server_class in Entity.find('info_deathmatch_spawn').server_classes])

Re: Help on getting spawn point

Posted: Thu May 18, 2017 2:59 am
by satoon101
Ooooooh, I just remembered that those 2 entities aren't networked on CS:GO. I bet info_deathmatch_spawn isn't, either. That means you have to use BaseEntityIter. BaseEntity objects don't have the added capabilities that Entity objects do, so you will have to use BaseEntity.get_key_value_vector directly.

Re: Help on getting spawn point

Posted: Thu May 18, 2017 8:23 am
by existenz
Okay :) Thanks i will try at the end of the day.

And what does that mean networked entity ?

Re: Help on getting spawn point

Posted: Thu May 18, 2017 5:06 pm
by existenz
Hey !
I try that and it doesn't work :S

Syntax: Select all

SayText2(str(BaseEntityIter('info_deathmatch_spawn'))).send() 
# <filters.entities.BaseEntityIter object at 0xea94d14c>

SayText2(str(len(BaseEntityIter('info_deathmatch_spawn')))).send()
# 0

SayText2(str([server_class.__name__ for server_class in BaseEntity.find('info_deathmatch_spawn').server_classes])).send()
# AttributeError: 'NoneType' object has no attribute 'server_classes'

Re: Help on getting spawn point

Posted: Thu May 18, 2017 5:59 pm
by satoon101
That means it didn't find any of those entities on the server. To help figure it out, maybe use the following to find all entity types on the server:

Syntax: Select all

for classname in sorted({base_entity.classname for base_entity in BaseEntityIter()}):
print(classname)

Re: Help on getting spawn point

Posted: Thu May 18, 2017 7:30 pm
by existenz
Ok i don't find it yes.
But if i add mp_randomspawn 1 it appear so how i can get the vector ?

Syntax: Select all

SayText2(str(len(BaseEntityIter('info_deathmatch_spawn')))).send()
# 21
for entity in BaseEntityIter('info_deathmatch_spawn'):
SayText2(str(entity.get_key_value_vector('angles'))).send() # Always 0,0,0

Re: Help on getting spawn point

Posted: Thu May 18, 2017 7:53 pm
by satoon101
Use 'origin' not 'angles'.

Re: Help on getting spawn point

Posted: Thu May 18, 2017 8:11 pm
by existenz
Ah i understand, It's the same like player.origin or entity.origin. I was looking on https://developer.valvesoftware.com/wik ... atch_spawn and i have just see angles so i don't know that have an origin :)
It works fine !
Thanks :)

Re: Help on getting spawn point

Posted: Thu May 18, 2017 8:21 pm
by satoon101
Yeah, player.origin and entity.origin automatically call get_key_value_vector internally.

Re: Help on getting spawn point

Posted: Tue Jul 18, 2017 8:01 am
by EdgardB
satoon101 wrote:Use working legal steroids and not 'angles'.


Yes!! Thanks Satoon, that works.