attack1 Posted October 5, 2010 Share Posted October 5, 2010 Does anyone have or can anyone help me with a script to restart a game(s) say every 12 hours? CS1.6 is the game I want to restart. I am no coder before a couple of you guys give me a flip answer. I am asking for legitimate help here. Thank you in advance. Link to comment Share on other sites More sharing options...
dimitrifrom31 Posted October 5, 2010 Share Posted October 5, 2010 <tcascript> <language name="VB" /> <waitForUserAction value="true"/> <scriptCode><![CDATA[ Imports System Imports TCAdminSDK.Objects Public Class RestartGameServers Public Shared Sub Main() 'Set the game id to restart dim GameID as string = "TCXXXXXXXXXXXX" 'Get a list of all services Dim services() As Service = Service.GetServices() for each s as Service in services If s.CurrentStatus = ServiceStatus.Running and s.GameId.Equals(GameID) Then Console.WriteLine("Restarting " & s.ServiceID) s.Stop() Threading.Thread.CurrentThread.Sleep(1000) s.Start() 'Wait a few seconds before restarting the 'next service to avoid high loads on server Threading.Thread.CurrentThread.Sleep(10000) End If next Console.WriteLine("Done. Press any key to continue.") End Sub End Class ]]></scriptCode> </tcascript> Put that in a restart.tcascript file on your master server (just create a new .txt file, copy/paste and finally rename your file), replace TCXXXXXXXXXXXX by your GAME TCA ID and use task scheduler to run it every 12 hours. if it deosnt seem to work create a .bat with contents : restart.tcascript and set the task scheduler to run the bat every 12 hours Edit : in advanced properties set it so it "stops the task if already running" Link to comment Share on other sites More sharing options...
trancemode Posted October 6, 2010 Share Posted October 6, 2010 does this restarts empty servers or just all servers no matter what activity is going on? Link to comment Share on other sites More sharing options...
attack1 Posted October 6, 2010 Author Share Posted October 6, 2010 tyvm dimitrifrom31 Link to comment Share on other sites More sharing options...
dimitrifrom31 Posted October 6, 2010 Share Posted October 6, 2010 does this restarts empty servers or just all servers no matter what activity is going on? thsi restart no matter what. to restart empty ones : <tcascript> <language name="VB" /> <waitForUserAction value="true"/> <scriptCode><![CDATA[ Imports System Public Class Collector Public Shared Sub Main() Dim gameid As String = "TCXXXXXXXXXXXX" Dim services() As TCAdminSDK.Objects.Service = TCAdminSDK.Objects.Service.GetServices() If Not services Is Nothing Then For Each service As TCAdminSDK.Objects.Service In services Try If service.GameID = gameid Or gameid = "TCXXXXXXXXXXXX" Then If service.CurrentStatus = TCAdminSDK.Objects.ServiceStatus.Running Then Dim gswPlugin As TCAdminBase.Plugins.IGenericPlugIn = TCAdminSDK.Remote.InstanceCreator.GetPluginFromServer(service.ServerID, "TCAdmin.Plugins.GameStats.ServerPlugin", "TCAdmin.Plugins.GameStats") Dim xmldata As String = gswPlugin.Execute(New Object() {"GetGameServerStatus", service.ServerIP, service.ServerQueryPort, service.GameID, service.ServiceID}) If Not xmldata Is Nothing Then Dim ds As New System.Data.DataSet Dim stream As New System.IO.StringReader(xmldata) ds.ReadXml(stream) stream.Close() If ds.Tables.Count = 0 Then Console.WriteLine("No results were returned: {0}", service.UniqueDisplayNameWithOwner) Else Dim activeplayers As Integer = ds.Tables(0).Rows(0).Item("Active Players") Console.WriteLine("{0} has {1} active players.", service.UniqueDisplayNameWithOwner, activeplayers) If activeplayers = 0 Then Console.WriteLine("Stopping...") service.Stop() Console.WriteLine("Starting...") service.Start() End If End If Else Console.WriteLine("No results were returned: {0}", service.UniqueDisplayNameWithOwner) End If Else Console.WriteLine("{0} is not running", service.UniqueDisplayNameWithOwner) End If End If Catch ex As Exception Console.WriteLine("Error checking {0}: {1}", service.UniqueDisplayNameWithOwner, ex.ToString()) End Try Next End If Console.WriteLine("Done.") End Sub End Class ]]></scriptCode> </tcascript> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.