So i made the saving part, but the problem is now loading part

Started by Kewun, Jul 27, 2016, 08:19 AM

Previous topic - Next topic

Kewun

function LoadCars()
{
for(local a = 0; a < GetVehicleCount(); a ++)
{
local vee = FindVehicle(a);
if(vee) {
vee.Model = ReadIniInteger("Stats.ini","VehicleModels","Vehicle ID"+vee.ID)
vee.ID = ReadIniInteger("Stats.ini","VehiclesIDS", "Vehicle Model "+vee.Model)
vee.Pos.x = ReadIniNumber("Stats.ini","VehiclesX", "Vehicle Model "+vee.ID)
vee.Pos.y = ReadIniNumber("Stats.ini","VehiclesY", "Vehicle Model "+vee.ID)
vee.Pos.z = ReadIniNumber("Stats.ini","VehiclesZ", "Vehicle Model "+vee.ID)
Message("[#ffffff]Loading Vehicle's, please stand-by")
}
}
}
function SaveCars()
{
for(local a = 0; a < GetVehicleCount(); a ++)
{
local vee = FindVehicle(a);
if(vee) {
WriteIniInteger("Stats.ini","VehicleModels","Vehicle ID"+vee.ID, vee.Model)
WriteIniInteger("Stats.ini","VehiclesIDS", "Vehicle Model "+vee.Model, vee.ID)
WriteIniNumber("Stats.ini","VehiclesX", "Vehicle Model "+vee.ID, vee.Pos.x)
WriteIniNumber("Stats.ini","VehiclesY", "Vehicle Model "+vee.ID, vee.Pos.y)
WriteIniNumber("Stats.ini","VehiclesZ", "Vehicle Model "+vee.ID, vee.Pos.z)
Message("[#ffffff]Saving all vehicle's. please stand- by ")
}
}
}

The laoding doesn't work.

erorr : member variable not found, line 124
line 124 is:          vee.Model = ReadIniInteger("Stats.ini","VehicleModels","Vehicle ID"+vee.ID)

in the loadcars function.

how to fix it so i can load all cars positions and etc?

KAKAN

I don't think that INIs support spaces in them though :D
But if it does, then, the problem is, you're finding the vehicle in LoadCars where the vehicles aren't created.
Use CreateVehicle instead
oh no

Kewun

nah, CreateVehicle returns  a error

no overload matching this argment list found
i use:
CreateVehicle(ReadIniInteger("Stats.ini","VehicleModels","Vehicle ID"+vee.ID),ReadIniNumber("Stats.ini","VehiclesX", "Vehicle Model "+vee.ID), ReadIniNumber("Stats.ini","VehiclesY", "Vehicle Model "+vee.ID), WriteIniNumber("Stats.ini","VehiclesZ", "Vehicle Model "+vee.ID, vee.Pos.z), 0, 1,1 )


fixed the write thing in the create vehicle

now: wrong number of parametrs

KAKAN

Use locals and then compare your params, the code you gave looks shit to read :p
oh no

Kewun


Kewun

thx man ur the best in the world man i love you (no homo) you're the best m8 i was working on this shit for years now til now thx man now it works without errors nad gay shit crashes man ur best thx <#