Does RCON commands allow formatting?
#1

pawn Код:
SendRconCommand("hostname %s", SERVER_NAME);
    SendRconCommand("gamemodetext %s", SERVER_MODE);
    SendRconCommand("mapname %s", SERVER_MAP);
pawn Код:
#define SERVER_NAME "San Andreas Online"
#define SERVER_MAP "San Andreas"
#define SERVER_MODE "SAOnline 1.0"
The first code is not compiling successfully. Does that mean that RCON commands do not allow formatting, as seen in the aforementioned code? If not, what's the way of doing this?
Reply
#2

how about something like this?

PHP код:
SendRconCommand("hostname "SERVER_NAME); 
Reply
#3

As far as I see, you are using SendRconCommand just like printf. Well, that's not the way it's meant to be used.
I'd suggest to format a string, then pass it as the argument of SendRconCommand:
pawn Код:
new rconcmd[32]; // You can change the size relying to the size of your defines.
// I recommend keeping it 32, unless you change the defines.
format(rconcmd, sizeof(rconcmd), "hostname %s", SERVER_NAME);
SendRconCommand(rconcmd);
format(rconcmd, sizeof(rconcmd), "gamemodetext %s", SERVER_MODE);
SendRconCommand(rconcmd);
format(rconcmd, sizeof(rconcmd), "mapname %s", SERVER_MAP);
SendRconCommand(rconcmd);
Reply
#4

Thank you, Dragonsauros.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)