Author Topic: Cant clear channel data after player exit  (Read 1839 times)

krvc

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 16
    • View Profile
Cant clear channel data after player exit
« on: January 12, 2017, 12:43:08 PM »
hi. my players sometimes write data on channel. (example tno.isMine TNManager.SetChannelData("info", +1);)
i cant find good way how clear it. (players lose connection or use alt+f4 to exit from game)

1.  i create empty "sample object" and write data to it. (TNManager.Instantiate FALSE)
then players off - object destroy, and i use code in Destroy() void - every players send ("info", -1) - wrong result.....

2. i added if tno.isMine - sometimes clear info, sometimes no... (players lose connection or use alt+f4 to exit from game)

3. okay i create new object (TNManager.Instantiate TRUE) for ONE player - its my virtual host. it player clear data other players.
yes, now data others players clear a good. Then player a leave object change owner to next player, object have tno.isMine
and clear data for One player, but sometimes its clearing data for new Owner too...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Cant clear channel data after player exit
« Reply #1 on: January 13, 2017, 10:54:00 PM »
SetChannelData("info", null);

Note that tno.isMine is the wrong check here. Channel data can only be set by the channel's host. You should be checking for TNManager.IsHosting(tno.channelID);