Author Topic: TNManager.players does not include self?  (Read 3856 times)

Voxel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
TNManager.players does not include self?
« on: July 08, 2013, 04:10:01 PM »
Hi,

From what I can see TNManager.players does not include the client. I want to use TNPlayer for scores etc and I was just going to use the data in TNManager.players to populate the scoreboard during play. The client is also a player so I am confused. Do I just fill in the gap with TNManager.player.score for example? Or is there another way that I am unaware of?

Also is there a built in way to notify other players of a change in any of my custom data in the Player Class such as a change in score, or should I just send the details using tno.Send to the other clients?

Thanks.
« Last Edit: July 08, 2013, 05:29:22 PM by Voxel »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNManager.players does not include self?
« Reply #1 on: July 08, 2013, 10:56:15 PM »
You should use tno.Send. And your assumption is correct -- player list only includes other players. It's basically for "who else is in this channel?"

riomoko

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: TNManager.players does not include self?
« Reply #2 on: November 10, 2014, 02:49:46 PM »
There is a way to receive the complete list of the player including client?

Or an example for managing score?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNManager.players does not include self?
« Reply #3 on: November 10, 2014, 11:16:07 PM »
Your player will never be a part of the TNManager.players list, but everyone else will be. If you want to include yourself in there, simply consider TNManager.player as a part of the list.

riomoko

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: TNManager.players does not include self?
« Reply #4 on: November 11, 2014, 03:02:52 AM »
I see, there are some elegant example how manage score, or manage object characteristics for example how assign a material from an array to cars in a race game without duplicate material?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNManager.players does not include self?
« Reply #5 on: November 12, 2014, 08:05:03 AM »
Send the index of that material. You won't be able to sell a reference across the network as each client will have a completely different and unrelated value.

riomoko

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: TNManager.players does not include self?
« Reply #6 on: November 12, 2014, 09:56:56 AM »
I try to explain better:
In a gamemanager object the scene not created I have an array of x material and another empty int array where store the client id to the related material
I create a tnet object .if I'm the owner I choose random a material (and checking on the client array is not already taken), the put  the owner player id in the client array.
now I send the index of the material and the index of the client they assign material and fill the client array with the related client id so everybody in the net have the same relation material-> cliend id

and it should work

the question is: how avoid two client choosing the same material at the same time?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNManager.players does not include self?
« Reply #7 on: November 14, 2014, 05:13:37 AM »
Don't let each client do it. Route everything through the channel's host. Instead of simply calling an RFC like tno.Send("SetMaterial", Target.All, ...), do a request instead: tno.Send("RequestSetMaterial", Target.Host, ...). Inside this RequestSetMaterial, which is guaranteed to be executed only on one client, check -- is the material already taken by someone else? If so, send some RFC that says "choice invalid". Otherwise proceed to tno.Send("SetMaterial", Target.All, ...).

riomoko

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: TNManager.players does not include self?
« Reply #8 on: November 15, 2014, 10:15:31 AM »
Thanks Resolved, now host assign material under a client request