Loop + Dialog question.
#8

On dialog response, just loop again and use the same if statements used in the command commands or function. IMPORTANT: add a counter for the loop then match them with the listitem.

Ror example:

pawn Код:
COMMAND:mycars(playerid)
{
    new MainStr[ 500 ], iFormat[ 128 ];
    VehicleLoop(v)
    {
        if(VehicleInfo[v][vActive] != 1) continue;
        if(!strcmp(VehicleInfo[v][owner], PlayerName(playerid), false))
        {
            format(iFormat, sizeof, "ID: [%d]\n", v);
            strcat(MainStr, iFormat);
        }
    }
    ShowPlayerDialog(playerid, MY_CARS, DIALOG_STYLE_LIST, "Vehicles owned by you!", MainStr, "Select", "");
    return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(listitem == MY_CARS)
    {
        if(response)
        {
            new count, finalid;
            VehicleLoop(v)
            {
                if(VehicleInfo[v][vActive] != 1) continue;
                if(!strcmp(VehicleInfo[v][owner], PlayerName(playerid), false))
                {
                    if(count == listitem)
                    {
                        finalid = v;
                    }
                    count++;
                }
            }
            format(iFormat, sizeof(iFormat), "Congratulations my prince, you own ID: %d", finalid);
            ShowPlayerDialog(playerid, MY_CARS, DIALOG_STYLE_MSGBOX, "Wow, mr big time.", iFormat, "Select", "");  
        }
    }
}
Reply


Messages In This Thread
Loop + Dialog question. - by ikbenremco - 24.06.2014, 17:31
Re: Loop + Dialog question. - by Threshold - 25.06.2014, 04:30
Re: Loop + Dialog question. - by Faisal_khan - 25.06.2014, 06:33
Re: Loop + Dialog question. - by ikbenremco - 25.06.2014, 09:10
Re: Loop + Dialog question. - by RenovanZ - 25.06.2014, 09:22
Re: Loop + Dialog question. - by ikbenremco - 25.06.2014, 10:30
Re: Loop + Dialog question. - by ikbenremco - 25.06.2014, 20:22
Re: Loop + Dialog question. - by d3ll - 25.06.2014, 21:15
Re: Loop + Dialog question. - by ikbenremco - 26.06.2014, 07:12

Forum Jump:


Users browsing this thread: 1 Guest(s)