|
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. |
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.");
|
PHP код:
|
case dialogThreadCarDealer:
{
if(!response)
{
return 0;
}
switch(listitem)
{
case 0:
{
new string[525], next[255];
for(new i=0; i<MAX_DEALERSHIPVEHICLES; i++)
{
if(Dealer[i][Cat] == 1)
{
format(next, sizeof(next),"%s\t$%d\n",Dealer[i][Name],Dealer[i][Price]);
strcat(string, next, sizeof(string));
}
}
ShowPlayerDialog(playerid, dialogThreadBikes, DIALOG_STYLE_TABLIST, "Vehicle Dealership - Bikes",string, "Purchase", "Back");
}
|
Don't think you understood, I'll try and be more clear the way I have it set is a user will type /vbuy this will then show a dialogbox(list style) of all the categories and then lets say they press Bikes shows another Dialogbox(list tab style) of all the Vehicles in my dealership table with the catagory for bike e.g
Код:
case dialogThreadCarDealer:
{
if(!response)
{
return 0;
}
switch(listitem)
{
case 0:
{
new string[525], next[255];
for(new i=0; i<MAX_DEALERSHIPVEHICLES; i++)
{
if(Dealer[i][Cat] == 1)
{
format(next, sizeof(next),"%s\t$%d\n",Dealer[i][Name],Dealer[i][Price]);
strcat(string, next, sizeof(string));
}
}
ShowPlayerDialog(playerid, dialogThreadBikes, DIALOG_STYLE_TABLIST, "Vehicle Dealership - Bikes",string, "Purchase", "Back");
}
|
switch(Dealer[i][carid]) // idk wth is Cat but there should be vehicle ID for each vehicle
{
case i:
// format and strcat shit (loading each vehicle)
case MAX_DEALERSHIPVEHICLES:
return 0;
}
// you can use your dialog function here.