string formating question - 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: string formating question (
/showthread.php?tid=665165)
string formating question -
bosmania - 24.03.2019
format(aim, sizeof(aim), "%s[R%s] [%s/3 warns] %s\n", aim, test, warns, query);
i've seen people formating a string like this and i don't understand what's the point,i mean why do they include the string itself while formating the string, the first placeholder "%s" represents "aim",wich is the string that its formated
format(aim, sizeof(aim), "%S [R%s] [%s/3 warns] %s\n", AIM, test, warns, query);
i wrote the placeholder with caps and what it represents,the AIM witch is the string itself,i don't understand
Re: string formating question -
NaS - 24.03.2019
It's used to attach something to a string while also using other specifiers.
For example, if you have a list you want to show in a dialog and you want to format each line with values/text from an array or so, you can use this to repeatedly attach the new line to the string without using a temporary array/string.
Code:
new some_models[] = {13592, 1225, 2323};
new string[100];
for(new i = 0; i < sizeof(some_models); i ++)
{
format(string, sizeof(string), "%s%d\n", string, some_models[i]);
}
And the result will be
"13592\n1225\n2323\n"
It basically is just used as strcat with format specifiers.