Author Topic: Stopping a user from becoming host if none exists.  (Read 3181 times)

Scobbo

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Stopping a user from becoming host if none exists.
« on: June 10, 2013, 12:18:56 AM »
Hello,
Thanks Aren for this great package, works a treat. However I can't figure out how I am supposed to stop players from becoming host if the server is down. Basically I will be hosting a small persistant server and players will join that. However I believe with the TNAutoJoin script if it can't find a "Host" client it will make itself host. Is there anyway that I can force this to stop.

Cheers!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Stopping a user from becoming host if none exists.
« Reply #1 on: June 10, 2013, 02:40:53 AM »
There must always be at least one "host" per channel. It's just an authoritative player who will be running AI and physics for everyone else. You can't have a channel without a host.

If a server is down, auto join script won't work. Failure function will be broadcast instead.

Scobbo

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Stopping a user from becoming host if none exists.
« Reply #2 on: June 10, 2013, 03:35:37 AM »
Thanks for your reply. What I mean is, if the server application is running but the game client that I will be setting as a host is down I don't want players to make their own hosts. I want only my server to be able to host and other players can only join instead of hosting.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Stopping a user from becoming host if none exists.
« Reply #3 on: June 10, 2013, 01:58:36 PM »
Then you should have this logic on the client side. If a player that you designated as host disconnects, leave the channel.

Scobbo

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Stopping a user from becoming host if none exists.
« Reply #4 on: June 11, 2013, 05:56:46 AM »
Ok I have had a look around, I can't see where it says that if there is not host make itself host. Which script is that in?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Stopping a user from becoming host if none exists.
« Reply #5 on: June 11, 2013, 12:51:08 PM »
Host transfer is done on the server side via TNGameServer.SendSetHost function.

If you want the channel to be closed after the host leaves, you'd want to modify TNGameServer.SendLeaveChannel function, line 645:
  1. if (ch.host == null) SendSetHost(ch.players[0]);
However as I mentioned you can just do this on the client side as well. Clients should get only one SetHost message. If a second one arrives, it means the original host left, so disconnect.