Jump to content

Create a game server from script


LFA

Recommended Posts

The following script will create a game server based on the values you specify. Look under "CONFIGURATION" for details.

 

Requires TCAdmin Build build 1.0.2047.860 or greater.

 

 

<tcascript>
<language name="VB" />
<waitForUserAction value="true"/>
<scriptCode><![CDATA[

Imports System

Public Class Test
   Public Shared Sub Main()
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' CONFIGURATION '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set the email where the creation or error email will be sent (an admin email account)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim NotifyEmail As String = "you@yourdomain"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set the ID of the user that will own the game server
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       Dim UserID As String = "ADMIN"
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set the ID of the game you are creating
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       Dim GameID As String = "TC1205673628476"
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set the ID of the server where the game server will be created
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim ServerID As String = "MasterServer"
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set the IP that the new game server will use. [Auto] is for automatic.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim ServerIP as String = "[Auto]"
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set if the game server will be private (True or False)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim IsPrivate as Boolean = False
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set the number of slots the game server will have
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Slots as Integer = 8
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set the game server's host name
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim HostName as String = "Game Server"
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set the game server's RCON password
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim RCONPassword as String = "rconpassword"
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set the game server's private password (if private)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim PrivatePassword as String = ""
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set if the game server will only use default ports (True or False)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim OnlyUseDefaultPorts as Boolean = False
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set if the game server will interact with the desktop (True or False)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim InteractWithDesktop as Boolean = False
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       '' Set if the game server should be started after creation (True or False)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim StartAfterCreation as Boolean = False
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim NewGameServerInfo As TCAdminSDK.Remote.Plugins.GSAutomation.GameServerCreationInfo

NewGameServerInfo.AdminNotificationEmail = NotifyEmail

NewGameServerInfo.Owner = UserID
NewGameServerInfo.GameID = GameID
NewGameServerInfo.ServerID = ServerID	
NewGameServerInfo.ServerIP = ServerIP
NewGameServerInfo.IsPrivate = IsPrivate
NewGameServerInfo.Slots = Slots

       NewGameServerInfo.HostName = HostName
       NewGameServerInfo.RCONPassword = RCONPassword
       NewGameServerInfo.PrivatePassword = PrivatePassword

NewGameServerInfo.OnlyUseDefaultPorts = OnlyUseDefaultPorts
       NewGameServerInfo.InteractWithDesktop = InteractWithDesktop
       NewGameServerInfo.StartAfterCreation = StartAfterCreation

NewGameServerInfo.SendNewUserNotificationEmail = False

       Dim ServiceID As String
Console.WriteLine("Creating Game Server...")
       If TCAdminSDK.Remote.Plugins.GSAutomation.CreateGameServerWithWait(NewGameServerInfo, ServiceID) Then
	Console.WriteLine("ID of new Game Server: " & ServiceID)
Else
	Console.WriteLine("Error!")
End If
   End Sub
End Class
]]>
</scriptCode>
</tcascript>

Link to comment
Share on other sites

To create a voice server along with the game server see the sdk documentation for

 

TCAdminSDK.Remote.Plugins.GSAutomation.GameServerCreationInfo

 

and

 

TCAdminSDK.Remote.Plugins.GSAutomation.VoiceServerCreationInfo

 

 

 

you will have to create a variable of type VoiceServerCreationInfo and assign it to the VoiceServerInfo property in your GameServerCreationInfo variable.

 

 

 

Same thing for game switching, except that the variable is an array since you can specify more than one game server for switching.

 

 

 

If you assign a user that doesn't exist it will probably not give an error but your server will be assigned to a user that doesn't exist.

 

 

 

To create a new user you would have to do something like this:

 

 

 

Dim newuser as new TCAdminSDK.Objects.User
newuser.userID = "NewUserID"
newuser.FirstName = "user's first name"
newuser.LastName = "user's last name"
newuser.Email1 = "noob@aol.com"
newuser.Type = TCAdminSDK.Objects.UserType.User
newuser.Save()

 

 

 

There are alot more properties you can set for a user. Check the sdk documentation for TCAdminSDK.Objects.User

Link to comment
Share on other sites

  • 1 year later...

Hello!

How about creating new game service not server. currently I'm trying to use next code:

TCAdminSDK.Objects.Service tcService = new TCAdminSDK.Objects.Service();

tcService.DisplayName = DisplayName;
tcService.ServerID      = "MasterServer";
tcService.GameID       = GameID
tcService.Slots           = Slots;
tcService.ServerIP      = ServerIP;
tcService.ServerPort    = ServerPort;
tcService.ServerQueryPort  = ServerQueryPort;
tcService.ServerRCONPort   = ServerRCONPort;
tcService.WorkingDirectory = WorkingDirectory;
tcService.UserFilePath     = UserFilePath;
tcService.StartupType      = TCAdminSDK.Objects.ServiceStartup.Manual;
tcService.UserID           = UserID; 

tcService.Save();

 

But I alway get error: Object reference not set to an instance of an object at tcService.Save(); code line

Link to comment
Share on other sites

You need to generate a random id. You can do it like this:

Dim svctemp As New TCAdminSDK.Objects.Service
Do
 svctemp.ServiceID = "TC" & TCAdminSDK.Web.Util.RandomNumber(23)
Loop While svctemp.Find

TCService.ServiceID= svctemp.ServiceID

Link to comment
Share on other sites

  • 2 weeks later...

Yet one little question.

 

When I create service through API it has status as 'Unknown' in TCAmind control panel. And when I try to start this service it show me error like "Cannot open TC74867003676138714548814 service on computer '.'." Then I do update from TCAdmin CP without any fields changing and this service status become 'Stoped'. Now I can start service without problem.

 

Can you explain me what operation should I do to set service status 'Stoped' once service created.

 

Thank you.

Link to comment
Share on other sites

If you are using the script on the first page it should install the service automatically. If you are creating the game server manually you have to execute the function service.Install() after sevice.Save().

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use