Dynamic Dialogboxes
#1

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.
Reply
#2

Quote:
Originally Posted by Markus_Whiteus
Посмотреть сообщение
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 
0!= MAX_VEHICLES++) // put your MAX_DEALERSHIP_VEHICLES thing...
    
{
        if (!
CarData[i][cExists]) continue; // create an another variable for each vehicle to see if they exists
        
strunpack(textCarData[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(dialogTextsizeof(dialogText), "Car ID: %d | Car Model: %s | Car Fuel: %f\n"CarData[i][cID], textcFuel);
        
ShowPlayerDialog(playeridDIALOG_LIST_VEHICLESDIALOG_STYLE_LIST"Vehicles"dialogText"Select""Exit");
        
count++;
    }
    if (!
count) return SendClientMessage(playerid, -1"There are no vehicles to display."); 
I hope I understood you correctly. You can put these in a command or a function idk whatever pleases you. Ofc you have to change variables to what you set in your script.

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()
Reply
#3

Quote:
Originally Posted by WhoIsYourDaddy
Посмотреть сообщение
PHP код:
    new
        
count,
        
text[128],
        
dialogText[200];
    for (new 
0!= MAX_VEHICLES++) // put your MAX_DEALERSHIP_VEHICLES thing...
    
{
        if (!
CarData[i][cExists]) continue; // create an another variable for each vehicle to see if they exists
        
strunpack(textCarData[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(dialogTextsizeof(dialogText), "Car ID: %d | Car Model: %s | Car Fuel: %f\n"CarData[i][cID], textcFuel);
        
ShowPlayerDialog(playeridDIALOG_LIST_VEHICLESDIALOG_STYLE_LIST"Vehicles"dialogText"Select""Exit");
        
count++;
    }
    if (!
count) return SendClientMessage(playerid, -1"There are no vehicles to display."); 
I hope I understood you correctly. You can put these in a command or a function idk whatever pleases you. Ofc you have to change variables to what you set in your script.
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");
				}
As you can see this will now load the vehicles I have set what I am wondering is how to do the next step dymically make a case for each vehicle depending on how many vehicles it loaded
Reply
#4

Quote:
Originally Posted by Markus_Whiteus
Посмотреть сообщение
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");
				}
As you can see this will now load the vehicles I have set what I am wondering is how to do the next step dymically make a case for each vehicle depending on how many vehicles it loaded
You have to use the switch function again.

PHP код:
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. 
If you try to do this way, you'll get it done I hope. Because what you need is load each vehicles in a category on a dialog.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)