SA-MP Forums Archive
DJson issue (Reading from file) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: DJson issue (Reading from file) (/showthread.php?tid=400118)



DJson issue (Reading from file) - nmader - 17.12.2012

Alright, I am using DracoBlue's DJson saving and reading system for saving car files as well as reading them. I have narrowed down a problem that prevents the car from being read in the file to the reading system itself. Here is what I have:
pawn Код:
stock InitVehicles()
{
    new Vehicle[16];
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        format(Vehicle, sizeof(Vehicle), "V_%d", i);
        if(djIsSet(VEHICLES_FILE, Vehicle))
        {
            format(Vehicle, sizeof(Vehicle), "V_%d/PosX", i);
            Vehicles[i][CarPosX] = djFloat(VEHICLES_FILE, Vehicle, true);
            format(Vehicle, sizeof(Vehicle), "V_%d/PosY", i);
            Vehicles[i][CarPosY] = djFloat(VEHICLES_FILE, Vehicle, true);
            format(Vehicle, sizeof(Vehicle), "V_%d/PosZ", i);
            Vehicles[i][CarPosZ] = djFloat(VEHICLES_FILE, Vehicle, true);
            format(Vehicle, sizeof(Vehicle), "V_%d/ZAngle", i);
            Vehicles[i][CarZAngle] = djFloat(VEHICLES_FILE, Vehicle, true);
            format(Vehicle, sizeof(Vehicle), "V_%d/Model", i);
            Vehicles[i][CarModel] = djInt(VEHICLES_FILE, Vehicle, true);
            format(Vehicle, sizeof(Vehicle), "V_%d/Col1", i);
            Vehicles[i][CarColor1] = djInt(VEHICLES_FILE, Vehicle, true);
            format(Vehicle, sizeof(Vehicle), "V_%d/Col2", i);
            Vehicles[i][CarColor2] = djInt(VEHICLES_FILE, Vehicle, true);
            format(Vehicle, sizeof(Vehicle), "V_%d/Military", i);
            Vehicles[i][CarMilitary] = djInt(VEHICLES_FILE, Vehicle, true);
            format(Vehicle, sizeof(Vehicle), "V_%d/Fuel", i);
            Vehicles[i][Fuel] = djInt(VEHICLES_FILE, Vehicle, true);
            format(Vehicle, sizeof(Vehicle), "V_%d/Rank", i);
            Vehicles[i][CarRank] = djInt(VEHICLES_FILE, Vehicle, true);

            if(Vehicles[i][CarModel] != 537 && Vehicles[i][CarModel] != 538 && Vehicles[i][CarModel] != 569 && 570 && Vehicles[i][CarModel] != 590)
            {
                Vehicles[i][GameID] = AddStaticVehicleEx(Vehicles[i][CarModel], Vehicles[i][CarPosX], Vehicles[i][CarPosY], Vehicles[i][CarPosZ], Vehicles[i][CarZAngle], Vehicles[i][CarColor1], Vehicles[i][CarColor2], 3600);
            }

            printf("[system] InitVehicles(): Vehicle %d has spawned (spawned from %s).", i, VEHICLES_FILE);
        }
    }
}
I am not very experienced with DJson; however on pre-existing gamemodes I tested out it seemed to be rather reliable! That being said and help will be appreciated and if you respond professionally and informatively you are likely to receive reputation

~Nmader


Re: DJson issue (Reading from file) - nmader - 17.12.2012

I apologize for this; however I just realized my problem.

To anyone having this problem just don't forget to put:
pawn Код:
InitVehicles();
under OnGameModeInit.