SA-MP Forums Archive
Need an explanation regarding this - 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: Need an explanation regarding this (/showthread.php?tid=648848)



Need an explanation regarding this - Hooligan12 - 29.01.2018

I don't understand what this "format" is used for and how can it be used later in the script?

Code:
        new name_of_server[42];
	format(name_of_server, sizeof(name_of_server), "hostname %s v. %.01f", SERVER_NAME, SERVER_VERSION);
	SendRconCommand(name_of_server);
I'll very grateful if anyone can give me a good explanation of this piece of code, how it works and so on.

Thank you.


Re: Need an explanation regarding this - Isolated - 29.01.2018

pawn Code:
new name_of_server[42]; // declare the hostname variable.
    format(name_of_server, sizeof(name_of_server), "hostname %s v. %.01f", SERVER_NAME, SERVER_VERSION); // format the hostname variable string with the RCON command name, server name and version =
    SendRconCommand(name_of_server); // send the RCON command to the server setting the hostname of the server.



Re: Need an explanation regarding this - RogueDrifter - 29.01.2018

Quote:

Formats a string to include variables and other strings inside it.

you should check this https://sampwiki.blast.hk/wiki/Format


Re: Need an explanation regarding this - Mugala - 29.01.2018

okay, lets make it simple.
You can't send a message (and not only a message) with a formatted, such as "Hello Hooligan12"
you must format this like - format(text,sizeof(text),"Hello %s",YourNameScript), SendClientMessage(playerid,-1,text);

Yeah u can use this SendClientMessage(playerid,-1,"Hello Hooligan12"); too but u're saying hello only yourself, if someone got this message it only says your name.