Strcat question
#1

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)