Quake 3 Rcon

  • Mein UDF zum Quake 3 Rcon Protocol, wir zb von CoD, Quake ^^ usw. unterstütz. (Keine Valve Spiele)

    Spoiler anzeigen
    [autoit]

    func _RconConnect ( $sIP, $iPort )
    UDPStartup ()

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    if $socket <> false and IsArray ( $socket ) and $socket[0] <> -1 Then
    ;
    Else
    return SetError ( 1, 0, 0)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    Local $sRecv = "", $iCountEmptyRecv = 0, $sBuffer, $sTmp = ""

    [/autoit] [autoit][/autoit] [autoit]

    while 1
    $sBuffer = UDPRecv ( $socket, 100000000 )

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]
  • sehr schön gemacht funktioniert auch mit cod2 allerdings dann mit "status" und nicht getstatus etc

  • Für den 'status' Befehl braucht man jededoch ein Passwort für 'getStatus' hingegen nicht ^^. Das eine ist zu Serveradministration, das andere für die Infos von Spielern die ein Server suchen.
    Aber schön das wenigstens jemand es ausprobiert hat :)