Advertisement
Guest User

Grex RCON Tool

a guest
Apr 30th, 2011
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Software developped by Grex - sa-rl.de
  2. 'It's a RCON Tool for SAMP to administrate your SAMP-Server outside the game.
  3. 'This Software is free, changes on this program only for yourself. No release without my assent.
  4. 'Programm can be downloaded on http://files.sa-rl.de
  5.  
  6.  
  7. Public Class Main
  8.     Sub rcon(ByVal cmd)
  9.         If checksettings() = True Then
  10.             txtPort.Text = CInt(txtPort.Text)
  11.             Dim udpClient As New System.Net.Sockets.UdpClient
  12.             udpClient.Connect(txtIP.Text, txtPort.Text)
  13.  
  14.             Dim newip() As String = Split(txtIP.Text, ".")
  15.             Dim paket As String
  16.             Dim newport, newrcon, newcmd As Integer
  17.             newport = txtPort.Text / 2 ^ 8
  18.             newrcon = txtRCON.TextLength / 2 ^ 8
  19.             newcmd = Len(cmd) / 2 ^ 8
  20.  
  21.             paket = "SAMP" & Chr(newip(0)) & Chr(newip(1)) & Chr(newip(2)) & Chr(newip(3))
  22.             paket = paket & Chr(CByte(txtPort.Text Mod 256)) & Chr(CByte(newport Mod 256))
  23.             paket = paket & "x" & Chr(CByte(txtRCON.TextLength Mod 256)) & Chr(CByte(newrcon Mod 256)) & txtRCON.Text
  24.             paket = paket & Chr(CByte(Len(cmd) Mod 256)) & Chr(CByte(newcmd Mod 256)) & cmd
  25.             Dim sendBytes As [Byte]() = System.Text.Encoding.ASCII.GetBytes(paket)
  26.             udpClient.Send(sendBytes, sendBytes.Length)
  27.             udpClient.Close()
  28.             MsgBox("Befehl erfolgreich gesendet")
  29.         End If
  30.     End Sub
  31.     Public Function IsValidIP(ByVal addr As String) As Boolean
  32.         Dim pattern As String = "^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\." & _
  33.         "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$"
  34.         Dim check As New System.Text.RegularExpressions.Regex(pattern)
  35.         Dim valid As Boolean = False
  36.         If addr = "" Then
  37.             valid = False
  38.         Else
  39.             valid = check.IsMatch(addr, 0)
  40.         End If
  41.         Return valid
  42.     End Function
  43.  
  44.     Private Sub btBan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btBan.Click
  45.         If Ban.Checked = True Then
  46.             rcon("banip " & txtBanIP.Text)
  47.         ElseIf Unban.Checked = True Then
  48.             rcon("unbanip " & txtBanIP.Text)
  49.         Else
  50.             MsgBox("Bitte Aktion auswählen")
  51.             Exit Sub
  52.         End If
  53.     End Sub
  54.  
  55.     Private Sub btCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btCheck.Click
  56.         If checksettings() = True Then
  57.             MsgBox("Einstellungen sind im richtigem Format")
  58.             txtServerIP.Text = txtIP.Text & ":" & txtPort.Text
  59.             Servercontrol.Enabled = True
  60.             IPControl.Enabled = True
  61.             PlayerControl.Enabled = True
  62.             GroupChangeRCON.Enabled = True
  63.         End If
  64.  
  65.     End Sub
  66.     Function checksettings()
  67.         If IsValidIP(txtIP.Text) = False Then
  68.             MsgBox("Die angegeben IP Adresse ist nicht gültig")
  69.             Return False
  70.         ElseIf txtPort.TextLength = 0 Or txtPort.Text > 65535 Then
  71.             MsgBox("Der angegebene Port ist ungültig")
  72.             Return False
  73.         ElseIf txtRCON.TextLength = 0 Then
  74.             MsgBox("Bitte geben Sie ein RCON Passwort ein")
  75.             Return False
  76.         End If
  77.         Return True
  78.     End Function
  79.  
  80.     Private Sub btRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btRestart.Click
  81.         rcon("gmx")
  82.     End Sub
  83.  
  84.     Private Sub btStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btStop.Click
  85.         rcon("exit")
  86.     End Sub
  87.  
  88.     Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  89.         disable()
  90.     End Sub
  91.  
  92.     Private Sub btChangeHostname_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btChangeHostname.Click
  93.         If txtHostname.TextLength > 0 Then
  94.             rcon("hostname " & txtHostname.Text)
  95.         Else
  96.             MsgBox("Bitte zuerst einen Hostnamen angeben")
  97.         End If
  98.     End Sub
  99.  
  100.     Private Sub btChangeMapname_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btChangeMapname.Click
  101.         If txtMapname.TextLength > 0 Then
  102.             rcon("mapname " & txtMapname.Text)
  103.         Else
  104.             MsgBox("Bitte zuerst einen Mapnamen angeben")
  105.         End If
  106.     End Sub
  107.  
  108.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  109.         If txtGamemode.TextLength > 0 Then
  110.             rcon("changemode " & txtGamemode.Text)
  111.         Else
  112.             MsgBox("Bitte zuerst einen Gamemode angeben")
  113.         End If
  114.     End Sub
  115.  
  116.     Private Sub btFilterscript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btFilterscript.Click
  117.         If txtFilterscript.TextLength > 0 Then
  118.             If FilterscriptLoad.Checked = True Then
  119.                 rcon("loadfs " & txtFilterscript.Text)
  120.             ElseIf FilterscriptReload.Checked = True Then
  121.                 rcon("reloadfs " & txtFilterscript.Text)
  122.             ElseIf FilterscriptUnload.Checked = True Then
  123.                 rcon("unloadfs " & txtFilterscript.Text)
  124.             Else : MsgBox("Bitte zuerst eine Aktion auswählen")
  125.             End If
  126.         End If
  127.     End Sub
  128.  
  129.     Private Sub btWeatherChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btWeatherChange.Click
  130.         If txtWeather.Text > 0 Then
  131.             rcon("weather " & txtWeather.Text)
  132.         End If
  133.     End Sub
  134.  
  135.     Private Sub btChangeRCON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btChangeRCON.Click
  136.         If txtNewRcon.TextLength > 0 Then
  137.             If txtNewRcon.Text = txtNewRconReply.Text Then
  138.                 rcon("rcon_password " & txtNewRcon.Text)
  139.                 disable()
  140.                 txtNewRcon.Text = ""
  141.                 txtNewRconReply.Text = ""
  142.             End If
  143.         End If
  144.     End Sub
  145.  
  146.     Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
  147.         Process.Start("http://sa-rl.de")
  148.     End Sub
  149.  
  150.     Private Sub btClearServerlog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btClearServerlog.Click
  151.         rcon("reloadlog")
  152.     End Sub
  153.  
  154.     Private Sub btRealoadbans_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btRealoadbans.Click
  155.         rcon("reloadbans")
  156.     End Sub
  157.  
  158.     Private Sub btHandlePlayer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btHandlePlayer.Click
  159.         If txtPlayerid.TextLength > 0 Then
  160.             If Kick.Checked = True Then
  161.                 rcon("kick " & txtPlayerid.Text)
  162.             ElseIf IPBan.Checked = True Then
  163.                 rcon("ban " & txtPlayerid.Text)
  164.             End If
  165.         End If
  166.     End Sub
  167.     Sub disable()
  168.         Servercontrol.Enabled = False
  169.         IPControl.Enabled = False
  170.         PlayerControl.Enabled = False
  171.         GroupChangeRCON.Enabled = False
  172.     End Sub
  173. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement