Cars won't load! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Cars won't load! (
/showthread.php?tid=475110)
Cars won't load! -
Prostilov - 11.11.2013
I made a vehicle ownership system, but for some reason the cars won't load when the server restarts, could you guys have a look at this?
Код:
stock LoadVehicle(filename[36], name[], value[])
{
new model, vx, vy, vz, vfa, col1, col2;
INI_Int("Model", model);
INI_Float("x", vx);
INI_Float("y", vy);
INI_Float("z", vz);
INI_Float("fa", vfa);
INI_Int("color1", col1);
INI_Int("color2", col2);
CreateVehicleEx(model, vx, vy, vz, vfa, col1, col2);
}
stock LoadAllVehicles()
{
new fname[36];
new index = 0;
format(fname, sizeof(fname), "/POV/%i.ini", index);
while(fexist(fname))
{
format(fname, sizeof(fname), "/POV/%i.ini", index);
INI_ParseFile(fname, "LoadVehicle");
index ++;
}
}
Under GameModeInit:
Re: Cars won't load! -
[SF]OutLawZ - 11.11.2013
Can we see your SaveVehicle function?
Re: Cars won't load! -
Prostilov - 11.11.2013
Certainly.
Код:
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_Close(iniFile);
}
Re: Cars won't load! -
[SF]OutLawZ - 11.11.2013
The code looks fine to me from what I can see, you might want to assign a print message to the LoadVehicle function and see what result it gives you
printf("Loading vehicle type %d at %f, %f, %f", model, vx, vy, vz);
And do the vehicles even save?
Re: Cars won't load! -
Prostilov - 11.11.2013
The vehicles save properly, they just won't spawn into the world on restart.
I added the print message line, but it won't print anything into the console.
Is it possible that my LoadVehicle function is not being executed properly or not being executed at all?
Re: Cars won't load! -
Prostilov - 12.11.2013
bump, really need help
Re: Cars won't load! -
hewittpro - 12.11.2013
Kinda have the same problem but with MySQL.. really pisses me off.
Re: Cars won't load! -
Prostilov - 25.11.2013
bump