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

1

9

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 ?

Doralynn answered 5/8, 2016 at 13:2 Comment(0)
H
2

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.

Harvester answered 10/8, 2016 at 23:3 Comment(1)
thanks for your answer. If I replace C0 with the playerNames isn't it available for those players. I don't get the logic I think. How sql type blocked those players.Apathy

© 2022 - 2024 — McMap. All rights reserved.