Console communication


(squadjot) #1

How do you communicate with the wolf console. (external)

f.ex if u wanted to send some commands to an already open ETconsole, from an external program.

Whats the procedure…and can i read about this somewhere…

thnx


(alfredbester) #2

Communication with Wolf happens with the stateless UDP protocol. To send server commands externally, you simlpy send a UDP packet to the server IP and port with message “ÿÿÿÿ MyRconPassword MyRemoteCommand”. I used a protocol analyzer to find this out a long time ago so i hope i remember the ÿ-part correctly.

Depending on the complexity of what you have in mind, this can be written in anything. If its really complex I suggest C, if its really simple you could try VB6 which is easiest.
To simply make an rcon without starting wolf, I suggest the latter or if you use linux make it in python or perl…

cheers,
alf


(Sandius) #3

Don’t know what squadjot needs, but what I would like to know, how can I communicate with the console on the client side, llike: heron and qirc. Not just send the text to console, but also how to read it.

As I understand, there is a hidden window (the console). Short idea is to get the handler of that window and put/scan text to it - don’t know how to do that.

The problem is, that DLL source (Qirc) has vanished and I can’t find it anywhere!

Anyone please help if U can!

Thx


(alfredbester) #4

It seems to me you want to do this in windows, and I don’t know how to do what you want. I suggest you search codeplanet or something for programs that can externally fetch text out of for example an open wordpad screen… Under linux tough the solution is straightforward: just use g_logsync 2 and do a tail -f on the logfile and pipe the output of this to your program. Then you can read realtime consoleoutput and use UDP to send commands… this is the way etadmin mod works by the way
Good Luck


(Lanz) #5

Read at the bottom of the page, that’s how you do it:

http://www.slipgate.de/projects/qirc.html

For ET the window is called "ET Console"and for rtcw I think it’s called “Wolf Console”.


(Aigle) #6

Sorry for bringing up old threads, but I searched for a C/C++ source code with an exemple on how to send rcon, and found none. So here’s the one I made, I though it could be useful to some peoples :


#include <winsock2.h>

#pragma comment(lib,"ws2_32.lib")

const char HEADER = (char)0xFF;
const char FOOTER = (char)0x00;
int sinsize;

WSADATA wsa;
SOCKET sock;
SOCKADDR_IN sin;

void SendRcon(char *cmd, char *rcon);

int main()
{
	char *rconpass="password";
	char* ip = new char[15];
	int port=27960;
	strcpy(ip, "127.0.0.1");

	WSAStartup(MAKEWORD(2,0),&wsa);

	sin.sin_family=AF_INET;
	sin.sin_addr.s_addr=inet_addr(ip);
	sin.sin_port=htons(port);

	sinsize = sizeof(sin);

	sock=socket(AF_INET,SOCK_DGRAM,0);

	if(!bind(sock,(SOCKADDR*)&sin,sinsize))
	{
		printf("Error binding socket... Closing app...");
		return 0;
	}

	SendRcon("cp ^1Hello...", rconpass);

	return 1;
}

void SendRcon(char *cmd, char *rcon)
{
	char sndbuffer[240]; ZeroMemory(sndbuffer, 240);
	short k = 0;

	sndbuffer[k++] = HEADER;
	sndbuffer[k++] = HEADER;
	sndbuffer[k++] = HEADER;
	sndbuffer[k++] = HEADER;

	strcat(sndbuffer, "rcon \"");
	strcat(sndbuffer, rcon);
	strcat(sndbuffer, "\" ");
	strcat(sndbuffer, cmd);

	k += strlen(rcon) + strlen(cmd) + 8 ;

	sndbuffer[k] = FOOTER;
		
	sendto(sock,sndbuffer,sizeof(sndbuffer),0,(SOCKADDR*)&sin,sinsize);
}

PS : I didn’t comment the sources as I found they were self-explicating enough :slight_smile: