How to keep disconnected players custom properties?

Hello @JohnTube

I am going to keep the player's custom property when he exited the application.
- Is this possible?
- To keep, what can I do?
- I only need the player's custom property for about 10 secs. Once I kept the player's custom property, after that can I delete the player's all custom property and the player object itself?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @sweetmei25,

    No, it's not possible. Player properties are removed when the actor is removed from the room's actors list.
    You can set PlayerTTL and EmptyRoomTTL to 10000 (10seconds) when creating rooms.
    And when you want a player to leave a room, call PhotonNetwork.LeaveRoom(true). This way actors will be kept for another 10 seconds after they disconnect from the room and their properties will remain as well.
  • Thank you very much! :smiley:
  • Hi @JohnTube
    Then PhotonNetwork.LeaveRoom(true) works in OnApplicationQuit function?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2019
    Technically if you don't call PhotonNetwork.LeaveRoom(true); the actor will be disconnected due to client timeout.
    But if you want to let the others know you disconnected ASAP, make sure to add a call to PhotonNetwork.SendAllOutgoingCommands();.
    void OnApplicationQuit()
    {
        PhotonNetwork.LeaveRoom(true);
        PhotonNetwork.SendAllOutgoingCommands();
    }
  • sweetmei25
    edited February 2019
    Hi @JohnTube

    If player1 called
    
    PhotonNetwork.LeaveRoom(true);
    PhotonNetwork.SendAllOutgoingCommands();
    
    PlayerTtl is set to 3000

    Then what is the method for the other players in the room that shows player1 is disconnected immediately?
    public override void OnPhotonPlayerDisconnected(PhotonPlayer player1)
    Above method called after 3 seconds, not immediately...
  • public override void OnPhotonPlayerActivityChanged(PhotonPlayer otherPlayer)
    {
    if (otherPlayer.IsInactive == true)
    {
    }
    }
    I think this will work...
  • this worked