24.08.2010, 10:27
Okay so, I'm working on a vehicle ownership system, and I got an issue with loading the vehicles.
Each vehicle has a file (VehX)
X is a number (if you format it, its Veh%d) I hope you get it..
Anyway, its a dynamic system, which means I can add & edit them in game by simple commands.
Lets say I got files, Veh1, Veh2, Veh3, Veh4
If I load them, its all good and works properly.
But if I would delete Veh2 and Veh3, then Veh1 loads properly, but not Veh4
If I add a vehicle (Not a file, just a vehicle) then it reads Veh4.. And thats the problem.. kinda
Thats how it works:
Each vehicle has a file (VehX)
X is a number (if you format it, its Veh%d) I hope you get it..
Anyway, its a dynamic system, which means I can add & edit them in game by simple commands.
Lets say I got files, Veh1, Veh2, Veh3, Veh4
If I load them, its all good and works properly.
But if I would delete Veh2 and Veh3, then Veh1 loads properly, but not Veh4
If I add a vehicle (Not a file, just a vehicle) then it reads Veh4.. And thats the problem.. kinda
Thats how it works:
pawn Код:
public LoadVehicles()
{
new file[128];
for(new v = 1; v < MAX_VEHICLES; v++)
{
format(file, 128, "LVRP/Vehicles/Veh%d.ini", v);
if(dini_Exists(file))
{
VehicleInfo[v][vID] = dini_Int(file, "ID");
VehicleInfo[v][vSpawnx] = dini_Float(file, "Spawn_X");
VehicleInfo[v][vSpawny] = dini_Float(file, "Spawn_Y");
VehicleInfo[v][vSpawnz] = dini_Float(file, "Spawn_Z");
VehicleInfo[v][vColor1] = dini_Int(file, "Color1");
VehicleInfo[v][vColor2] = dini_Int(file, "Color2");
VehicleInfo[v][vRotation] = dini_Float(file, "Rotation");
VehicleInfo[v][vModel] = dini_Int(file, "Model");
VehicleInfo[v][vAlarm] = dini_Int(file, "Alarm");
VehicleInfo[v][vLock] = dini_Int(file, "Lock");
VehicleInfo[v][vOwned] = dini_Int(file, "Owned");
VehicleInfo[v][vInsurance] = dini_Int(file, "Insurance");
VehicleInfo[v][vPrice] = dini_Int(file, "Price");
VehicleInfo[v][vForSale] = dini_Int(file, "ForSale");
VehicleInfo[v][vParkable] = dini_Int(file, "Parkable");
VehicleInfo[v][vFuel] = dini_Int(file, "Fuel");
VehicleInfo[v][vJob] = dini_Int(file, "Job");
VehicleInfo[v][vCiv] = dini_Int(file, "Civ");
VehicleInfo[v][vDTest] = dini_Int(file, "Test");
VehicleInfo[v][vFaction] = dini_Int(file, "Faction");
VehicleInfo[v][vWorld] = dini_Int(file, "World");
VehicleInfo[v][vInterior] = dini_Int(file, "Interior");
format(VehicleInfo[v][vOwner], MAX_PLAYER_NAME, "%s", dini_Get(file, "Owner"));
format(VehicleInfo[v][vName], 128, "%s", dini_Get(file, "Name"));
VehicleInfo[v][vTrade] = dini_Int(file, "Trade");
VehicleInfo[v][vLocked] = dini_Int(file, "Locked");
VehicleInfo[v][vDamage][0] = dini_Int(file, "Panels"), VehicleInfo[v][vDamage][1] = dini_Int(file, "Doors"), VehicleInfo[v][vDamage][2] = dini_Int(file, "Lights"), VehicleInfo[v][vDamage][3] = dini_Int(file, "Tires");
//VehicleInfo[v][vID] = CreateVehicle(VehicleInfo[v][vModel], VehicleInfo[v][vSpawnx], VehicleInfo[v][vSpawny], VehicleInfo[v][vSpawnz],VehicleInfo[v][vRotation] , VehicleInfo[v][vColor1], VehicleInfo[v][vColor2],9999999999999);
VehicleInfo[v][vID] = AddNewVehicle(VehicleInfo[v][vModel], VehicleInfo[v][vSpawnx], VehicleInfo[v][vSpawny], VehicleInfo[v][vSpawnz], VehicleInfo[v][vRotation] , VehicleInfo[v][vColor1], VehicleInfo[v][vColor2], VehicleInfo[v][vFaction], VehicleInfo[v][vJob]);
SetVehicleVirtualWorld(v, VehicleInfo[v][vWorld]);
SetVehicleInterior(v, VehicleInfo[v][vInterior]);
SetVehicleToRespawn(v);
UpdateVehicleDamageStatus(v, VehicleInfo[v][vDamage][0], VehicleInfo[v][vDamage][1], VehicleInfo[v][vDamage][2], VehicleInfo[v][vDamage][3]);
VehicleInfo[v][vHealth] = dini_Float(file, "Health");
SetVehicleHealth(v, VehicleInfo[v][vHealth]);
if(VehicleInfo[v][vLocked])
{
LockCar(v);
}
else
{
UnlockCar(v);
}
}
}
return 1;
}