This is the bit of code that does work, and set the spawn location (but will spawn you inside blocks)
- Code: Select all
def get_spawn_location(connection):
if connection.team is connection.protocol.blue_team:
x, y, z = ServerConnection.get_spawn_location(connection)
r = random.randrange(1, 5)
if r == 1:
return (77, 365, 52)
elif r == 2:
return (93, 350, 46)
elif r == 3:
return (287, 369, 52)
elif r == 4:
return (295, 391, 52)
elif r == 5:
return (67, 146, 62)
Then I try to use set_spawn_safe formatted like this:
- Code: Select all
if connection.team is connection.protocol.green_team:
x, y, z = ServerConnection.get_spawn_location(connection)
r = random.randrange(1, 5)
if r == 1:
return ServerConnection.set_location_safe(connection, (399, 88, 52))
elif r == 2:
return ServerConnection.set_location_safe(connection, (407, 103, 48))
elif r == 3:
return ServerConnection.set_location_safe(connection, (399, 284, 52))
elif r == 4:
return ServerConnection.set_location_safe(connection, (309, 229, 52))
elif r == 5:
return ServerConnection.set_location_safe(connection, (102, 27, 62))
And it never spawns the players (just a floating view of the map, and I cannot close the game, change weapons, or change teams.)
So I tried the example given (here) using coords that I know are correct.
- Code: Select all
def get_spawn_location(connection):
if connection.team is connection.protocol.blue_team:
x, y, z = ServerConnection.get_spawn_location(connection)
return ServerConnection.set_location_safe(connection, (399, 88, 52))
if connection.team is connection.protocol.green_team:
x, y, z = ServerConnection.get_spawn_location(connection)
return ServerConnection.set_location_safe(connection, (399, 88, 52))
and it gives the same result, just a floating view of the map, and nothing your can do.
I can't seem to figure out what I am doing wrong? I would like to use the random range method so I could have multiple spawn points, but with safe spawn so you don't end up in a wall or tree.
Edit:
change set_spawn_safe to set_location_safe (after trying it)