Hello everybody
I have simple question i hope some people can help so !!
What i need is :
I want when the player run the game connecting to the server and firstly check if they are room with name for ex “test” well if they are will get in the room “test” if they are not room with this name will create room with name “test”.
I try to do it before but i failed every time i hope i will find who can help me and thank you before .
You can simply try to join any room (with PhotonNetwork.joinRandomRoom) and if that fails you create a room named “test”.
Have a look at the Marco Polo Tutorial:
if there is already “test” room? Can he create another “test” room?
@alarm656 : The roomnames are the IDs of rooms. Each name exists only once per cluster and title version.
Means: A room “test” can exist for each AppId, region and gameversion.
I’m sorry Tobias, but how can I create rooms. I just need like this: Player1 connects to photon and creates room if there are no rooms, Player2 connects to photon and joined to the room which has been created by Player1. So the room is full (because I set maxPlayers to 2)
Now there is a new player Player3. Is Player3 will create a new room? because when I have used codes from “Sky Arena” my Player3 couldn’t created a new room. Unity Editor console says “The Room is Full”. Now I’m creating my own simple Photon Authentication and creating room code. There are no options, buttons in game like [Create Room], [Join Room]. Just only one [PLAY] button. When player pressed [PLAY] button it’s creates room if there are no rooms or joints if there is available rooms. My new code:
using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
public string roomName = "CannonBlast";
public static bool IsConnected
{
get
{
return PhotonNetwork.offlineMode == false && PhotonNetwork.connectionState == ConnectionState.Connected;
}
}
void Start ()
{
DontDestroyOnLoad( gameObject );
}
public void Connect()
{
if( PhotonNetwork.connectionState != ConnectionState.Disconnected )
{
return;
}
try
{
PhotonNetwork.ConnectUsingSettings( "1.0" );
PhotonNetwork.autoJoinLobby = true;
}
catch
{
Debug.LogWarning( "Couldn't connect to server" );
}
}
void OnJoinedLobby ()
{
RoomOptions roomOptions = new RoomOptions () { isVisible = true, maxPlayers = 2 };
PhotonNetwork.JoinOrCreateRoom (roomName, roomOptions, TypedLobby.Default);
Debug.Log ("OnJoinedLobby");
}
void OnJoinedRoom ()
{
Application.LoadLevel ("Room");
Debug.Log ("OnJoinedRoom");
}
}
Also I would like to know What is CCU? is CCU20 20 count of currently playing players? What can you say about this screens? Seems like I can create only one room? Dropbox
Operation failed: OperationResponse 226: ReturnCode: 32765 (Game full). Parameters: {} Server: MasterServer
UnityEngine.Debug:LogError(Object)
Player3 can’t create a new room:(
Seems like worked, Have changed code a little bit, but I’m not sure. I have to display all room to be 100% sure
PhotonNetwork.JoinOrCreateRoom (roomName + System.Guid.NewGuid().ToString("N"), roomOptions, TypedLobby.Default);
Got from here: How to create an online multiplayer game with Photon Unity Networking - Paladin Studios
string mapName = "test";
var allRooms = PhotonNetwork.GetRoomList();
var aviableRooms = allRooms.ToList().FindAll(f => f.MaxPlayers > f.PlayerCount && f.Name.Contains(mapName));
var connectedRoom = aviableRooms.FirstOrDefault();
if (connectedRoom != null)
{
PhotonNetwork.JoinOrCreateRoom(connectedRoom.Name, roomOptions, TypedLobby.Default);
}
else
{
PhotonNetwork.JoinOrCreateRoom(mapName + Guid.NewGuid().ToString("N"), roomOptions, TypedLobby.Default);
}

