19.01.2012, 15:00
well, I made a cars' system and it's works enough good but it's a limit of vehicles, how remove the limit?
note limit is 28 cars
note limit is 28 cars
pawn Код:
enum CarSystem
{
cDescription[MAX_PLAYER_NAME],
cOwner[MAX_PLAYER_NAME],
Float:cX,
Float:cY,
Float:cZ,
Float:cTempX,
Float:cTempY,
Float:cTempZ,
Float:cAngle,
Float:cTempAngle,
cOwned,
cPrice,
cLocked,
cModel,
cCol1,
cCol2,
ownedvehicle,
ccLocked,
};
new Cars[28][CarSystem];
public LoadCars()
{
new arrCoords[17][64];
new strFromFile2[256];
new File: file = fopen("Cars/cars.cfg",io_read);
if (file)
{
new idx;
while (idx < sizeof(Cars))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
strmid(Cars[idx][cDescription], arrCoords[0], 0, strlen(arrCoords[0]), 255);
strmid(Cars[idx][cOwner], arrCoords[1], 0, strlen(arrCoords[1]), 255);
Cars[idx][cModel] = strval(arrCoords[2]);
Cars[idx][cX] = floatstr(arrCoords[3]);
Cars[idx][cY] = floatstr(arrCoords[4]);
Cars[idx][cZ] = floatstr(arrCoords[5]);
Cars[idx][cAngle] = floatstr(arrCoords[6]);
Cars[idx][cOwned] = strval(arrCoords[7]);
Cars[idx][cPrice] = strval(arrCoords[8]);
Cars[idx][cLocked] = strval(arrCoords[9]);
Cars[idx][cCol1] = strval(arrCoords[10]);
Cars[idx][cCol2] = strval(arrCoords[11]);
Cars[idx][cTempX] = floatstr(arrCoords[12]);
Cars[idx][cTempY] = floatstr(arrCoords[13]);
Cars[idx][cTempZ] = floatstr(arrCoords[14]);
Cars[idx][cTempAngle] = floatstr(arrCoords[15]);
Cars[idx][cTempX] = Cars[idx][cX];
Cars[idx][cTempY] = Cars[idx][cY];
Cars[idx][cTempZ] = Cars[idx][cZ];
Cars[idx][cTempAngle] = Cars[idx][cAngle];
Cars[idx][ccLocked] = strval(arrCoords[16]);
Cars[idx][ownedvehicle] = CreateVehicle(Cars[idx][cModel],Cars[idx][cX],Cars[idx][cY],Cars[idx][cZ],Cars[idx][cAngle],Cars[idx][cCol1],Cars[idx][cCol2],10000);
idx++;
}
fclose(file);
}
return 1;
}
public SaveCars()
{
new idx;
new File: file2;
while (idx < sizeof(Cars))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%s|%s|%d|%f|%f|%f|%f|%d|%d|%d|%d|%d|%f|%f|%f|%f|%d\n",
Cars[idx][cDescription],
Cars[idx][cOwner],
Cars[idx][cModel],
Cars[idx][cX],
Cars[idx][cY],
Cars[idx][cZ],
Cars[idx][cAngle],
Cars[idx][cOwned],
Cars[idx][cPrice],
Cars[idx][cLocked],
Cars[idx][cCol1],
Cars[idx][cCol2],
Cars[idx][cTempX],
Cars[idx][cTempY],
Cars[idx][cTempZ],
Cars[idx][cTempAngle],
Cars[idx][ccLocked]);
if(idx == 0)
{
file2 = fopen("Cars/cars.cfg",io_write);
}
else
{
file2 = fopen("Cars/cars.cfg",io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}