Hi, I am looking to make my own remote control application for my clans call of duty 4 servers. I am a COD4 Admin, Webmaster and mod developer for WYDGAMING.com and I am wishing to make admining our servers much easier. I have searched the internet and this site and cannot really find an answer to my problem.
I need to know how to connect to the server console so I can send server commands. I know all commands and things that can be used on the server so i just need to know how to connect to it. I believe from research Call of Duty 4 using a UDP port for connecting to the console via remote application.
Does anyone know of how I can make the UDP connection or know anyother site where i can find the info to do this.
Dont let the name of this forum fool you, we've got a wide variety of languages on here
Do you know exactly how these messages to the server should look? Wouldnt you need some sort of authentication?
Sending the UDP messages is the easy part:
vb Code:
Dim client As New System.Net.Sockets.Socket(Net.Sockets.AddressFamily.InterNetwork, Net.Sockets.SocketType.Dgram, Net.Sockets.ProtocolType.Udp)
Note that even though the Connect method is called in this piece of code, there is no actuall connection, it will just label the datagrams with this destination IP before sending them on their way. UDP is a connectionless protocoll.
Hey, thanks for repling. I will try get that code into my program when I get home. I have found this topic on another website where someone has nearly got the required connection working.
Code:
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
' rconPassword is the password to login for admin control
Dim sPass As String = "/rcon login rconPassword"
' sv_hostname is the variable on the server that has text im trying to receive
Dim hostName As String = "sv_hostname"
' multi-line textbox named txtBox1 for sending the information to, to read
Private Sub txt(ByVal Text As String)
txtBox1.AppendText(Text & vbCrLf)
txtBox1.ScrollToCaret()
End Sub
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
Dim udpClient As New UdpClient(12345)
Try
' Not the real ip address or port number
udpClient.Connect("123.45.67.89", 12345)
' Here i try to send the login attempt and hostname request
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(sPass & hostName)
udpClient.Send(sendBytes, sendBytes.Length)
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
Dim receiveBytes As [Byte]() = udpClient.Receive(RemoteIpEndPoint)
Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)
txt("Hostname: " + returnData.ToString())
udpClient.Close()
Catch ex As Exception
txt(ex.ToString())
End Try
End Sub
End Class
- If the 1st line of the response says "map: " then I save the next series of characters as the map name.
----> If the 1st line does NOT say "map: " then there is a problem... try again. Maximum retries are 3.
- If the 3rd line is a bunch of hyphens (----) then start populating the player list with the listed players.
----> If the 3rd line is not a bunch of hyphens, then there is a problem... Try again, a maximum of 3 times.
- If I've tried 3 times on either of those conditions, and it still doesn't match what I am expecting, show the error message "Your server is returning really bad UDP packets" (or whatever that message says).
So basically, your server is returning a FRAGMENTED response out-of-order. So since the UDP protocol is so unreliable sometimes, my program cannot account for and detect every case where the packets are messed up. So that warning is there to explain that the program might not function properly. Sometimes when people get the warning, the program works semi-fine, but some players are missing from the list. Other people just don't see anything, depending on how messed up their UDP packets are.
I have read on several sites the main rcon protocol is 115 but that might be for the previous versions
Code:
\Admin\wydadmin\Email\[email protected]\g_compassShowEnemies\0\g_gametype\war\gamename\Call of Duty 4\mapname\mp_convoy\protocol\4\shortversion\1.5\sv_allowAnonymous\0\sv_disableClientConsole\0\sv_floodprotect\4\sv_hostname\^2WWW.^1W^7Y^4D^2-HQ.COM\sv_maxclients\32\sv_maxPing\350\sv_maxRate\25000\sv_minPing\0\sv_privateClients\0\sv_punkbuster\1\sv_pure\1\sv_voice\1\ui_maxclients\50\URL\www.wydgaming.com
I see protocol 4 in the above code what I took from one my server log files.
Hope this helps, if you want me to provide anything else let me know,
Matt
Last edited by computermat; Apr 15th, 2008 at 05:12 PM.
Visual Studio 2005 (.net 2.0) Please note: I am 17 and dont have the exerience of an experienced programmer so I apologise in advance if my posts are confusing
It would be great if the creators of Call of duty would supply us with some sort of documentation on the server protocoll. Valve has some good documentation I've use a couple of times; http://developer.valvesoftware.com/w...Query_Protocol
Gave it a try and unfortunately it didnt do the job. In the top part of the image below this is what I get when I query the game port. If I query any other port i get the bottom part of the image.
From using your code I think the port used in the connection has to be to the game connection port or both the game connection port and a UDP port have to be used. Im not sure though.
Any more ideas, maybe its an authentication problem or is it suppose to do that?
Visual Studio 2005 (.net 2.0) Please note: I am 17 and dont have the exerience of an experienced programmer so I apologise in advance if my posts are confusing
The format of the sent message must be wrong.
And since I dont know the protocol syntax/semantics, I can only guess on other ways to write the command. Try changing the command to:
VB.NET Code:
Dim command As String = "ÿÿÿÿrcon yourPassword say Is this working?"
The only difference is that there's no space between 'ÿÿÿÿ' and 'rcon'.
Still not working, still getting the disconnect msg.
Thanks for your help, I am going to post on codbaords.com see if someone with knowledge in COD protocols sees my post.
Thanks again, your efforts are greatly appreciated
Matt
Visual Studio 2005 (.net 2.0) Please note: I am 17 and dont have the exerience of an experienced programmer so I apologise in advance if my posts are confusing
Yes I did manage to get the connection working but never completed my application. I will try and find the vb file and post the code here.
Visual Studio 2005 (.net 2.0) Please note: I am 17 and dont have the exerience of an experienced programmer so I apologise in advance if my posts are confusing
I found the project file and made sure it was working before posting here. I have included it as an attachement. Any questions regarding it please feel free to ask and I will try to answer them
Visual Studio 2005 (.net 2.0) Please note: I am 17 and dont have the exerience of an experienced programmer so I apologise in advance if my posts are confusing
thank you so much, just done a quick ststus command on a few servers, and all working fine.. will have a bash at adding it to my app when i next have time..
I found the project file and made sure it was working before posting here. I have included it as an attachement. Any questions regarding it please feel free to ask and I will try to answer them
I can't open it with Visual Basic 2008.
Could you please convert it for VB.NET 2008 ?
I know this is kind of a dead thread, but I'm trying to do the exact same thing. There just isn't much about this on the 'net at this point, even though the game has been out for over 3 years. :sigh:
I have downloaded the file from post #16, and have tried adding commands like Fast Restart, Change Map, Change Gametype, etc., but I just have no clue how to get them working. Also, when I connect to my server, it always shows "????print" above the player information. I would like for that to not be shown.
If anyone has ANY additional information about this, please please post something.