Dynamic Vehicles
#1

I am trying to add dynamic cars to a game mode.. the template is
Код:
420|0.0|0.0|0.0|0.0|-1|-1|255|0
and the car co-ords i am trying to add are
Код:
567,2217.1907,-1157.1108,25.5951,91.0856,88,64
but when i change the "," to "|" and add them into the carspawns.cfg file the cars dont spawn.. can someone show me the correct way to do it?
Reply
#2

do you have a loading function for the .cfg file?
Reply
#3

Quote:
Originally Posted by FS}Nameless [LDR
]
do you have a loading function for the .cfg file?
pawn Код:
public LoadDynamicCars()
{
    new arrCoords[9][64];
    new strFromFile2[128];
    new File: file = fopen("CRP_Scriptfiles/Cars/carspawns.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(DynamicCars))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, '|');
            DynamicCars[idx][CarModel] = strval(arrCoords[0]);
            DynamicCars[idx][CarX] = floatstr(arrCoords[1]);
            DynamicCars[idx][CarY] = floatstr(arrCoords[2]);
            DynamicCars[idx][CarZ] = floatstr(arrCoords[3]);
            DynamicCars[idx][CarAngle] = floatstr(arrCoords[4]);
            DynamicCars[idx][CarColor1] = strval(arrCoords[5]);
            DynamicCars[idx][CarColor2] = strval(arrCoords[6]);
            DynamicCars[idx][FactionCar] = strval(arrCoords[7]);
            DynamicCars[idx][CarType] = strval(arrCoords[8]);
           
            new vehicleid = CreateVehicle(DynamicCars[idx][CarModel],DynamicCars[idx][CarX],DynamicCars[idx][CarY],DynamicCars[idx][CarZ],DynamicCars[idx][CarAngle],DynamicCars[idx][CarColor1],DynamicCars[idx][CarColor2], -1);

            if(DynamicCars[idx][FactionCar] != 255)
            {
                SetVehicleNumberPlate(vehicleid, DynamicFactions[DynamicCars[idx][FactionCar]][fName]);
                SetVehicleToRespawn(vehicleid);
            }
            idx++;
        }
        fclose(file);
    }
    return 1;
}
Reply
#4

Try using dini instead of io, maybe it works. Its possible because it cant read from the file.
Try a print line above and under the io lines. If it prints on the samp-server.exe that part of the code is correct if it doesn't show up you know where the problem is.
Reply
#5

Quote:
Originally Posted by Oxside
Try using dini instead of io, maybe it works. Its possible because it cant read from the file.
Try a print line above and under the io lines. If it prints on the samp-server.exe that part of the code is correct if it doesn't show up you know where the problem is.
It's loading up alright.. all the cars that are in carspawns.cfg load, its just when i add one car it doesn't load up
Reply
#6

Do not use dini for saving/loading huge amounts of data, unless you want it doing for 15 minutes. Try spliting and 'de-formating' with sscanf
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)