Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I block a specific user in random match making by using Photon Engine ?

We are making random match making game by using Photon engine. We want to match players with different users in a certain amount of time. If PlayerA plays with PlayerB they cannot play again for 30 minutes. What is the best way of doing this kind of system ?

We try some algorithms but it doesn't fit well.

public override void OnJoinedRoom()
{
    if(PhotonNetwork.isMasterClient) 
        StartCoroutine("StartWaiting");

    theSameGame = false;

    var photonPlayer =  PhotonNetwork.Instantiate("PhotonPlayerKO", Vector3.zero, Quaternion.identity, 0) as GameObject;
    photonPlayer.name = "Local Player";


    if(PhotonNetwork.playerList.Count() > 1 && !PhotonNetwork.isMasterClient)
        photonViewOfManager.RPC("MyNameIs", PhotonTargets.Others, PlayerInfos.thePlayersName);
    //Sending player name to other player to check whether this name is playable or not ?

    if(!PhotonNetwork.isMasterClient)
        StartCoroutine("CheckError");



}

It works but there are some disadvantages such as time consuming vs.. Any ideas for better solutions ?

like image 711
Çağatay Kaya Avatar asked Aug 05 '16 13:08

Çağatay Kaya


People also ask

Which is better UNet or photon?

UNet knows the scene and has physics running in the host. This is good for checking hits, areas where you can move, etc. Photon uses dedicated servers. It shares them for many rooms and does not run physics or anything Unity related.

How do I join a random room in photon?

Getting into a room to play with (or against) someone is very easy with Photon. There are basically three approaches: Either tell the server to find a matching room, follow a friend into her room, or fetch a list of rooms to let the user pick one.

What is Photon Unity Networking?

Photon Unity Networking (PUN) is a Unity package for multiplayer games. Flexible matchmaking gets your players into rooms where objects can be synced over the network. RPCs, Custom Properties or "low level" Photon events are just some of the features.


1 Answers

Solution can be found here: documentation

You need to use SQL Lobby Type:

Creating room:

    RoomOptions roomOptions = new RoomOptions();
    roomOptions.MaxPlayers = expectedMaxPlayers;
   // in this example, C0 might be 0 or 1 for the two (fictional) game modes
    roomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", 1 } };
    roomOptions.customRoomPropertiesForLobby = new string[] { "C0" }; // this makes "C0" available in the lobby
    // let's create this room in SqlLobby "myLobby" explicitly
    TypedLobby sqlLobby = new TypedLobby("myLobby", LobbyType.SqlLobby);
    lbClient.OpCreateRoom(roomName, roomOptions, sqlLobby);

Joining room:

TypedLobby sqlLobby = new TypedLobby("myLobby", LobbyType.SqlLobby);    // same as above
string sqlLobbyFilter = "C0 = 0";   // find a game with mode 0
lbClient.OpJoinRandomRoom(null, expectedMaxPlayers, matchmakingMode, sqlLobby, sqlLobbyFilter);
// more filter variations:
// "C0 = 1 AND C2 > 50"
// "C5 = \"Map2\" AND C2 > 10 AND C2 < 20"

In your case you just need to replace C0 with list of the players who are blocked, and updated this list every time new user plays the game, and removes him from the list after 30 minutes.

If you will face some other issues with that, let us know.

like image 146
Adam Roszyk Avatar answered Oct 18 '22 21:10

Adam Roszyk