Visual Basic.NET - Remote Admin Console Works with CS, CSS, ET, RTCW, Q3, JK ++

This is something that I coded for my application ETTools.
image: etttooool1

This will allow a user to remotely connect to a game server using the IP, PORT and RCON PASSWORD. Once the user connects they will automatically query the server for the status.

The user can then send commands from the application to the remote server and receive the data as an output in txtOutput.Text.

This is a simple application to do, you can work out everything by the pic.


CODE
Imports System.IO
Imports System.Net
Public Class Form1
Inherits System.Windows.Forms.Form
Dim HostIp As String, Rcon As String, Port As String
Dim Command As String
Dim Say As String
Dim Kick As String, ClientKick As String
Dim strData As String



Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click
'error handle
On Error Resume Next

'we get the input
HostIp = txtHostIp.Text
Rcon = txtRcon.Text
Port = txtPort.Text

'here is the main part, we connect to the server
AxWinsock1.RemoteHost = HostIp
AxWinsock1.RemotePort = Port
AxWinsock1.Connect()

'we send the first command in the begging, being status. THe Chr(255) have to be there.
'This line just makes sure that we get the status automatically that is all.
AxWinsock1.SendData(Chr(255) & Chr(255) & Chr(255) & Chr(255) & "rcon " & Rcon & " " & "status")
End Sub

Private Sub btnQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuery.Click
Send("status")
End Sub


Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
'we store the text to variable
Say = txtCommand.Text
'send the command
Send(Say)
'and we clean up
txtCommand.Text = ""
'and prepare for new say message
txtCommand.Focus()
End Sub

Private Sub cmdKickClient_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdKickClient.Click
Kick = InputBox("Enter name of the player to be kicked: ")
Send("kick " & Kick)
End Sub

Private Sub cmdKickClientByID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdKickClientByID.Click
ClientKick = InputBox("Enter the client number of the player to be kicked: ")
Send("clientkick " & ClientKick)
End Sub
Private Sub txtcmd_KeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer)
'if we press enter in the command line textbox, we want to check if it is enter
If KeyCode = Keys.Enter Then
'and then execute the command
Command = txtCommand.Text
Send(Command)
txtCommand.Text = ""
End If
End Sub
Private Sub AxWinsock1_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles AxWinsock1.DataArrival
'the meat of the program
'when you send a command to server, it responds back and this is where it goes
On Error Resume Next

'we get the data
AxWinsock1.GetData(strData, vbString, 2000000)


'if user wishes to hide the funny names, colors and stuff
If cbHideColour.Checked = True Then
strData = Replace(strData, "^0", "")
strData = Replace(strData, "^1", "")
strData = Replace(strData, "^2", "")
strData = Replace(strData, "^3", "")
strData = Replace(strData, "^4", "")
strData = Replace(strData, "^5", "")
strData = Replace(strData, "^6", "")
strData = Replace(strData, "^7", "")
strData = Replace(strData, "^8", "")
strData = Replace(strData, "^9", "")
strData = Replace(strData, "^-", "")
strData = Replace(strData, "^=", "")
strData = Replace(strData, "^q", "")
strData = Replace(strData, "^w", "")
strData = Replace(strData, "^e", "")
strData = Replace(strData, "^r", "")
strData = Replace(strData, "^t", "")
strData = Replace(strData, "^y", "")
strData = Replace(strData, "^u", "")
strData = Replace(strData, "^i", "")
strData = Replace(strData, "^o", "")
strData = Replace(strData, "^p", "")
strData = Replace(strData, "^[", "")
strData = Replace(strData, "^]", "")
strData = Replace(strData, "^a", "")
strData = Replace(strData, "^s", "")
strData = Replace(strData, "^d", "")
strData = Replace(strData, "^f", "")
strData = Replace(strData, "^g", "")
strData = Replace(strData, "^h", "")
strData = Replace(strData, "^j", "")
strData = Replace(strData, "^k", "")
strData = Replace(strData, "^l", "")
strData = Replace(strData, "^;", "")
strData = Replace(strData, "^'", "")
strData = Replace(strData, "^#", "")
strData = Replace(strData, "^\", "")
strData = Replace(strData, "^z", "")
strData = Replace(strData, "^x", "")
strData = Replace(strData, "^c", "")
strData = Replace(strData, "^v", "")
strData = Replace(strData, "^b", "")
strData = Replace(strData, "^n", "")
strData = Replace(strData, "^m", "")
strData = Replace(strData, "^,", "")
strData = Replace(strData, "^.", "")
strData = Replace(strData, "^/", "")
strData = Replace(strData, "^!", "")
strData = Replace(strData, "^@", "")
strData = Replace(strData, "^£", "")
strData = Replace(strData, "^$", "")
strData = Replace(strData, "^%", "")
strData = Replace(strData, "^^", "")
strData = Replace(strData, "^&", "")
strData = Replace(strData, "^*", "")
strData = Replace(strData, "^(", "")
strData = Replace(strData, "^)", "")
strData = Replace(strData, "^_", "")
strData = Replace(strData, "^+", "")
strData = Replace(strData, "^{", "")
strData = Replace(strData, "^}", "")
strData = Replace(strData, "^:", "")
strData = Replace(strData, "^~", "")
strData = Replace(strData, "^|", "")
strData = Replace(strData, "^<", "")
strData = Replace(strData, "^>", "")
strData = Replace(strData, "^?", "")

End If


strData = Replace(strData, Chr(255) & Chr(255) & Chr(255) & Chr(255) & "print" & vbLf, "")
strData = Replace(strData, vbLf, vbCrLf)



'we Output the received filtered text!
txtOutput.Text = txtOutput.Text & vbCrLf & vbCrLf & strData

'we make sure the output window is at the end. The scroller is always in the end
txtOutput.Selectionstart = Len(txtOutput.Text)

End Sub

Sub Send(ByVal cmd As String)
'the send section. we call Send when we want to send something to the server and this does the
'trick
On Error Resume Next

AxWinsock1.SendData(Chr(255) & Chr(255) & Chr(255) & Chr(255) & "rcon " & Rcon & " " & cmd)
End Sub



End Class

/ CODE
Comments
1
not any tutorial at all just a wall of code
Back to top