PDA

View Full Version : Executing rcon commands by server - from a gsc file - without execclientcommand



richard27
5th November 2021, 08:04
Hello cod2 experts! This is my first post here :-)

My question is about how to execute rcon commands on server side?

There are 3 possibilities currently for executing rcon commands:
a) client side: logging in a player with "rcon login password" using the execclient command menu trick
b) using 3rd part programs which send some message to website (i dont know how they work unfortately), for example hslw or any rcon bot ("sending" data to website with these data: ip, port, rcon login and action command

c) and I would need the third option which is between these two: how can i execute an rcon command inside a gsc?

Practical use: i would like to make a console message welcome script, which sends a message on playerconnect /or playerspawn function (at first spawn).

I have this all working, with the client side rcon login method, but its a bad practice cause rcon password flows throw client variables (clientcmd cvar stores it temporarily, so the player can login into rcon.

So it seems like there should be a solution between these two. 3rd party bots can solve this, so inside a gsc file it should also work based on my logic, cause this would be more simple than 3rd party bots.

Do you have any idea?

This is the article where Kungfooman mentioned something about a menu-less server side command:
https://killtube.org/showthread.php?1687-Sending-server-commands-to-the-clients

I am a beginner at scripting, but would be awesome to solve this. Thank you very much for any kind of help, have a nice day :-)

(the id for tell command is not hard coded in real example, i just wanted to simplify it)




self setClientCvar("clientcmd", "rcon login pass; rcon tell 2 Welcome to the server " + self.name + "rcon logout");

self openMenuNoMouse(game["menu_clientcmd"]);
self closeMenu(game["menu_clientcmd"]);
wait 0.2;
self setClientCvar("clientcmd", "");
wait 0.2;

kung foo man
5th November 2021, 12:48
If you don't want to use B3 or any other log-reader-send-rcon-third-party-tool this you can use libcod:

https://github.com/kungfooman/libcod/blob/master/gsc.cpp#L266

Your example would be:



Cmd_ExecuteString("tell 2 Welcome to the server " + self.name);