17.01.2017, 15:34
Код:
CMD:garage(playerid, params[]) { new i, string[256] ; for(i; i < MAX_PLAYER_CARS; i++) // loop { if(ID[playerid][i] == -1) // if player doesn't have car in this slot, skip it continue; format(string, 256, "%s%s(%i)\n", string, aVehicleNames[GetVehicleModel(ID[playerid][i])-400], ID[playerid][i]); } for(i; i < MAX_PLAYER_CARS; i++) // loop to make the rest of slots - empty - { strcat(string, "- empty -\n"); } ShowPlayerDialog(playerid, DIALOG_MENU, DIALOG_STYLE_LIST, "Garage", string1, "Select", "Close"); return 1; }
Example:
Код:
OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { // ... case DIALOG_MENU: { if(response) { new slot; for(new i; i < MAX_PLAYER_CARS; i++) { if(ID[playerid][i] == -1) // if player doesn't have car in this slot, skip it continue; if(listitem == slot) { // code if player selected vehicle slot 'slot' return 1; } slot++; } // code if player selected - empty - slot } } // ... } }