PDA

View Full Version : Need help with this command.


danielpalade
26/11/2016, 08:52 PM
Hello.

I have this command /myvehicles which displays which vehicles are owned by you.
I also have the variable, "playerSlots" which says how many vehicle slots you have.
This is the command:


CMD:myvehicles(playerid, params[])
{
new aim[1500];
format(aim, 256,"Name\tStatus\tCarplate\tPrice\n");
new stringg[256];
mysql_format(handle, stringg, sizeof(stringg), "SELECT * FROM `vehicles` WHERE `vehicleOwnerID` = %d && `vehicleStatus` = 1",playerVariables[playerid][pInternalID]);
new vehid, vehmodel, cplate[64];
new Cache: result12 = mysql_query (handle, stringg);
for ( new i, j = cache_get_row_count ( ); i != j; ++i )
{
cache_get_field_content(i, "vehicleID", result); vehid = strval(result);
SelVeh[playerid][count] = vehid;
cache_get_field_content(i, "vehicleModelID", result); vehmodel = strval(result);
cache_get_field_content(i, "vehicleNumberPlate", result); format(cplate, 64, result);
if(vehicleVariables[vehid][vVehicleStatus] == 0)
{
format(aim, sizeof(aim), "%s %s\t{%s}[ despawned ]\t%s\t$%s\n", aim, VehicleNames[vehmodel - 400], selColor[175], cplate, NumberFormat(vehPrice[vehmodel]));
}
else
{
format(aim, sizeof(aim), "%s %s\t{%s}[ spawned ]\t%s\t$%s\n", aim, VehicleNames[vehmodel - 400], selColor[226], cplate, NumberFormat(vehPrice[vehmodel]));
}
}
cache_delete(result12);
if(count == 0)
{
SCM(playerid, -1, "You don't own any vehicles.");
}
else
{
ShowPlayerDialog(playerid, DIALOG_DISPLAY_VEHICLES, DIALOG_STYLE_TABLIST_HEADERS, "My Vehicles",aim,"Select","Cancel");
}
return 1;
}


Now let's say I have 2 vehicles, and 5 slots.
That means that 3 slots would be empty.
How can I make it so when you do /myvehicles, it shows the vehicles you have, and after them, it will show how many empty slots you have. So the dialog would look like this:

Infernus [ spawned ] 84Hsa7 $100,000
Bullet [ spawned ] 84Hsa7 $100,000
- empty -
- empty -
- empty -

So basically it would add "- empty -" under each other, as many times as you have free slots.

How can I do this?

Vince
26/11/2016, 10:05 PM
You've done the math. Just create a loop to append the remaining slots.