forward LoadPVehicles(iVehicleID, name[], value[]); public LoadPVehicles(iVehicleID, name[], value[]) { for(new iVehicleID = 0; iVehicleID < MAX_BUYABLE_VEH; ++iVehicleID) { new kFile[128]; format(kFile, sizeof(kFile), "Avta/%d.ini", iVehicleID); INI_Open(kFile); INI_Int("Model",vInfo[iVehicleID][vModel]); INI_Int("Color1",vInfo[iVehicleID][vColor1]); INI_Int("Color2",vInfo[iVehicleID][vColor2]); INI_Int("Price",vInfo[iVehicleID][vPrice]); INI_String("Owner",vInfo[iVehicleID][vOwner], 24); INI_Float("vPosX",vInfo[iVehicleID][vPosX]); INI_Float("vPosY",vInfo[iVehicleID][vPosY]); INI_Float("vPosZ",vInfo[iVehicleID][vPosZ]); INI_Float("vPosA",vInfo[iVehicleID][vPosA]); INI_String("Plate",vInfo[iVehicleID][vPlate], 32); INI_Int("PaintJ",vInfo[iVehicleID][vPaintJ]); INI_Int("Locked",vInfo[iVehicleID][vLocked]); INI_Int("vMod1",vMods[iVehicleID][0]); INI_Int("vMod2",vMods[iVehicleID][1]); INI_Int("vMod3",vMods[iVehicleID][2]); INI_Int("vMod4",vMods[iVehicleID][3]); INI_Int("vMod5",vMods[iVehicleID][4]); INI_Int("vMod6",vMods[iVehicleID][5]); INI_Int("vMod7",vMods[iVehicleID][6]); INI_Int("vMod8",vMods[iVehicleID][7]); INI_Int("vMod9",vMods[iVehicleID][8]); INI_Int("vMod10",vMods[iVehicleID][9]); INI_Int("vMod11",vMods[iVehicleID][10]); INI_Int("vMod12",vMods[iVehicleID][11]); new vCarID = CreateVehicle(vInfo[iVehicleID][vModel], vInfo[iVehicleID][vPosX], vInfo[iVehicleID][vPosY], vInfo[iVehicleID][vPosZ], vInfo[iVehicleID][vPosA], vInfo[iVehicleID][vColor1], vInfo[iVehicleID][vColor2], 500000); SetVehicleNumberPlate(vCarID, vInfo[iVehicleID][vPlate]); ChangeVehiclePaintjob(vCarID, vInfo[iVehicleID][vPaintJ]); for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod) { if(vMods[vCarID][iMod] > 0) { AddVehicleComponent(vCarID, vMods[vCarID][iMod]); } } OwnedVeh(vCarID) = iVehicleID; ++ Total_Veh_Created; } return 1; } |
LoadPVehicles(); |
stock VehicleLoadAll() // This function will load all of the system vehicles created and saved.
{
new index = 0; // We need this variable to keep track of the id or the index of the file. Start it with 0 as the id.
while(fexist(VehiclePath(index))) // If any system vehicle has been created before with that 0 id
{
LoadPVehicles(index, VehiclePath(index)); // Then load that vehicle.
index++; // And move on to another system vehicle id.
}
printf("Vehicles Loaded: %d", index); // Print out how many vehicles has been loaded.
}
public OnGameModeInit()
{
VehicleLoadAll(); // Load all vehicles when the main script starts.
return 1;
}