01.12.2012, 14:48
pawn Код:
forward OnLoadVehicles();
public OnLoadVehicles()
{
new fields, rows;
cache_get_data(rows, fields);
new index = 0, result[100];
printf("%d rows", rows);
for(new v = 0; v < rows; v ++)
{
index = v;
// LOADING DATA \====================================================================/
cache_get_row(0, 0, result); vInfo[index][vCariD] = strval(result);
cache_get_row(0, 1, result); vInfo[index][vModel] = strval(result);
cache_get_row(0, 2, result); vInfo[index][vColor1] = strval(result);
cache_get_row(0, 3, result); vInfo[index][vColor2] = strval(result);
cache_get_row(0, 4, result); vInfo[index][vPrice] = strval(result);
cache_get_row(0, 5, result); strmid(vInfo[index][vOwner], result, false, strlen(result), 24);
cache_get_row(0, 6, result); vInfo[index][vPosX] = floatstr(result);
cache_get_row(0, 7, result); vInfo[index][vPosY] = floatstr(result);
cache_get_row(0, 8, result); vInfo[index][vPosZ] = floatstr(result);
cache_get_row(0, 9, result); vInfo[index][vPosA] = floatstr(result);
cache_get_row(0, 10, result); strmid(vInfo[index][vPlate], result, false, strlen(result), 24);
cache_get_row(0, 11, result); vInfo[index][vPaintJ] = strval(result);
cache_get_row(0, 12, result); vInfo[index][vLocked] = strval(result);
cache_get_row(0, 13, result); vInfo[index][vTowed] = strval(result);
cache_get_row(0, 14, result); vMods[index][0] = strval(result);
cache_get_row(0, 15, result); vMods[index][1] = strval(result);
cache_get_row(0, 16, result); vMods[index][2] = strval(result);
cache_get_row(0, 17, result); vMods[index][3] = strval(result);
cache_get_row(0, 18, result); vMods[index][4] = strval(result);
cache_get_row(0, 19, result); vMods[index][5] = strval(result);
cache_get_row(0, 20, result); vMods[index][6] = strval(result);
cache_get_row(0, 21, result); vMods[index][7] = strval(result);
cache_get_row(0, 22, result); vMods[index][8] = strval(result);
cache_get_row(0, 23, result); vMods[index][9] = strval(result);
cache_get_row(0, 24, result); vMods[index][10] = strval(result);
cache_get_row(0, 25, result); vMods[index][11] = strval(result);
cache_get_row(0, 26, result); vInfo[index][vExploded] = strval(result);
// CREATING VEHICLE \====================================================================/
new i = index;
if(vInfo[i][vPosX] == 0.0 && vInfo[i][vPosY] == 0.0 && vInfo[i][vPosZ] == 0.0) { ++ Total_Veh_Created; continue; }
new
vCarID = CreateVehicle(vInfo[i][vModel], vInfo[i][vPosX], vInfo[i][vPosY], vInfo[i][vPosZ], vInfo[i][vPosA], vInfo[i][vColor1], vInfo[i][vColor2], 500000);
SetVehicleNumberPlate(vCarID, vInfo[i][vPlate]);
ChangeVehiclePaintjob(vCarID, vInfo[i][vPaintJ]);
OwnedVeh(vCarID) = index;
for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod)
{
if(vMods[index][iMod] > 0)
{
AddVehicleComponent(vCarID, vMods[index][iMod]);
}
}
Total_Veh_Created = vInfo[index][vCariD];
}
printf("%d cars created!", Total_Veh_Created);
return 1;
}