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?
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?
0
Comments
-
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, callPhotonNetwork.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.0 -
Thank you very much!0
-
Hi @JohnTube
Then PhotonNetwork.LeaveRoom(true) works in OnApplicationQuit function?0 -
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 toPhotonNetwork.SendAllOutgoingCommands();
.void OnApplicationQuit() { PhotonNetwork.LeaveRoom(true); PhotonNetwork.SendAllOutgoingCommands(); }
1 -
Hi @JohnTube
If player1 calledPhotonNetwork.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...
0 -
public override void OnPhotonPlayerActivityChanged(PhotonPlayer otherPlayer) { if (otherPlayer.IsInactive == true) { } }
I think this will work...0 -
this worked0