LFA Posted March 12, 2010 Share Posted March 12, 2010 Just change the game id TCXXXXXXXXXXXX and run it on the master. To restart all empty game servers of all game types leave it like it is. <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...
trancemode Posted March 12, 2010 Share Posted March 12, 2010 thanks! would this restart server with HLTV or source TV ? Link to comment Share on other sites More sharing options...
Derek Posted March 12, 2010 Share Posted March 12, 2010 Nice Script Luis! On a side note is there a way where we can have it restart all game servers that are empty rather then just one game id ? Link to comment Share on other sites More sharing options...
LFA Posted March 12, 2010 Author Share Posted March 12, 2010 It can be used to restart any game. I updated the script so you can restart all games. Just leave the game id ="TCXXXXXXXXXXXX" There was also a script error that I fixed Link to comment Share on other sites More sharing options...
dimitrifrom31 Posted March 12, 2010 Share Posted March 12, 2010 It can be used to restart any game. I updated the script so you can restart all games. Just leave the game id ="TCXXXXXXXXXXXX" There was also a script error that I fixed what derek meant was "can it restart all empty game servers at once" with the condition they are empty i assume. However derek some games cant be queried so they would be considered as empty even if full. Maybe Luis can manage a way to include the condition "game has compatibility set" so it would restart ALL game servers that can be queried and that are empty. I tried to make such a script without chance but i might use it for other purposes. Link to comment Share on other sites More sharing options...
LFA Posted March 12, 2010 Author Share Posted March 12, 2010 what derek meant was "can it restart all empty game servers at once" with the condition they are empty i assume. However derek some games cant be queried so they would be considered as empty even if full. Maybe Luis can manage a way to include the condition "game has compatibility set" so it would restart ALL game servers that can be queried and that are empty. I tried to make such a script without chance but i might use it for other purposes. Yes that is what it does just leave the script as it is and it will restart all game servers of any game type that does not have any players. If the game does not have the game compatibility set it will fail and move to the next game server. It will not restart it. Link to comment Share on other sites More sharing options...
dimitrifrom31 Posted March 12, 2010 Share Posted March 12, 2010 Yes that is what it does just leave the script as it is and it will restart all game servers of any game type that does not have any players. If the game does not have the game compatibility set it will fail and move to the next game server. It will not restart it. oh good i didnt understand it this way the first time, very nice script then, ima use it. Link to comment Share on other sites More sharing options...
adamnp Posted March 13, 2010 Share Posted March 13, 2010 Cool, very useful script Link to comment Share on other sites More sharing options...
trancemode Posted March 13, 2010 Share Posted March 13, 2010 nice! ahha sorry im not sure if you missed my question ;P hiow about server with HLTV or sourcetv? does it skip it or restart it as well? thanks! have a great weekend guys Link to comment Share on other sites More sharing options...
LFA Posted March 13, 2010 Author Share Posted March 13, 2010 nice! ahha sorry im not sure if you missed my question ;P hiow about server with HLTV or sourcetv? does it skip it or restart it as well? thanks! have a great weekend guys It only restarts the main game. You will have to run another script with the HLTV game id. Link to comment Share on other sites More sharing options...
luboservers Posted March 13, 2010 Share Posted March 13, 2010 Nice, but i would add some sleep time between stopping, starting and going to the next server. Something like.... If activeplayers = 0 Then Console.WriteLine("Stopping...") service.Stop() [color="green"] ' Wait 2 seconds before starting it up again[/color] Threading.Thread.CurrentThread.Sleep(2000) Console.WriteLine("Starting...") service.Start() [color="green"] ' Wait 10 seconds before the next stop[/color] Threading.Thread.CurrentThread.Sleep(10000) End If Link to comment Share on other sites More sharing options...
ECF Posted March 14, 2010 Share Posted March 14, 2010 The stop delay is already set in the game configuration. Link to comment Share on other sites More sharing options...
agentpr24 Posted March 14, 2010 Share Posted March 14, 2010 Nice Script Luis, thanks for it :-) Link to comment Share on other sites More sharing options...
luboservers Posted March 14, 2010 Share Posted March 14, 2010 The stop delay is already set in the game configuration. Yep, but people usually don't pay too much attention to that option and leave it on 3 seconds, i always use 10 What can i cay, i'm a patient man Link to comment Share on other sites More sharing options...
ECF Posted March 14, 2010 Share Posted March 14, 2010 Most people usually don't change any of the default settings unless a problem arisies. But that is what the start delay setting is for Link to comment Share on other sites More sharing options...
Broseph Posted March 14, 2010 Share Posted March 14, 2010 Great script. Only thing that could make it better is if it changed the map to what it was before restart (unless it already does that and I missed it). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.