Author Topic: HowTo Setup dedicated Gameserver?  (Read 1689 times)

Rexima

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 2
  • Posts: 78
    • View Profile
HowTo Setup dedicated Gameserver?
« on: February 01, 2014, 02:44:34 PM »
Hello,

i want to setup some fixed dedicated Gameserver. Should i setup a lobby and register gameserver to it, and after i did this, i can see the server in my serverlist?
Or should register channels in the gameserver? If its so, how can i setup fixed channels?

//EDIT: Ok, i got how to setup fixed channels.

Here a small snippet, i hope it's ok.

  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. using TNet;
  5.  
  6. public class CreateFixedChannel : MonoBehaviour {
  7.  
  8.         // Use this for initialization
  9.         void Start () {
  10.         TNManager.Connect("YOUR IP", YOUR PORT);
  11.         }
  12.  
  13.     private string channelname ="";
  14.     private string channelmaxplayer = "8";
  15.     private string channelpw = "";
  16.  
  17.     void OnGUI()
  18.     {
  19.         if (TNManager.isConnected)
  20.         {
  21.             GUI.Label(new Rect(20, 20, 100, 50), "Channelname:");
  22.             channelname = GUI.TextField(new Rect(120, 20, 200, 20),channelname);
  23.  
  24.             GUI.Label(new Rect(20, 50, 100, 50), "Max Player:");
  25.             channelmaxplayer = GUI.TextField(new Rect(120, 50, 200, 20), channelmaxplayer);
  26.  
  27.             GUI.Label(new Rect(20, 80, 100, 50), "Passwort:");
  28.             channelpw = GUI.TextField(new Rect(120, 80, 200, 20), channelpw);
  29.  
  30.  
  31.             if (GUILayout.Button("Create Channel"))
  32.             {
  33.                 TNManager.CreateChannel(channelname, true, Convert.ToInt32(channelmaxplayer), channelpw);
  34.                
  35.             }
  36.         }
  37.     }
  38. }
  39.  

« Last Edit: February 01, 2014, 03:02:57 PM by Rexima »

Katalyst

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: HowTo Setup dedicated Gameserver?
« Reply #1 on: February 01, 2014, 04:02:47 PM »
Depends on what your objective is. If you want multiple GameServers, like if they are located in different locations around the world for latency purposes, then you'll want a lobby server to register those with so they can be accessed.

If you want just a single GameServer and then you want users to make channels instead, then you don't need a lobby server. You can either edit the TNServer.sln file how you want or just do what I did and make a .bat (batch) file containing
Quote
tnserver.exe -name "GAMESERVER NAME HERE" -tcp 5129

When you don't specify that it is a lobby server, it defaults to a GameServer. Just place that batch file next to your tnserver.exe and then run it.

As for your posted code, there is one problem. Where you have TNManager.CreateChannel and give it "channelname", its supposed to be the name of the Scene you want to load with the creation of the channel, not the name of the channel. A channel name is tracked separately when your Updating the channel list data.