JohnTube mod

About

Username
JohnTube
Joined
Visits
4,023
Last Active
Roles
Registered, Moderator
Points
480
Badges
20
  • Re: Will OnDisconnected From Photon callback be executed when a player exits the game ?

    Hi @rokugatsu,

    Just to avoid any confusion or misunderstanding.

    void OnDisconnectedFromPhoton()
    Will be called when the local client is disconnected from all Photon servers but the app is still open.
    This happens after unexpected disconnect (another callback should be called first) or if you call PhotonNetwork.Disconnect().
    If you just exit the game nothing will be called.

    What do you mean by "unplay"?
    Do you mean stop playing from Unity Editor?

    In this case, the callback will not be called as well.
  • Re: Best practices for "reserve slot leftovers"? +Clarifications?

    Hi @xblade724,

    1. yes the room is full unless you remove the reserved slot(s) of the player(s) who left.
    2. no. but you can do it manually.
    3. manually as it depends on your game logic. check snippet below.
    4. no. also depends on game logic. you can add it manually as well.

    Talk is cheap, here is the code:

        public void AddExpectedUser(string userId)
        {
            if (string.IsNullOrEmpty(userId))
            {
                return;
            }
            if (!PhotonNetwork.inRoom)
            {
                return;
            }
            if (null != PhotonNetwork.room.ExpectedUsers && PhotonNetwork.room.ExpectedUsers.Contains(userId))
            {
                return;
            }
            List<string> list = new List<string>(PhotonNetwork.room.ExpectedUsers);
            list.Add(userId);
            PhotonNetwork.room.SetExpectedUsers(list.ToArray());
        }
    
        public void RemoveExpectedUser(string userId)
        {
            if (string.IsNullOrEmpty(userId))
            {
                return;
            }
            if (!PhotonNetwork.inRoom)
            {
                return;
            }
            if (null == PhotonNetwork.room.ExpectedUsers || !PhotonNetwork.room.ExpectedUsers.Contains(userId))
            {
                return;
            }
            List<string> list = new List<string>(PhotonNetwork.room.ExpectedUsers);
            list.Remove(userId);
            PhotonNetwork.room.SetExpectedUsers(list.ToArray());
        }
        
  • Re: Having troubles handling pre-game room disconnections with TTL (to reconnect in-game)

    Hi @xblade724,

    It's not supported out of the box yet.
    Try this code (not tested yet):
    using Hashtable = ExitGames.Client.Photon.Hashtable;
    
    // [...]
    
    public static bool UpdateTTLs(int playerTTL, int emptyRoomTTL)
        {
            Hashtable hash = new Hashtable(2);
            hash.Add((byte)246, playerTTL);
            hash.Add((byte)245, emptyRoomTTL);
            return PhotonNetwork.networkingPeer.OpSetPropertiesOfRoom(hash);
        }
  • Re: OnUpdatedFriendList => No UserId?

    Hi @xblade724,

    Thank you for reporting this!
    Yes indeed the Name is the UserId in fact it is not returned by server but cached on client from the list you provide in FindFriends.

    Any reason it's called Name instead of UserId?
    "Historical" reasons! "UserId" is a concept we now enforce (it is a must, even if you do not explicitly set one the server does this for you) and is relatively new in Photon. "NickName"/"Nickname" should be the new naming for the old "UserName"/"Username" or "PlayerName"/"Playername" or "Name".
    We will change this in future versions ("Name" to "UserId").
  • Re: PhotonNetwork.GetRoomsList() Not working (autojoinlobby is on, waited for onJoinedLobby)

    Hi @xblade724,

    Rooms list is ready after calls to PUN callback OnReceivedRoomListUpdate(). You can get the rooms list inside that callback.
    Also I assume these rooms are in default lobby or in a lobby with default type.