25.06.2014, 21:15
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:
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", "");
}
}
}