C:\Users\Nate\Desktop\test\gamemodes\test.pwn(6517 -- 6530) : warning 213: tag mismatch C:\Users\Nate\Desktop\test\gamemodes\test.pwn(6517 -- 6530) : error 032: array index out of bounds (variable "GarageInfo")
enum gInfo
{
gEnterX,
gEnterY,
gEnterZ,
gEnterAngle,
gExitX,
gExitY,
gExitZ,
gExitAngle,
gOwned,
gOwner,
gPrice,
gLocked,
gPickupID
};
new GarageInfo[SCRIPT_MAXGARGES][gInfo];
public SaveGarage()
{
new idx, File: file2, coordsstring[256];
while (idx < sizeof(GarageInfo))
{
format(coordsstring, sizeof(coordsstring), "%f|%f|%f|%f|%f|%f|%f|%f|%d|%s|%d|%d\n",
GarageInfo[idx][gEnterX],
GarageInfo[idx][gEnterY],
GarageInfo[idx][gEnterZ],
GarageInfo[idx][gEnterAngle],
GarageInfo[idx][gExitX],
GarageInfo[idx][gExitY],
GarageInfo[idx][gExitZ],
GarageInfo[idx][gExitAngle],
GarageInfo[idx][gOwned],
GarageInfo[idx][gOwner],
GarageInfo[idx][gPrice],
GarageInfo[idx][gLocked],
GarageInfo[idx][hPickupID]);
if(idx == 0) file2 = fopen("garage.ini", io_write);
else file2 = fopen("garage.ini", io_append);
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
public LoadGarage()
{
printf("Loading Garages...");
new arrCoords[13][64], strFromFile2[256];
new File: file = fopen("garage.ini", io_read);
if (file)
{
new idx;
while (idx < sizeof(GarageInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
GarageInfo[idx][gEnterX] = floatstr(arrCoords[0]);
GarageInfo[idx][gEnterY] = floatstr(arrCoords[1]);
GarageInfo[idx][gEnterZ] = floatstr(arrCoords[2]);
GarageInfo[idx][gEnterAngle] = floatstr(arrCoords[3]);
GarageInfo[idx][gExitX] = floatstr(arrCoords[4]);
GarageInfo[idx][gExitY] = floatstr(arrCoords[5]);
GarageInfo[idx][gExitZ] = floatstr(arrCoords[6]);
GarageInfo[idx][gExitAngle] = floatstr(arrCoords[7]);
GarageInfo[idx][gOwned] = strval(arrCoords[8]);
strmid(GarageInfo[idx][gOwner], arrCoords[9], 0, strlen(arrCoords[9]), 255);
GarageInfo[idx][gPrice] = strval(arrCoords[10]);
GarageInfo[idx][gLocked] = strval(arrCoords[11]);
GarageInfo[idx][gPickupID] = strval(arrCoords[12]);
idx++;
}
}
fclose(file);
return 1;
}
enum gInfo
{
gEnterX,
gEnterY,
gEnterZ,
gEnterAngle,
gExitX,
gExitY,
gExitZ,
gExitAngle,
gOwned,
gOwner,
gPrice,
gLocked,
gPickupID,
};
new GarageInfo[SCRIPT_MAXGARGES][gInfo];
gOwner
gOwner[MAX_PLAYER_NAME],
gEnterX, gEnterY, gEnterZ, gEnterAngle, gExitX, gExitY, gExitZ, gExitAngle,
GarageInfo[idx][hPickupID]);
I want to add that it is terrible practice to open and close the file for each line written. This leads to lots of unnecessary IO and it is very slow. Open file, loop, close files. The structure also does not follow the INI file format so it shouldn't realistically have the extension .ini, either.
|
Код:
gOwner Код:
gOwner[MAX_PLAYER_NAME], Код:
gEnterX, gEnterY, gEnterZ, gEnterAngle, gExitX, gExitY, gExitZ, gExitAngle, Код:
GarageInfo[idx][hPickupID]); |
Open file before loop. Do the entire loop. Close the file after loop. I reckon my earlier instructions were pretty straightforward.
|