//==============================================================================
public LoadCar()
{
new arrCoords[30][64];
new strFromFile2[256];
new File: file = fopen("dealership.cfg", io_read);
if (file)
{
new idx = 0;
while (idx < sizeof(CarInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
CarInfo[idx][vModel] = strval(arrCoords[0]);
CarInfo[idx][vLocationx] = floatstr(arrCoords[1]);
CarInfo[idx][vLocationy] = floatstr(arrCoords[2]);
CarInfo[idx][vLocationz] = floatstr(arrCoords[3]);
CarInfo[idx][vAngle] = floatstr(arrCoords[4]);
CarInfo[idx][vColorOne] = strval(arrCoords[5]);
CarInfo[idx][vColorTwo] = strval(arrCoords[6]);
strmid(CarInfo[idx][vOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
strmid(CarInfo[idx][vDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
CarInfo[idx][vValue] = strval(arrCoords[9]);
CarInfo[idx][vLicense] = strval(arrCoords[10]);
CarInfo[idx][vOwned] = strval(arrCoords[11]);
CarInfo[idx][vLock] = strval(arrCoords[12]);
CarInfo[idx][vMod1] = strval(arrCoords[13]);
CarInfo[idx][vMod2] = strval(arrCoords[14]);
CarInfo[idx][vMod3] = strval(arrCoords[15]);
CarInfo[idx][vMod4] = strval(arrCoords[16]);
CarInfo[idx][vMod5] = strval(arrCoords[17]);
CarInfo[idx][vMod6] = strval(arrCoords[18]);
CarInfo[idx][vMod7] = strval(arrCoords[19]);
CarInfo[idx][vMod8] = strval(arrCoords[20]);
CarInfo[idx][vMod9] = strval(arrCoords[21]);
CarInfo[idx][vMod10] = strval(arrCoords[22]);
CarInfo[idx][vMod11] = strval(arrCoords[23]);
CarInfo[idx][vMod12] = strval(arrCoords[24]);
CarInfo[idx][vMod13] = strval(arrCoords[25]);
CarInfo[idx][vMod14] = strval(arrCoords[26]);
CarInfo[idx][vMod15] = strval(arrCoords[27]);
CarInfo[idx][vMod16] = strval(arrCoords[28]);
CarInfo[idx][vMod17] = strval(arrCoords[29]);
CarInfo[idx][ownedvehicle] = CreateVehicle(CarInfo[idx][vModel],CarInfo[idx][vLocationx],CarInfo[idx][vLocationy],CarInfo[idx][vLocationz],CarInfo[idx][vAngle],CarInfo[idx][vColorOne],CarInfo[idx][vColorTwo],300000);
printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][vOwner],CarInfo[idx][vLicense]);
idx++;
}
}
return 1;
}
//==============================================================================
public SaveCars()
{
new idx;
new File: file2;
while (idx < sizeof(CarInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\r\n",
CarInfo[idx][vModel],
CarInfo[idx][vLocationx],
CarInfo[idx][vLocationy],
CarInfo[idx][vLocationz],
CarInfo[idx][vAngle],
CarInfo[idx][vColorOne],
CarInfo[idx][vColorTwo],
CarInfo[idx][vOwner],
CarInfo[idx][vDescription],
CarInfo[idx][vValue],
CarInfo[idx][vLicense],
CarInfo[idx][vOwned],
CarInfo[idx][vLock],
CarInfo[idx][vMod1],
CarInfo[idx][vMod2],
CarInfo[idx][vMod3],
CarInfo[idx][vMod4],
CarInfo[idx][vMod5],
CarInfo[idx][vMod6],
CarInfo[idx][vMod7],
CarInfo[idx][vMod8],
CarInfo[idx][vMod9],
CarInfo[idx][vMod10],
CarInfo[idx][vMod11],
CarInfo[idx][vMod12],
CarInfo[idx][vMod13],
CarInfo[idx][vMod14],
CarInfo[idx][vMod15],
CarInfo[idx][vMod16],
CarInfo[idx][vMod17]);
if(idx == 0)
{
file2 = fopen("dealership.cfg", io_write);
}
else
{
file2 = fopen("dealership.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
//==============================================================================
enum vInfo
{
vModel,
Float:vLocationx,
Float:vLocationy,
Float:vLocationz,
Float:vAngle,
vColorOne,
vColorTwo,
vOwner[MAX_PLAYER_NAME],
vDescription[MAX_PLAYER_NAME],
vValue,
vLicense,
vRegistration,
vOwned,
vLock,
ownedvehicle,
vMod1,
vMod2,
vMod3,
vMod4,
vMod5,
vMod6,
vMod7,
vMod8,
vMod9,
vMod10,
vMod11,
vMod12,
vMod13,
vMod14,
vMod15,
vMod16,
vMod17
};
new CarInfo[200][vInfo];
560,-2705.624267,224.065734,3.844985,189.970138,0,0,Louis,,20000,,1,0,1139,1009,1169,1141,1028,0,0,0,1032,1026,0,1087,1086,0,0,1079,0,
printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][vOwner],CarInfo[idx][vLicense]);
for(new i = 0; i < sizeof(CarInfo); i++)
{
if(CarInfo[i][ownedvehicle] == vehicleid)
{
ChangeVehicleColor(CarInfo[i][ownedvehicle],CarInfo[i][vColorOne],CarInfo[i][vColorTwo]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod1]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod2]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod3]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod4]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod5]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod6]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod7]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod8]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod9]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod10]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod11]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod12]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod13]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod14]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod15]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod16]);
AddVehicleComponent(CarInfo[i][ownedvehicle],CarInfo[i][vMod17]);
}
}
#define MAX_CARS 200
for(new i = 0; i < MAX_CARS; i++)
At the top of ur GM:
pawn Код:
pawn Код:
|