23.10.2012, 05:34
I can not seen why my system will not work, Its a vehicle system that saves and loads from a folder of files named by there ID's.
Its something to do with loading from the file, Thats the only problem i need help with i can manage the rest myself.
Here are some snippets of my code, I wont paste the whole game mode because its a fullon RolePlaying server im developing. Im not a total noob to programming, But PAWN is one of the languages i have only basic expirence But i have not been using PAWN for over a a year.
I have been following a number of tutorials to get into the idea of how things work but this is all my own code. Im a noob to using Y_ini so im pretty sure its something to do with that side of things on reading, It looks like it writes fine but i cant load data to save it.
Iv been scripting this vehicle system for over 6-hours, Iv been trying to fix this for an hour but without complier hints im pretty lost right now, Specially since i only got back to PAWN the otherday.
Its most likly something stupid, Small but any help/guildece will help MASSIVELY, Thanks in advance. I will continue to attempt to fix this but i rekon its going to take me a very long time.
Its something to do with loading from the file, Thats the only problem i need help with i can manage the rest myself.
Here are some snippets of my code, I wont paste the whole game mode because its a fullon RolePlaying server im developing. Im not a total noob to programming, But PAWN is one of the languages i have only basic expirence But i have not been using PAWN for over a a year.
I have been following a number of tutorials to get into the idea of how things work but this is all my own code. Im a noob to using Y_ini so im pretty sure its something to do with that side of things on reading, It looks like it writes fine but i cant load data to save it.
Iv been scripting this vehicle system for over 6-hours, Iv been trying to fix this for an hour but without complier hints im pretty lost right now, Specially since i only got back to PAWN the otherday.
Its most likly something stupid, Small but any help/guildece will help MASSIVELY, Thanks in advance. I will continue to attempt to fix this but i rekon its going to take me a very long time.
Код:
#define VEHICLE_PATH "/vehicles/%i.ini"
enum vInfo {
vModel,
vCol1,
vCol2,
vEngine,
vDamage,
vDPanels,
vDDoors,
vDLights,
vDTires,
vMileage,
vFuel,
vHasLock,
vLocked,
vOwnerName[32],
vForSale,
vForSalePrice,
Float:vLocX,
Float:vLocY,
Float:vLocZ,
Float:vLocA
}
new VehicleInfo[MAX_VEHICLES][vInfo];
new bool:ValidVehicle[MAX_VEHICLES];
stock VehiclePath(vehicleid)
{
new string[128];
format(string,sizeof(string),VEHICLE_PATH,vehicleid);
return string;
}
stock GetFreeVehicleSlot()
{
for(new i = 0; i < sizeof(validcar); i ++)
{
if(!validcar[i]) return i;
}
return -1;
}
stock SaveVehicle(vehicleid)
{
new INI:ini = INI_Open(VehiclePath(vehicleid));
INI_WriteInt(ini, "Model", VehicleInfo[vehicleid][vModel]);
INI_WriteInt(ini, "Col1", VehicleInfo[vehicleid][vCol1]);
INI_WriteInt(ini, "Col2", VehicleInfo[vehicleid][vCol2]);
INI_WriteInt(ini, "Engine", VehicleInfo[vehicleid][vEngine]);
INI_WriteInt(ini, "Damage", VehicleInfo[vehicleid][vDamage]);
INI_WriteInt(ini, "DPanels", VehicleInfo[vehicleid][vDPanels]);
INI_WriteInt(ini, "DDoors", VehicleInfo[vehicleid][vDDoors]);
INI_WriteInt(ini, "DLights", VehicleInfo[vehicleid][vDLights]);
INI_WriteInt(ini, "DTires", VehicleInfo[vehicleid][vDTires]);
INI_WriteInt(ini, "Mileage", VehicleInfo[vehicleid][vMileage]);
INI_WriteInt(ini, "Fuel", VehicleInfo[vehicleid][vFuel]);
INI_WriteInt(ini, "HasLock", VehicleInfo[vehicleid][vHasLock]);
INI_WriteInt(ini, "Locked", VehicleInfo[vehicleid][vLocked]);
INI_WriteString(ini, "OwnerName", VehicleInfo[vehicleid][vOwnerName]);
INI_WriteInt(ini, "ForSale", VehicleInfo[vehicleid][vForSale]);
INI_WriteInt(ini, "ForSalePrice", VehicleInfo[vehicleid][vForSalePrice]);
INI_WriteFloat(ini, "LocX", VehicleInfo[vehicleid][vLocX]);
INI_WriteFloat(ini, "LocY", VehicleInfo[vehicleid][vLocY]);
INI_WriteFloat(ini, "LocZ", VehicleInfo[vehicleid][vLocZ]);
INI_WriteFloat(ini, "LocA", VehicleInfo[vehicleid][vLocA]);
INI_Close(ini);
return 0;
}
stock SaveAllVehicles()
{
for( new vehicleid = 1; vehicleid < (MAX_VEHICLES+1); vehicleid++)
{
SaveVehicle(vehicleid);
}
return 0;
}
stock LoadAllVehicles()
{
for( new vehicleid = 1; vehicleid < (MAX_VEHICLES+1); vehicleid++)
{
INI_ParseFile(VehiclePath(vehicleid), "LoadVehicle_%i", .bExtra = true, .extra = vehicleid);
if(VehicleInfo[vehicleid][vModel] != 0) {
CreateVehicle(VehicleInfo[vehicleid][vModel] ,VehicleInfo[vehicleid][vLocX] , VehicleInfo[vehicleid][vLocY] ,
VehicleInfo[vehicleid][vLocZ] , VehicleInfo[vehicleid][vLocA] , VehicleInfo[vehicleid][vCol1] ,
VehicleInfo[vehicleid][vCol2] , -1);
ValidVehicle[vehicleid] = true;
}
}
return 0;
}
forward LoadVehicle_data(vehicleid,name[],value[]);
public LoadVehicle_data(vehicleid,name[],value[])
{
INI_Int("Model", VehicleInfo[vehicleid][vModel]);
INI_Int("Col1", VehicleInfo[vehicleid][vCol1]);
INI_Int("Col2", VehicleInfo[vehicleid][vCol2]);
INI_Int("Engine", VehicleInfo[vehicleid][vEngine]);
INI_Int("Damage", VehicleInfo[vehicleid][vDamage]);
INI_Int("DPanels", VehicleInfo[vehicleid][vDPanels]);
INI_Int("DDoors", VehicleInfo[vehicleid][vDDoors]);
INI_Int("DLights", VehicleInfo[vehicleid][vDLights]);
INI_Int("DTires", VehicleInfo[vehicleid][vDTires]);
INI_Int("Mileage", VehicleInfo[vehicleid][vMileage]);
INI_Int("Fuel", VehicleInfo[vehicleid][vFuel]);
INI_Int("HasLock", VehicleInfo[vehicleid][vHasLock]);
INI_Int("Locked", VehicleInfo[vehicleid][vLocked]);
INI_String("OwnerName", VehicleInfo[vehicleid][vOwnerName], 32);
INI_Int("ForSale", VehicleInfo[vehicleid][vForSale]);
INI_Int("ForSalePrice", VehicleInfo[vehicleid][vForSalePrice]);
INI_Float("LocX", VehicleInfo[vehicleid][vLocX]);
INI_Float("LocY", VehicleInfo[vehicleid][vLocY]);
INI_Float("LocZ", VehicleInfo[vehicleid][vLocZ]);
INI_Float("LocA", VehicleInfo[vehicleid][vLocA]);
return 1;
}
public OnGameModeInit()
{
LoadAllVehicles();
return 1;
}
public OnGameModeExit()
{
SaveAllVehicles();
return 1;
}

