yucatan Posted April 10, 2012 Share Posted April 10, 2012 (edited) Hello guys i'm making a tool so that i can query my CS 1.6 server UDPStartup() OnAutoItExitRegister("Cleanup") $socket = udpopen("84.27.142.137", 27015) If @error <> 0 Then ConsoleWrite(@error) Exit EndIf $teller=0 $henk=1 $teller +=1 $status = udpSend($socket, "ÿÿÿÿTSource Engine Query") While 1 $data = udpRecv($socket, 99999) i already got a working sample for CS source. but i would like to use it for 1.6expandcollapse popupLocal Const $RCON_SERVERDATA_AUTH = 3 Local Const $RCON_SERVERDATA_EXECCOMMAND = 2 Local Const $RCON_TERMINATOR = Binary(Chr(0) & Chr(0)) TCPStartup() $server = _RconConnect("176.9.125.87", "29018", "test") If @error Then ConsoleWrite("Error with connecting or authorisation" & @CRLF) Exit EndIf While 1 $status = _RconCommand($server, "status") If @error Then ConsoleWrite("Connection closed by server" & @CRLF) ExitLoop EndIf ConsoleWrite(@CRLF & ">Result from status: " & @CRLF & @CRLF & $status & @CRLF) Sleep(5000) WEnd Exit Func _RconCommand($hSocket, $command) TCPSend($hSocket, _RconCreateCommand(0, $RCON_SERVERDATA_EXECCOMMAND, $command)) If @error Then ; Connection closed by remote server Return SetError(1, 0, -1) EndIf $len = Number(_RconGetReply($hSocket, 1)) + 3 If @error Then Return SetError(2, 0, -1) EndIf $packet = _RconGetReplyMinLen($hSocket, $len) If @error Then Return SetError(2, 0, -1) EndIf $packet = BinaryMid($packet, 12) Return BinaryToString($packet) EndFunc Func _RconConnect($ip, $port, $password) Local $hSocket = TCPConnect($ip, $port) If @error Then ; No connection could be made Return SetError(1, 0, -1) EndIf TCPSend($hSocket, _RconCreateCommand(0, $RCON_SERVERDATA_AUTH, $password)) $reply = _RconGetReply($hSocket, 28) If $reply = "" Then ; This happens if the connection is forcibly closed. Probably user is banned. Return SetError(3, 0, -1) EndIf $flag = Number(BinaryMid($reply, 19, 4)) If $flag <> 0 Then ; Invalid password Return SetError(2, 0, -1) EndIf Return $hSocket EndFunc Func _RconGetReplyMinLen($hSocket, $length) Local $packet = Binary("") While 1 $data = TCPRecv($hSocket, $length) If @error Then ExitLoop $packet = Binary($packet) + Binary($data) If BinaryLen($packet) >= $length Then ExitLoop EndIf WEnd Sleep(200) ; Read any other junk $data = TCPRecv($hSocket, 1024) $packet = Binary($packet) + Binary($data) Return $packet EndFunc Func _RconGetReply($hSocket, $length) Local $packet = Binary("") While 1 $data = TCPRecv($hSocket, $length) If @error Then ExitLoop $packet = Binary($packet) + Binary($data) If BinaryLen($packet) >= $length Then ExitLoop EndIf WEnd Return $packet EndFunc Func _RconCreateCommand($requestId, $serverData, $command) Return Binary(StringLen($command) + 10) + Binary($requestId) + Binary($serverData) + Binary($command) + $RCON_TERMINATOR EndFunc If $data <> "" Then ConsoleWrite($Data & @CRLF) EndIf WEnd anyone got an idea why this isnt working ? Edited April 10, 2012 by yucatan Link to comment Share on other sites More sharing options...
yones7x Posted April 10, 2012 Share Posted April 10, 2012 Because fhe function "Cleanup" not found in this script! and "OnAutoItExitRegister" need to function if you want, delete "OnAutoItExitRegister" and the script will be started normally Good Luck.. Link to comment Share on other sites More sharing options...
yucatan Posted April 14, 2012 Author Share Posted April 14, 2012 i'm now trying this on a cod4 server. here is my code : UDPStartup() $socket = udpopen("176.9.111.100", 29067) If @error <> 0 Then ConsoleWrite(@error) Exit EndIf $teller=0 $henk=1 $teller +=1 $data = "" $status = udpSend($socket, "xFFxFFxFFxFFgetstatus/n") While 1 $data = udpRecv($socket, 99999) If $data <> "" Then ConsoleWrite($Data & @CRLF) EndIf WEnd ;ConsoleWrite($teller & @CRLF) but it keeps sending me yyyydisconnect Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now