pawn Код:
forward LoadVehicles();
public LoadVehicles()
{
new QueryString[256], count, vehicleid;
//mysql_query( "SELECT id, VehModel,VehOwner, VehColour1, VehColour2, VehPlate, VehSpawnX, VehSpawnY, VehSpawnZ, VehSpawnAngle, VehFuel, VehCash,VehWep1,VehWepA1,VehWep2,VehWepA2, VehArmour,VehFaction,VehFRank, VehOwned, VehFactioned, VehWeed, VehCoke, VehBizID, VehForSale,VehPrice FROM vehicles");
//mysql_store_result();
new x;
new rows, fields;
cache_get_data(rows, fields); // if the rows are more than the size of the variable, reset the rows to match (to avoid run time error 4)
for (new y; y != rows; ++y)
{
cache_get_row(y, vvid, QueryString);
x = cache_get_row_int(y, vvid);
printf("x %d", x);
cache_get_row(y, vVehModel, QueryString);
VehModel[x] = strval( QueryString);
cache_get_row(y, vVehColour1, QueryString);
VehColour1[x] = strval( QueryString);
cache_get_row(y, vVehColour2, QueryString);
VehColour2[x] = strval( QueryString);
cache_get_row(y,vVehSpawnX, QueryString);
VehSpawnX[x] = floatstr( QueryString);
cache_get_row(y,vVehSpawnY, QueryString);
VehSpawnY[x] = floatstr( QueryString);
cache_get_row(y,vVehSpawnZ, QueryString);
VehSpawnZ[x] = floatstr( QueryString);
cache_get_row(y,vVehSpawnAngle, QueryString);
VehSpawnAngle[x] = floatstr( QueryString);
cache_get_row(y,vVehSiren, QueryString);
VehSiren[x] = strval(QueryString);
vehicleid = CreateVehicle(VehModel[x], VehSpawnX[x], VehSpawnY[x],VehSpawnZ[x], VehSpawnAngle[x], VehColour1[x], VehColour2[x], -1, VehSiren[x]);
VehicleSQLID[vehicleid] = x;
VehSiren[vehicleid] = VehSiren[x];
printf("VehSQLID %d", x);
cache_get_row(y,vVehPlate, VehPlate[vehicleid]);
SetVehicleNumberPlate(vehicleid, VehPlate[vehicleid]);
cache_get_row(y,vVehOwner, QueryString);
VehOwner[vehicleid] = strval( QueryString);
cache_get_row(y,vVehJob, QueryString);
VehJob[vehicleid] = strval( QueryString);
cache_get_row(y,vVehFuel, QueryString);
VehFuel[vehicleid] = strval( QueryString);
cache_get_row(y,vVehCash, QueryString);
VehCash[vehicleid] = strval( QueryString);
cache_get_row(y,vVehWeed, QueryString);
VehWeed[vehicleid] = strval( QueryString);
cache_get_row(y,vVehCoke, QueryString);
VehCoke[vehicleid] = strval( QueryString);
cache_get_row(y,vVehLock, QueryString);
VehLock[vehicleid] = strval( QueryString);
cache_get_row(y,vVehAlarm, QueryString);
VehAlarm[vehicleid] = strval( QueryString);
cache_get_row(y,vVehFaction, QueryString);
VehicleFaction[vehicleid] = strval( QueryString);
cache_get_row(y,vVehFRank, QueryString);
VehicleRank[vehicleid] = strval( QueryString);
cache_get_row(y,vVehOwned, QueryString);
VehOwned[vehicleid] = strval( QueryString);
cache_get_row(y,vVehFactioned, QueryString);
VehFactioned[vehicleid] = strval( QueryString);
cache_get_row(y,vVehArmour, QueryString);
VehArmour[vehicleid] = floatstr( QueryString);
cache_get_row(y,vVehBizID, QueryString);
VehBizID[vehicleid] = strval( QueryString);
cache_get_row(y, vVehForSale, QueryString);
VehForSale[vehicleid] = strval( QueryString);
cache_get_row(y,vVehPrice, QueryString);
VehPrice[vehicleid] = strval( QueryString);
cache_get_row(y,vVehWepSlots, QueryString);
VehWepSlots[vehicleid] = strval( QueryString);
cache_get_row(y,vVehFType, QueryString);
VehFType[vehicleid] = strval(QueryString);
cache_get_row(y,vVehSpark, QueryString);
VehSpark[vehicleid] = strval(QueryString);
cache_get_row(y,vVehWater, QueryString);
VehWater[vehicleid] = strval(QueryString);
cache_get_row(y,vVehGear, QueryString);
VehGear[vehicleid] = strval(QueryString);
cache_get_row(y,vVehElec, QueryString);
VehElec[vehicleid] = strval(QueryString);
cache_get_row(y,vVehOil, QueryString);
VehOil[vehicleid] = strval(QueryString);
cache_get_row(y,vVehExhaust, QueryString);
VehExhaust[vehicleid] = strval(QueryString);
cache_get_row(y,vVehFLine, QueryString);
VehFLine[vehicleid] = strval(QueryString);
cache_get_row(y,vVehRadi, QueryString);
VehRadi[vehicleid] = strval(QueryString);
cache_get_row(y,vVehBattery, QueryString);
VehBattery[vehicleid] = strval(QueryString);
cache_get_row(y,vVehFSize, QueryString);
VehFSize[vehicleid] = strval(QueryString);
cache_get_row(y,vVehTyres, QueryString);
VehTyres[vehicleid] = strval(QueryString);
cache_get_row(y,vVehFUsed, QueryString);
VehFUsed[vehicleid] = strval(QueryString);
cache_get_row(y,vVehVMarker, QueryString);
VehVMarker[vehicleid] = strval(QueryString);
cache_get_row(y,vVehFMarker, QueryString);
VehFMarker[vehicleid] = strval(QueryString);
cache_get_row(y,vVehNMarker, QueryString);
VehNMarker[vehicleid] = strval(QueryString);
cache_get_row(y,vVehFSlots, QueryString);
VehFSlots[vehicleid] = strval(QueryString);
cache_get_row(y,vVehHealth, QueryString);
VehHealth[vehicleid] = floatstr(QueryString);
SetVehicleHealth(vehicleid, VehHealth[vehicleid]);
if(VehicleFaction[vehicleid] > 0)
{
new string[12];
format(string, sizeof(string), "%s%d", ShortFName[VehicleFaction[vehicleid]], x);
if(strcmp(string, VehPlate[vehicleid], false))
{
count++;
format(VehPlate[vehicleid], sizeof(VehPlate),"%s%d", ShortFName[VehicleFaction[vehicleid]], x);
MySQL_SetString(x, "VehPlate", VehPlate[vehicleid], "vehicles");
SetVehicleNumberPlate(vehicleid, VehPlate[vehicleid]);
printf("unmatched Vehicle Plates: %d", count);
}
}
if(VehicleFaction[vehicleid] == 0)
{
printf("PLATE %s - not faction", VehPlate[vehicleid]);
SetVehicleNumberPlate(vehicleid, VehPlate[vehicleid]);
}
SetVehicleParamsEx(vehicleid, 0, 0, 0, VehLock[vehicleid], 0, 0, 0);
SetVehicleParamsCarDoors(vehicleid, 0,0,0,0);
SetVehicleParamsCarWindows(vehicleid, 1,1, 1, 1);
if(VehForSale[vehicleid] == 1)
{
new string[128];
new name = VehModel[vehicleid] - 400;
format(string, sizeof(string), "%s, $%s, %s", VehicleNames[name], AddCommas(VehPrice[vehicleid]), VehPlate[vehicleid]);
VehicleLabel[vehicleid] = CreateDynamic3DTextLabel(string, COLOUR_ORANGE, VehSpawnX[vehicleid],VehSpawnY[vehicleid], VehSpawnZ[vehicleid], 100.0, INVALID_PLAYER_ID, vehicleid, 0, 0, -1, -1, 20.0);
Attach3DTextLabelToVehicle(VehicleLabel[vehicleid] ,vehicleid,0.0,0.0,0.0);
}
}
return 1;
}