I have 141 items to add to this list, is there a quicker or better way? -
Dokins - 15.04.2015
pawn Код:
else if(dialogid == DIALOG_FURNILIST)
{
if(response == 0)
{
return 1;
}
switch(listitem)
{
case 0:
{
DealerOrderFurniture(playerid, 2290, InfPrice(400), 0, 0);
}
case 1:
{
DealerOrderFurniture(playerid, 14490, InfPrice(200), 0, 0);
}
case 2:
{
DealerOrderFurniture(playerid, 1794, InfPrice(700), 0, 1);
}
case 3:
{
DealerOrderFurniture(playerid, 2247, InfPrice(60), 0, 0);
}
case 4:
{
DealerOrderFurniture(playerid, 2306, InfPrice(125), 1, 2);
}
case 5:
{
DealerOrderFurniture(playerid, 2073, InfPrice(100), 0, 0);
}
case 6:
{
DealerOrderFurniture(playerid, 1740, InfPrice(120), 1, 1);
}
case 7:
{
DealerOrderFurniture(playerid, 1734, InfPrice(130), 0, 0);
}
case 8:
{
DealerOrderFurniture(playerid, 2100, InfPrice(800), 0, 0);
}
case 9:
{
DealerOrderFurniture(playerid, 14527, InfPrice(80), 0, 0);
}
}
}
Title says all.
Pasting messed up the indentation.
Re: I have 141 items to add to this list, is there a quicker or better way? -
Karan007 - 15.04.2015
Nope, i don't think so.You could just SendClientMessage it and make commands to buy them...Like /buy1 = buy furnitures only...
Re: I have 141 items to add to this list, is there a quicker or better way? -
Konstantinos - 15.04.2015
I'd use an array and "listitem" as its index.
Re: I have 141 items to add to this list, is there a quicker or better way? -
Dokins - 15.04.2015
Quote:
Originally Posted by Konstantinos
I'd use an array and "listitem" as its index.
|
Ahh that's a pretty good idea actually.
But don't I still effectively have to add them all to the array?
Re: I have 141 items to add to this list, is there a quicker or better way? -
Vince - 15.04.2015
Yes, but you can use the same array to generate the required dialog in the first place.
Re: I have 141 items to add to this list, is there a quicker or better way? -
Dokins - 15.04.2015
I kind of understand,
Would it be like switch(FurniArray[listitem]]?
And then elsewhere like
FurniArray[0] = DealerOrderFurniture(....?
Re: I have 141 items to add to this list, is there a quicker or better way? -
Dokins - 15.04.2015
For this will I also have to add 141 spaces to this:
pawn Код:
format(string, sizeof(string), "%s ($%s)\n%s ($%s)\n%s ($%s)\n%s ($%s)\n%s ($%s)\n%s ($%s)\n%s ($%s)\n%s ($%s)\n%s ($%s)\n%s ($%s)", GetFurniName(2290), AddCommas(InfPrice(400)),
GetFurniName(14490), AddCommas(InfPrice(200)), GetFurniName(1794), AddCommas(InfPrice(700)),GetFurniName(2247), AddCommas(InfPrice(60)), GetFurniName(2306), AddCommas(InfPrice(125)), GetFurniName(2073), AddCommas(InfPrice(100)), GetFurniName(1740), AddCommas(InfPrice(120)),GetFurniName(1734), AddCommas(InfPrice(130)), GetFurniName(2100), AddCommas(InfPrice(800)),GetFurniName(14527), AddCommas(InfPrice(80)));
Respuesta: I have 141 items to add to this list, is there a quicker or better way? -
admantis - 15.04.2015
Do it like this, so you only have to add a new element in the array when you want to expand your furniture list, doing it manually (like you're doing) makes no sense, and it's hard to read.
PHP код:
enum e_furn
{
furnimodel
furniname[32],
furnicost
}
new FurnitureArray[][e_furn] =
{
//
// Model, name, cost
//
{1337, "Trash Bin", 100}
};
//
// Showing the dialog
//
new dialog[1024]; // It has to be large
for(new i = 0; i != sizeof FurnitureArray; i++)
{
format(dialog, sizeof dialog, "%s ($%d)\n%s", FurnitureArray[i][furniname], FurnitureArray[i][furnicost], dialog);
}
// Now just show this dialog
//
// Processing the dialog (this OnDialogResponse)
//
printf("You selected furniture model %d (name: %s)", FurnitureArray[listitem][furnimodel] ,FurnitureInfo[listitem][furniname]);
Re: I have 141 items to add to this list, is there a quicker or better way? -
Dokins - 15.04.2015
Ahhh you're a hero. Thank you very much!
EDIT:
How would I add that to my existing function as I need that!