// Loop all personal vehicles
stock LoopVehicles()
{
new query[500], savestring[200], Cars[128];
for(new vid = 1; vid < MAX_VEHICLES; vid++)
{
format(query, sizeof(query), "SELECT * FROM Vehicles WHERE vID='%i'", vid);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query, "|"))
{
mysql_fetch_field_row(savestring, "vID"); VehInfo[vid][vID] = strval(savestring);
format(VehInfo[vid][Owner], MAX_PLAYER_NAME, "%s", mysql_fetch_field_row(savestring, "Owner"));
//mysql_fetch_field_row(savestring, "Owner"); format(VehInfo[vid][Owner], 24, "%s",savestring);
mysql_fetch_field_row(savestring, "SpawnX"); VehInfo[vid][SpawnX] = strval(savestring);
mysql_fetch_field_row(savestring, "SpawnY"); VehInfo[vid][SpawnY] = strval(savestring);
mysql_fetch_field_row(savestring, "SpawnZ"); VehInfo[vid][SpawnZ] = strval(savestring);
mysql_fetch_field_row(savestring, "SpawnAngle"); VehInfo[vid][SpawnAngle] = strval(savestring);
mysql_fetch_field_row(savestring, "Model"); VehInfo[vid][Model] = strval(savestring);
mysql_fetch_field_row(savestring, "BelongsTo"); VehInfo[vid][BelongsToHouse] = strval(savestring);
mysql_fetch_field_row(savestring, "Price"); VehInfo[vid][Price] = strval(savestring);
mysql_fetch_field_row(savestring, "SellPrice"); VehInfo[vid][SellPrice] = strval(savestring);
mysql_fetch_field_row(savestring, "color1"); VehInfo[vid][color1] = strval(savestring);
mysql_fetch_field_row(savestring, "color2"); VehInfo[vid][color2] = strval(savestring);
}
mysql_free_result();
CreateVehicle(VehInfo[vid][Model], VehInfo[vid][SpawnX], VehInfo[vid][SpawnY], VehInfo[vid][SpawnZ], VehInfo[vid][SpawnAngle], VehInfo[vid][color1], VehInfo[vid][color2], 200);
format(Cars, sizeof(Cars), "{ff6600}%s owner:\n%s",GetVehicleFriendlyName(vid), VehInfo[vid][Owner]);
VehLabel[vid] = Create3DTextLabel(Cars, 0xFFFFFFFF, 0.0, 0.0, 0.0, 50.0, -1, 0);
Attach3DTextLabelToVehicle(VehLabel[vid], vid, 0.0, 0.0, 0.4);
}
return 1;
}
mysql_store_result();
if(mysql_num_rows() > 0)
How do you mean with I should increment the 'vid' into the while loop?
|
// Loop all personal vehicles
stock LoopVehicles()
{
savestring[200], Cars[128];
new vid; // idx
mysql_query("SELECT * FROM Vehicles");
mysql_store_result();
while(mysql_fetch_row_format(query, "|"))
{
mysql_fetch_field_row(savestring, "vID"); VehInfo[vid][vID] = strval(savestring);
format(VehInfo[vid][Owner], MAX_PLAYER_NAME, "%s", mysql_fetch_field_row(savestring, "Owner"));
//mysql_fetch_field_row(savestring, "Owner"); format(VehInfo[vid][Owner], 24, "%s",savestring);
mysql_fetch_field_row(savestring, "SpawnX"); VehInfo[vid][SpawnX] = strval(savestring);
mysql_fetch_field_row(savestring, "SpawnY"); VehInfo[vid][SpawnY] = strval(savestring);
mysql_fetch_field_row(savestring, "SpawnZ"); VehInfo[vid][SpawnZ] = strval(savestring);
mysql_fetch_field_row(savestring, "SpawnAngle"); VehInfo[vid][SpawnAngle] = strval(savestring);
mysql_fetch_field_row(savestring, "Model"); VehInfo[vid][Model] = strval(savestring);
mysql_fetch_field_row(savestring, "BelongsTo"); VehInfo[vid][BelongsToHouse] = strval(savestring);
mysql_fetch_field_row(savestring, "Price"); VehInfo[vid][Price] = strval(savestring);
mysql_fetch_field_row(savestring, "SellPrice"); VehInfo[vid][SellPrice] = strval(savestring);
mysql_fetch_field_row(savestring, "color1"); VehInfo[vid][color1] = strval(savestring);
mysql_fetch_field_row(savestring, "color2"); VehInfo[vid][color2] = strval(savestring);
CreateVehicle(VehInfo[vid][Model], VehInfo[vid][SpawnX], VehInfo[vid][SpawnY], VehInfo[vid][SpawnZ], VehInfo[vid][SpawnAngle], VehInfo[vid][color1], VehInfo[vid][color2], 200);
format(Cars, sizeof(Cars), "{ff6600}%s owner:\n%s",GetVehicleFriendlyName(vid), VehInfo[vid][Owner]);
VehLabel[vid] = Create3DTextLabel(Cars, 0xFFFFFFFF, 0.0, 0.0, 0.0, 50.0, -1, 0);
Attach3DTextLabelToVehicle(VehLabel[vid], vid, 0.0, 0.0, 0.4);
vid++; // HERE
}
mysql_free_result();
return 1;
}