Mein UDF zum Quake 3 Rcon Protocol, wir zb von CoD, Quake usw. unterstütz. (Keine Valve Spiele)
Spoiler anzeigen
func _RconConnect ( $sIP, $iPort )
UDPStartup ()
Local $socket, $error
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$socket = UDPOpen ( $sIp, $iPort )
[/autoit] [autoit][/autoit] [autoit]if @error then
return SetError ( @error, 0, $socket)
Else
return $socket
EndIf
EndFunc
[/autoit] [autoit][/autoit] [autoit]func _RconSend ( $socket, $sData, $sPassword, $sHeader = "rcon")
[/autoit] [autoit][/autoit] [autoit];Wenn sHeader nicht "rcon" ist wird $sPassword automatisch zu einem leeren String gemacht und nur der string $sData
;wird übertragen (übrigens um das leerzeichen nach dem header braucht ihr euch NICHT zu kümmern!)
;andere header sind (ich weiss nicht ob es mehr gibt^^) getstatus und getinfo also:
;_RconSend ( $socket, "", "", "getstatus")
;_RconSend ( $socket, "", "", "getinfo")
;***Edit*** (20 miunten dannach
;es gibt getservers das kann man an den masterserver senden
if $socket <> false and IsArray ( $socket ) and $socket[0] <> -1 Then
;
Else
return SetError ( 1, 0, 0)
EndIf
Local $send
if $sHeader == "rcon" Then
$sHeader &= " "
$sPassword &= " "
Else
$sHeader &= " "
$sPassword = ""
EndIf
$send = UDPSend ( $socket, chr (255) & chr ( 255 ) & chr ( 255 ) & chr ( 255) & $sHeader & $sPassword & $sData )
if @error Then
return SetError ( @error, 0, 0)
Else
return $send
EndIf
EndFunc
[/autoit] [autoit][/autoit] [autoit]func _RconRecv ( $socket , $iCheckForPassword = 1, $iRemoveHeader = 1)
[/autoit] [autoit][/autoit] [autoit]if $socket <> false and IsArray ( $socket ) and $socket[0] <> -1 Then
;
Else
return SetError ( 1, 0, 0)
EndIf
Local $sRecv = "", $iCountEmptyRecv = 0, $sBuffer, $sTmp = ""
[/autoit] [autoit][/autoit] [autoit]while 1
$sBuffer = UDPRecv ( $socket, 100000000 )
if ($sBuffer = "" and $sRecv <> "") or @error then
ExitLoop
Else
$sRecv &= $sBuffer
EndIf
if $sBuffer = "" Then
$iCountEmptyRecv += 1
if $iCountEmptyRecv > 2 Then
ExitLoop
EndIf
EndIf
WEnd
if $sRecv == "" then
return SetError ( 2, 0, 0)
Else
if StringRegExp ( $sRecv, "(\xFF\xFF\xFF\xFFdisconnect)") Then
return SetError ( 4, 0, 0)
EndIf
if $iRemoveHeader Then
$sTmp = StringRegExpReplace ($sRecv, "(\xFF\xFF\xFF\xFF.+\n)", "")
if not @error Then
$sRecv = $sTmp
EndIf
EndIf
if StringRegExp ( $sRecv , "(?i).*((Invalid)|(Bad)|(No))+.*(rcon)?.*password.*") and $iCheckForPassword Then
return SetError ( 3, 0, 0)
else
return $sRecv
EndIf
EndIf
EndFunc
[/autoit]