String loop to join strings - 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 loop to join strings (
/showthread.php?tid=458713)
String loop to join strings -
ProjectMan - 18.08.2013
Hello, I would like to know how to join strings?
Something like this:
pawn Код:
CMD:shop(playerid,params[])
{
new LongString[512];
for(new i; i < sizeof(zones); i++)
{
printf("%s",zones[i][0]); // [0] is the name
format(LongString,sizeof(LongString),"%s\n",zones[i][0]);
}
ShowPlayerDialog(playerid, telemenu, DIALOG_STYLE_LIST, "Teleport menu", LongString, "Spawn", "Cancel");
return 1;
}
I want to loop every line in a format and then show the list as dialog.
Re: String loop to join strings -
Roko_foko - 18.08.2013
pawn Код:
CMD:shop(playerid,params[])
{
new LongString[512];
for(new i; i < sizeof(zones); i++)
{
printf("%s",zones[i][0]); // [0] is the name
format(LongString,sizeof(LongString),"%s\n%s",LongString,zones[i][0]);//>>> this line is changed <<<
}
ShowPlayerDialog(playerid, telemenu, DIALOG_STYLE_LIST, "Teleport menu", LongString, "Spawn", "Cancel");
return 1;
}
Re: String loop to join strings -
ProjectMan - 18.08.2013
Quote:
Originally Posted by Roko_foko
pawn Код:
CMD:shop(playerid,params[]) { new LongString[512]; for(new i; i < sizeof(zones); i++) { printf("%s",zones[i][0]); // [0] is the name format(LongString,sizeof(LongString),"%s\n%s",LongString,zones[i][0]);//>>> this line is changed <<< }
ShowPlayerDialog(playerid, telemenu, DIALOG_STYLE_LIST, "Teleport menu", LongString, "Spawn", "Cancel"); return 1; }
|
Thanks. If you are wondering why I made that command, it's because I don't want to type the stuff. Thanks again.
Re: String loop to join strings -
Edix - 18.08.2013
eaier would be using strcat.
https://sampwiki.blast.hk/wiki/Strcat