Easiest Way to do this? -
Dokins - 28.03.2012
Basically, instead of trying to write all possible combinations of if statements, how can I effectively display all the vehicles in the persons slots? It only displays one, otherwise..
How can I get my MSGBOX to display like this:
some of the code is here, I don't mean about plates etc, It's just like if a slot is empty, i don't want it to display, but adding a new line to each.
pawn Код:
for(new v = 1; v < MAX_VEHICLES; v++)
{
new name = GetVehicleModel(v) - 400;
printf("Vehicle ID: %d", VehicleSQLID[v]);
VehicleSQLID[v] = MySQL_GetValue(VehicleSQLID[v], "id", "vehicles");
if(VehicleSlot1[playerid] == VehicleSQLID[v] || VehicleSlot2[playerid] == VehicleSQLID[v] || VehicleSlot3[playerid] == VehicleSQLID[v])
{
format(string, sizeof(string), "Vehicles for %s", GetNameEx(playerid));
if(VehicleSlot1[playerid] > 0 && VehicleSlot2[playerid] > 0 && VehicleSlot3[playerid] > 0)
{
format(string1, sizeof(string1), "%s - (%d)\n2. %s - (%d)\n 3. %s - (%d)\n", VehicleNames[name], v);
}
ShowPlayerDialog(playerid,DIALOG_SHOWCAR,DIALOG_STYLE_MSGBOX,string, string1,"Close","");
}
}
return 1;
}
Re: Easiest Way to do this? -
Jonny5 - 28.03.2012
well the way it looks to me is your code would have to work slightly different
like instead of VehicleSlot1[playerid]
you need a 2d array that you can loop threw
like
pawn Код:
VehicleSlots[playerid][SlotID];
but after another look you might get away with trying this code using or || instead of and &&
pawn Код:
if(VehicleSlot1[playerid] > 0 || VehicleSlot2[playerid] > 0 || VehicleSlot3[playerid] > 0)
this will display the dialog if they have 1 or more matches
also this code is not right
pawn Код:
format(string1, sizeof(string1), "%s - (%d)\n2. %s - (%d)\n 3. %s - (%d)\n", VehicleNames[name], v);
it will only format the first %s and the first %d as you provide no arguments for the others
youll really have to rework all the code i suspect to get it working correctly.
Re: Easiest Way to do this? -
Dokins - 28.03.2012
Yes, but I need to add the string...
Re: Easiest Way to do this? -
Jonny5 - 28.03.2012
yes I know that but your not providing enough arguments for the string to add all the data
you only provide enough for 1 car, its name and id
look in the basic scripting tutorials and pawn-lang.pdf to understand the use of format.
also if you posted ALL the code related to this might be easier for us to help,
regards.