28.08.2014, 22:46
(
Последний раз редактировалось Prostilov; 29.08.2014 в 12:38.
)
I am having a bit of trouble with my Car Ownership system.
Cars are successfully saved when a player purchases the vehicle, however, when I restart my script/server, the player owned vehicles wouldn't load in!
These are the related functions that work flawlessly:
My SaveVehicle function:
My SaveAllVehicles function:
And these are the functions which I'm having issues with:
LoadAllVehicles:
LoadVehicles:
I've used some printf messages to debug it, the values seem to be always 0.
Printf LoadVehicles:
returns
However, this
returns
Can anyone help?
Cars are successfully saved when a player purchases the vehicle, however, when I restart my script/server, the player owned vehicles wouldn't load in!
These are the related functions that work flawlessly:
My SaveVehicle function:
pawn Код:
stock SaveVehicle(vehicle, filename[36])
{
new INI:iniFile = INI_Open(filename);
INI_SetTag(iniFile, "data");
INI_WriteInt(iniFile, "Model", vInfo[vehicle][Model]);
INI_WriteFloat(iniFile, "x", vInfo[vehicle][vPos_x]);
INI_WriteFloat(iniFile, "y", vInfo[vehicle][vPos_y]);
INI_WriteFloat(iniFile, "z", vInfo[vehicle][vPos_z]);
INI_WriteFloat(iniFile, "fa", vInfo[vehicle][vAngle]);
INI_WriteInt(iniFile, "color1", vInfo[vehicle][vcolor1]);
INI_WriteInt(iniFile, "color2", vInfo[vehicle][vcolor2]);
INI_WriteInt(iniFile, "locked", vInfo[vehicle][locked]);
INI_WriteInt(iniFile, "carid", vInfo[vehicle][id]);
INI_Close(iniFile);
}
pawn Код:
stock SaveAllVehicles()
{
new saveindex = 1;
new fname[36];
for(new i = 0; i < MAX_VEHICLES; i ++)
{
if(vInfo[i][id] > 0)
{
format(fname, sizeof(fname), "/POV/%d.ini", saveindex);
SaveVehicle(i, fname);
saveindex++;
}
}
}
LoadAllVehicles:
pawn Код:
stock LoadAllVehicles()
{
new fname[36];
new index = 1;
format(fname, sizeof(fname), "/POV/%i.ini", index);
while(fexist(fname))
{
format(fname, sizeof(fname), "/POV/%i.ini", index);
INI_ParseFile(fname, "LoadVehicles");
index++;
}
}
pawn Код:
forward LoadVehicles(filename[36], name[], value[]);
public LoadVehicles(filename[36], name[], value[])
{
new AssignedCarID, model, Float:vx, Float:vy, Float:vz, Float:vfa, col1, col2;
INI_Int("Model", model);
INI_Float("x", Float:vx);
INI_Float("y", Float:vy);
INI_Float("z", Float:vz);
INI_Float("fa", Float:vfa);
INI_Int("color1", col1);
INI_Int("color2", col2);
INI_Int("id", AssignedCarID);
CreateVehicleEx(model, Float:vx, Float:vy, Float:vz, Float:vfa, col1, col2, AssignedCarID);
return 0;
}
Printf LoadVehicles:
pawn Код:
forward LoadVehicles(filename[36], name[], value[]);
public LoadVehicles(filename[36], name[], value[])
{
printf("Loading %s %s %i", filename, name, value);
new AssignedCarID, model, Float:vx, Float:vy, Float:vz, Float:vfa, col1, col2;
INI_Int("Model", model);
INI_Float("x", Float:vx);
INI_Float("y", Float:vy);
INI_Float("z", Float:vz);
INI_Float("fa", Float:vfa);
INI_Int("color1", col1);
INI_Int("color2", col2);
INI_Int("id", AssignedCarID);
CreateVehicleEx(model, Float:vx, Float:vy, Float:vz, Float:vfa, col1, col2, AssignedCarID);
return 0;
}
Код:
Loading: Model 466
pawn Код:
forward LoadVehicles(filename[36], name[], value[]);
public LoadVehicles(filename[36], name[], value[])
{
new AssignedCarID, model, Float:vx, Float:vy, Float:vz, Float:vfa, col1, col2;
INI_Int("Model", model);
INI_Float("x", Float:vx);
INI_Float("y", Float:vy);
INI_Float("z", Float:vz);
INI_Float("fa", Float:vfa);
INI_Int("color1", col1);
INI_Int("color2", col2);
INI_Int("id", AssignedCarID);
printf("Loading Vehicle %i, Model %i at X: %f Y:%f Z:%f", AssignedCarID, model, Float:vx, Float:vy, Float:vz);
CreateVehicleEx(model, Float:vx, Float:vy, Float:vz, Float:vfa, col1, col2, AssignedCarID);
return 0;
}
Код:
Loading Vehicle 0, Model 0 at X:0.000000 Y:0.000000 Z:0.000000