SA-MP Forums Archive
Does RCON commands allow formatting? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Does RCON commands allow formatting? (/showthread.php?tid=526075)



Does RCON commands allow formatting? - Twizted - 15.07.2014

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?


Re: Does RCON commands allow formatting? - amirab - 15.07.2014

how about something like this?

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



Re: Does RCON commands allow formatting? - Dragonsaurus - 15.07.2014

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);



Re: Does RCON commands allow formatting? - Twizted - 15.07.2014

Thank you, Dragonsauros.