Need help with car system!!
#5

Okay i've changed the LoadCars and SaveCars to this :

pawn Код:
public LoadCars()
{
    new arrCoords[9][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][CarDescription], arrCoords[0], 0, strlen(arrCoords[0]), 255);
            Cars[idx][CarModel] = strval(arrCoords[1]);
            Cars[idx][CarX] = floatstr(arrCoords[2]);
            Cars[idx][CarY] = floatstr(arrCoords[3]);
            Cars[idx][CarZ] = floatstr(arrCoords[4]);
            Cars[idx][CarAngle] = floatstr(arrCoords[5]);
            Cars[idx][CarCol1] = strval(arrCoords[6]);
            Cars[idx][CarCol2] = strval(arrCoords[7]);
            Cars[idx][CarOwned] = strval(arrCoords[8]);
            strmid(Cars[idx][CarOwner], arrCoords[9], 0, strlen(arrCoords[9]), 255);
            CreateVehicle(Cars[idx][CarModel],Cars[idx][CarX],Cars[idx][CarY],Cars[idx][CarZ],Cars[idx][CarAngle],Cars[idx][CarCol1],Cars[idx][CarCol2], -1);
            idx++;
        }
        fclose(file);
    }
    return 1;
}
public SaveCars()
{
    new idx;
    new File: file2;
    while (idx < sizeof(Cars))
    {
        new coordsstring[512];
        format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d|%d|%d\n",
        Cars[idx][CarDescription],
        Cars[idx][CarModel],
        Cars[idx][CarX],
        Cars[idx][CarY],
        Cars[idx][CarZ],
        Cars[idx][CarAngle],
        Cars[idx][CarCol1],
        Cars[idx][CarCol2],
        Cars[idx][CarOwned],
        Cars[idx][CarOwner]);
        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;
}
but theres problem with this line:

pawn Код:
strmid(Cars[idx][CarOwner], arrCoords[9], 0, strlen(arrCoords[9]), 255);
arrCoords indexed out of bounds < error and can't compile? whats problem?
Reply


Messages In This Thread
Need help with car system!! - by coole210 - 13.07.2009, 19:28
Re: Need help with car system!! - by yezizhu - 13.07.2009, 20:09
Re: Need help with car system!! - by coole210 - 13.07.2009, 23:26
Re: Need help with car system!! - by coole210 - 14.07.2009, 01:02
Re: Need help with car system!! - by coole210 - 14.07.2009, 01:35
Re: Need help with car system!! - by Abernethy - 14.07.2009, 01:45
Re: Need help with car system!! - by Calgon - 14.07.2009, 04:00
Re: Need help with car system!! - by coole210 - 14.07.2009, 16:12
Re: Need help with car system!! - by coole210 - 14.07.2009, 17:52
Re: Need help with car system!! - by yezizhu - 15.07.2009, 00:38

Forum Jump:


Users browsing this thread: 2 Guest(s)