String loop to join strings
#1

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.
Reply
#2

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;
}
Reply
#3

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.
Reply
#4

eaier would be using strcat.

https://sampwiki.blast.hk/wiki/Strcat
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)