New vehicules save - 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: New vehicules save (
/showthread.php?tid=495288)
New vehicules save -
tysanio - 16.02.2014
I got some probleme with my save cars
There is my code for my save cars but it didnt save Why?
PHP код:
public SaveVeh()
{
new File:VehFile = fopen(FVEHICULE, io_write);
new stringv[256];
for(new v=1;v<Sveh;v++)
{
if(VInfo[v][vId] != INVALID_VEH_ID)
{
format(stringv, sizeof(stringv),"%d|%d|%d|%f|%f|%f|%f|%d|%d|%f|%f\r\n",
VInfo[v][vId],VInfo[v][vModel],VInfo[v][vMoteur],VInfo[v][vX],VInfo[v][vY],VInfo[v][vZ],VInfo[v][vA],
VInfo[v][vCol1],VInfo[v][vCol2],VInfo[v][vMessence],VInfo[v][vEssence]
);
fwrite(VehFile, stringv);
printf("-------Vehicule %s Sauvegarder-------", v);
}
}
fclose(VehFile);
return 1;
}
Sorry for my English.
Re: New vehicules save -
phoon - 16.02.2014
I rather use dini or y_ini.
Re: New vehicules save -
tysanio - 16.02.2014
I found something to help me but the Id for count the vehicles is the Same = 1
PHP код:
stock SaveVeh()
{
new idx = 1, File:file;
new stringv[256];
while(idx < MAX_VEHICULES)
{
format(stringv, sizeof(stringv),"%d|%d|%d|%f|%f|%f|%f|%d|%d|%f|%f\r\n",
VInfo[idx][vId],
VInfo[idx][vModel],
VInfo[idx][vMoteur],
VInfo[idx][vX],
VInfo[idx][vY],
VInfo[idx][vZ],
VInfo[idx][vA],
VInfo[idx][vCol1],
VInfo[idx][vCol2],
VInfo[idx][vMessence],
VInfo[idx][vEssence]);
if(idx == 1)
{
file = fopen("vehicules.cfg", io_write);
}
else
{
file = fopen("vehicules.cfg", io_append);
}
fwrite(file, stringv);
fclose(file);
idx++;
}
print("Vehicules sauvegarder correctement.");
return 1;
}
In my vehicules.cfg
1|568|0|159.164733|1191.708618|14.953808|163.54959 1|-1|-1|100.000000|13.259981
1|568|0|-161.715179|1083.066772|19.548107|312.414306|-1|-1|100.000000|14.919998
1|0|0|0.000000|0.000000|0.000000|0.000000|-1|-1|100.000000|14.919998
EDIT : I check up for this part "|-1|-1|100.000000|14.919998" and i solve them don't woory about it