21.03.2016, 12:19
Quote:
I'm adding in a dynamic car dealership feature into my script I already have it loading my cars dynamically into the dialog box list
how ever when it comes to switch(listitem) is there anyway to dynamically make the cases depending on the amount of items on the list as that can change as vehicles and added/removed into the dealership table of my database. |
PHP код:
new
count,
text[128],
dialogText[200];
for (new i = 0; i != MAX_VEHICLES; i ++) // put your MAX_DEALERSHIP_VEHICLES thing...
{
if (!CarData[i][cExists]) continue; // create an another variable for each vehicle to see if they exists
strunpack(text, CarData[i][cModel]); // Load things you need... (loads model such as Cheetah, Infernus)
CarData[i][cFuel] = new Float:cFuel; // I'm assuming this is float
format(dialogText, sizeof(dialogText), "Car ID: %d | Car Model: %s | Car Fuel: %f\n", CarData[i][cID], text, cFuel);
ShowPlayerDialog(playerid, DIALOG_LIST_VEHICLES, DIALOG_STYLE_LIST, "Vehicles", dialogText, "Select", "Exit");
count++;
}
if (!count) return SendClientMessage(playerid, -1, "There are no vehicles to display.");
But just realised this script will probably show dialog for each vehicle. So, you may want to create another function to prevent that. Maybe listDealershipCars()