LFA Posted August 10, 2005 Share Posted August 10, 2005 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 More sharing options...
ECF Posted August 10, 2005 Share Posted August 10, 2005 Oh oh... I can see where this is going Link to comment Share on other sites More sharing options...
church Posted August 11, 2005 Share Posted August 11, 2005 He lies, all lies Link to comment Share on other sites More sharing options...
ChrisOlver Posted August 13, 2005 Share Posted August 13, 2005 Nice bit of code 2 questions mind A) If i put a users name who didnt exsist in the service owner what would happen? B) How would i create a new user and teamspeak with this also?? Link to comment Share on other sites More sharing options...
LFA Posted August 13, 2005 Author Share Posted August 13, 2005 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 More sharing options...
romatr Posted March 22, 2007 Share Posted March 22, 2007 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 More sharing options...
romatr Posted March 26, 2007 Share Posted March 26, 2007 Anybody here? Link to comment Share on other sites More sharing options...
LFA Posted March 26, 2007 Author Share Posted March 26, 2007 You need to set these properties: tcservice.ServiceID tcservice.Application tcservice.Arguments tcservice.AutomationFilesPath (this is the game server root folder) Link to comment Share on other sites More sharing options...
romatr Posted March 27, 2007 Share Posted March 27, 2007 Ok, thank you! Is the tcservice.ServiceID generates automaticaly or I need to assign some value for it? Link to comment Share on other sites More sharing options...
LFA Posted March 27, 2007 Author Share Posted March 27, 2007 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 More sharing options...
romatr Posted April 10, 2007 Share Posted April 10, 2007 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 More sharing options...
LFA Posted April 10, 2007 Author Share Posted April 10, 2007 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 More sharing options...
romatr Posted April 10, 2007 Share Posted April 10, 2007 Thank you very much for help LFA. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.