SA-MP Forums Archive
Strcat 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: Strcat question (/showthread.php?tid=321878)



Strcat question - 2KY - 28.02.2012

Well, I have this:

pawn Код:
CMD:radio(playerid, params[]) {
   
    new
        availableStations[256],
        holder[256],
        rStr[16],
        radioCount = 0;
       
    for( new r = 1; r < MAXIMUM_RADIO_STATIONS; r ++ )
    {
           
        format( rStr, sizeof( rStr ), "%s/%d.ini", RadioLocation, r );
        if( fexist( rStr ) )
        {
            format( availableStations, sizeof( availableStations ), ""#STATIONGENRE"[%s]\t"#STATIONNAME"%s", radInfo[r][StationGenre], radInfo[r][StationName] );
            strcat( availableStations, holder );
           
            radioCount++;
            printf("count %d", radioCount);
        }
    }
   
    if(radioCount == 0)
        return SendClientMessage(playerid, -1, "ERROR: No Radio Stations available.");
       
    ShowPlayerDialog(playerid, RADIO_DIALOG, DIALOG_STYLE_LIST, "Please select a Radio Station", availableStations, "Play", "Cancel");
    return true;
}
Why won't this list all of the items? It only lists ID 1 (which is listitem 0)


Re: Strcat question - Vince - 28.02.2012

You're overwriting it every time. Also, you forgot to start a new line with \n.


Re: Strcat question - 2KY - 28.02.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
You're overwriting it every time. Also, you forgot to start a new line with \n.
That would explain my display problem, what do you mean overwriting it? How would I fix this?


Re: Strcat question - MP2 - 28.02.2012

You're wiping all past text in availableStations by using format. Use a different string variable.


Re: Strcat question - 2KY - 28.02.2012

Quote:
Originally Posted by MP2
Посмотреть сообщение
You're wiping all past text in availableStations by using format. Use a different string variable.
Thanks, fixed.