Author Topic: OnPlayerJoined  (Read 5530 times)

phoenix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 49
    • View Profile
OnPlayerJoined
« on: March 21, 2016, 07:49:30 PM »
Player 1 is the host and Player 2 is the client for a LAN connection.

Does OnPlayerJoined only get called on the host or does it sometimes get called on the client depending on network timing?
Because sometimes the host is reporting OnPlayerJoined and sometimes the client reports OnPlayerJoined and I do not understand this behavior.

Is it possible that the Player 1 host which creates the GameServer and then joins the GameServer becomes  the client because of the rare timing of Player 2 joining the GameServer first?
So that it does not matter that Player 1 created the GameServer?
How can I ensure that Player1 is the host?

Also, the list of players seems to only includes the other player so it is always 1 even though there are 2 players in the channel the host and the client.

Should the host and the client both be in the list of players and should they be the same on the host and client TNManager?



« Last Edit: March 21, 2016, 08:02:43 PM by phoenix »

TPMer

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: OnPlayerJoined
« Reply #1 on: March 23, 2016, 02:40:32 AM »
Sorry,Excuse me,Where I can download TNet 3.0 ,can you give me a link. Thank you!

phoenix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 49
    • View Profile
Re: OnPlayerJoined
« Reply #2 on: March 23, 2016, 11:24:00 AM »
To answer my own question:

OnPlayerJoined only gets called on the Host.

The Host is the first person to enter the channel.

The number of players is equal to everyone except the Host i.e. other players only.

Is their a way to make the Player who creates the GameServer the one to join the channel first so that that Player is always the Host?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnPlayerJoined
« Reply #3 on: March 24, 2016, 03:07:39 AM »
@phoenix: OnPlayerJoined gets called on every client that's in the channel when a new player joins.

I think you answered your own question there... The player that creates the game server can immediately join the channel -- this ensures that that player will be first. Also you can always check the player IDs. The player IDs always increment -- first player to connect to the server will have a lower ID than others.

@TPMer: It's sold on the Asset Store.