GameServer Control Application

Joeeyyy

New member
Joined
Jun 20, 2007
Messages
2
Programming Experience
Beginner
Hey everyone, I'm new here so take it easy on me if I'm posting this in the wrong place. As you can see from the title, I'm making a GameServer Control Application, which basically just gives a user "almost" complete control over their game server. I'm mainly making this because in the next few months, I will be starting my own gameserver hosting company and I wanted to give users something they've never seen before from any other company. Up until the last part, everything is working. They can send rcon commands to the server, view their server status, view and change server variables, start and stop the server, even edit some of their user details such as password, e-mail, etc. The problem I'm having is that I can't figure out how to display the in-game console in my application.

The console basically display everything that's going on in the server. HLDS (Half-Life Dedicated Server) even gives the option to write logs of everything. Which is how I first tried to display the console in my app. I tried to open and read the log file and write it to the textbox. The only problem that came up is that, I got an error which stated that the log file was currently in use so my app couldn't open it. So, is there any way to open a file in a completely laid back read only way that my application can read the file WHILE hlds is writing it?

After I get a few responses for that, I'll post the other way of getting the log which is REALLY getting on my nerves... lol
 
I found out how to do what I wanted to do:

VB.NET:
    Private Sub ConsoleRead(ByVal engine As String)
        If engine = "HalfLife" Then
            Dim di As New IO.DirectoryInfo(My.Settings.directory & My.Settings.game & "\logs\")
            Dim aryFi As IO.FileInfo() = di.GetFiles("*.log")

            Array.Sort(aryFi, New CompareFileInfoEntries)

            Dim newestFile As FileInfo = aryFi(0)

            Dim finalFile As String = newestFile.ToString()

            Dim str As Stream = File.Open(My.Settings.directory & My.Settings.game & "\logs\" & finalFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
            Dim sr As StreamReader
            sr = New StreamReader(str)

            txtConsole.Text = sr.ReadToEnd

            sr.Close()
        End If

    End Sub

    Public Class CompareFileInfoEntries
        Implements IComparer
        Public Overridable Overloads Function Compare(ByVal file1 As Object, _
               ByVal file2 As Object) As Integer Implements IComparer.Compare
            Dim f1 As FileInfo = CType(file1, FileInfo)
            Dim f2 As FileInfo = CType(file2, FileInfo)

            Return -DateTime.Compare(f1.CreationTime, f2.CreationTime)
        End Function
    End Class

There ya go =D
 
Last edited:
Back
Top