Alternative for my custom spawn points?

Hey Yall, so I’m currently creating custom spawn points for my game mode.
The first version, I created codes for each specefic player in each slot and it did work fine. However it was too much and added way to much codes considering I would’ve had to do it for each specific map, so i did a different way
The second version now is just one code with 12 teleport players in each slot actions
Along with an has spawned condition, however the problem is that if a player happened to join and spawn mid game, all the players will be teleported to the position again and that can be quite annoying at times, especially if players constantly join and spawn.
Can someone assist me on another alternative. If you would like to see the code feel free to ask for my game code.

rule 1: ongoing - each player

condition:
- has spawned(event player) == true

action:
- skip if(compare(team of(event player), !=, team(team 1)), 1)
- teleport(event player, value in array(global variable(T), slot of(event player)))
- teleport(event player, value in array(global variable(S), slot of(event player)))

You just need to set up the arrays on variable T and S to contain all the spawn positions. If its a teambased mode you have 2 arrays with 6 positions, if its DM one is enough.

Ok kinda confused on how I’m supposed to go about that. Since it is dm you did say one so, What i was gonna do was create a global variable and set it to be a vector position, but there is going to be multiple spawns so how would I go about that

Create an array. Put one vector for each spawn in it. In my example the array is on the variable T (and S, but in DM you only need T) and I made it that way, that each individual player has its own spawn (by using slot of(event player) as the index).
If you want to decide on wich position the players spawn in a different way, you can for example use these:

Random:
teleport(event player, random value in array(global variable(T)))

Cycle through:
teleport(event player, first of(global variable(T)))
set player variable(event player, Z, first of(global variable(T)))
modify global variable(T, remove from array(first of(global variable(T))))
modify global variable(T, append to array(player variable(event player, Z)))

Do you know how to work with arrays in workshop?

I have some experience with working with arrays. I was just doing some codes with arrays not too long ago

Good. I hope this will work for you then.

1 Like

After testing multiple times nothing seems to work, here’s the code if you want to see what I’m doing wrong. NJE24

The problem is that that the global variable T is used for something else in this gamemode. So its likely that it get overwritten with something that is not a valid vector. In my example I just used T because “Teleport”, you know.
So in order to make it work you need to replace the “T” with any variable that is not used yet.

Alright I see the problem now. It’s working and I wanna thank you for the help!

1 Like