Код:
stock vehicleLoad() {
mysql_tquery(g_iHandle, "SELECT * FROM `"TABLE_VEHICLES"`", "onVehicleLoad", "");
}
private onVehicleLoad() {
static
rows,
fields;
cache_get_data(rows, fields, g_iHandle);
for (new i = 0; i < rows; i ++) if (i < MAX_VEHICLES)
{
vehicle::Data[i][vSpawn] = cache_get_field_content_int(i, "Spawn");
if(vehicle::Data[i][vSpawn] == 1)
{
vehicle::Data[i][vPos][0] = cache_get_field_content_float(i, "X");
vehicle::Data[i][vPos][1] = cache_get_field_content_float(i, "Y");
vehicle::Data[i][vPos][2] = cache_get_field_content_float(i, "Z");
vehicle::Data[i][vPos][3] = cache_get_field_content_float(i, "A");
vehicle::Data[i][vModel] = cache_get_field_content_int(i, "Model");
vehicle::Data[i][vColor][1] = cache_get_field_content_int(i, "Boja1");
vehicle::Data[i][vColor][2] = cache_get_field_content_int(i, "Boja2");
vehicle::Data[i][vRespawn] = cache_get_field_content_int(i, "Respawn");
vehicle::Data[i][vUsedFor] = cache_get_field_content_int(i, "UsedFor");
vehicle::Data[i][vOrg] = cache_get_field_content_int(i, "Organizacija");
vehicle::Data[i][vJob] = cache_get_field_content_int(i, "Posao");
vehicle::Data[i][vCity] = cache_get_field_content_int(i, "Grad");
vehicleRefresh(i);
}
}
numOfVehicles = rows;
printf("[SQL]: Uspesno ucitano %d vozila.", numOfVehicles); //Successfully loaded 396 vehicles.
return true;
}