How to create several spawnpoints without spawning at the same place in Photon

Hello,

yes I know there’s a similar question to this already, but it’s not the same question, because I’m trying to spawn players at several spawnpoints and not objects.

So this is my code:

using System.Collections.Generic;

public Transform[] spawns;
public int amountThings = 2;
public int i = 0;

void Start()
{
    Connect();
}

void Connect ()
{
    PhotonNetwork.ConnectUsingSettings(verNum);
    Debug.Log("Connecting...");
}

public void spawnPlayer()
{
    List<Transform> freeSpawnPoints = new List<Transform>(spawns);

        int index = Random.Range(0, freeSpawnPoints.Count);
        for (i = 0; i < amountThings; i++)
        {
            if (freeSpawnPoints.Count <= 0)

                Debug.LogError("Not enough spawnpoints!!!!!!!!!");

            Transform pos = freeSpawnPoints[index];

            freeSpawnPoints.RemoveAt(index); // remove the spawnpoint from our temporary list
            GameObject pl = PhotonNetwork.Instantiate(playerPref.name, pos.position, pos.rotation, 0) as GameObject;

            pl.GetComponent<RigidbodyFPSWalker>().enabled = true;
            pl.GetComponent<RigidbodyFPSWalker>().fpsCam.SetActive(true);

            RigidbodyFPSWalker.speed = 10.0f;
            SimpleSmoothMouseLook.disabled = false;

            pl.GetComponent<Animations>().enabled = true;
        }
 }

The players are still spawning at the same place.
Every player should has an own spawn place.

So I think, that the list of the spawnpoints must be synchronized to the other players.
How can I synchronize it to the others?

I’ll be very happy about an helpful answer.
Thank you for reading.

With the logic above you have to synchronize the original structure (‘spawns’). So whenever a player spawn you remove one entry from the copy created within the spawnPlayer() function. You need to apply this change to the original structure too and share this event with all others active and upcoming players. since this seems somehow too complicated I want to make another suggestion you might think about.

In short: Master Clients sets spawn position for himself and all upcoming players.
In detail: Master Client creates a structure containing all available spawn points at the beginning. When OnJoinedRoom() is called he selects one of these points, creates his character from prefab and removes the spawn point entry from the list. Most likely before.
Whenever OnPhotonPlayerConnected(…) is called (another players joined the room) the Master Client selects another spawn position and stores it in the custom room properties as key-value-pair (e.g. userId and spawn position). OnPhotonCustomRoomPropertiesChanged(…) will be called and the client can check the spawn position allocated to his userId.

However, when going with this attempt (Master Clients selects spawn positions for other players), there are additional options for solving this problem.

So now I have this code and my question is how do I get values from the Hashtable for a specific player?:

public void OnPhotonPlayerConnected()
    {
        DebugConsole.Log("Player " + PhotonNetwork.player.name + " joined.");

        if (PhotonNetwork.isMasterClient) 
        {
            List<Transform> freeSpawnPoints = new List<Transform>(spawns);
            int index = Random.Range(0, freeSpawnPoints.Count);
            Transform pos = freeSpawnPoints[index];

            Hashtable t = new Hashtable();
            t.Add("Player", PhotonNetwork.player.name);
            t.Add("Location", pos);

            PhotonNetwork.room.SetCustomProperties(t);
        }
        else
        {
             RoomOptions roomOptions = new RoomOptions();
             string pos = (string) PhotonNetwork.room.customProperties[RoomProperty.Location]; <-- ??????????
             spawnPlayer(pos);
        }
    }

public void OnJoinedRoom()
{
    isConnected = true;

    if (PhotonNetwork.isMasterClient)
    {
        List<Transform> freeSpawnPoints = new List<Transform>(spawns);
        int index = Random.Range(0, freeSpawnPoints.Count);
        DebugConsole.Log("SpawnPoints: " + freeSpawnPoints.Count);
        DebugConsole.Log("index: " + index);

        if (freeSpawnPoints.Count <= 0)
        {
            DebugConsole.Log("Not enough spawnpoints!!!!!!!!!", "error");
        }
        else
        {
            Transform pos = freeSpawnPoints[index];
            DebugConsole.Log("Pos: " + pos + pos.position + pos.rotation);
            freeSpawnPoints.RemoveAt(index);
            spawnPlayer(pos);
        }
    }
}

@ChristianSimon