Issues with saving vehicles to a file... [HELP!!!] - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Issues with saving vehicles to a file... [HELP!!!] (
/showthread.php?tid=94968)
Issues with saving vehicles to a file... [HELP!!!] -
Dak_Cobain - 02.09.2009
I am making a RTS/TDM/RP/DM etc... server, and in it you can buy vehicles of destruction and transportation.
And I have encountered a problem...
pawn Code:
forward SaveVehicle(playerid);
public SaveVehicle(playerid)
{
new model = GetVehicleModel(gPCar[playerid]);
new pName[MAX_PLAYER_NAME];
new sstring[64];
GetPlayerName(playerid, pName, sizeof(pName));
format(sstring, sizeof(sstring), "vehs/%s.txt", pName);
new string[128];
new count;
new File:save = fopen(sstring, io_write);
if (save)
{
gPCar[playerid] = GetPlayerVehicleID(playerid);
new Float:xx, Float:yy, Float:zz, Float:z_rot;
if (IsPlayerInVehicle(playerid,gPCar[playerid]))
{
if(model == 468 || model == 520 || model == 473){
GetVehicleZAngle(gPCar[playerid],z_rot);
GetVehiclePos(gPCar[playerid],xx,yy,zz);
format(string, sizeof(string),"%d, %f, %f, %f, %f ;", model, xx, yy, zz, z_rot);
fwrite(save, string);
count++;
if(model == 468){
sanchez[playerid] -= 1;
SendClientMessage(playerid,COLOR_WHITE,"SERVER: Sanchez saved.");
}
if(model == 520){
hydra[playerid] -= 1;
SendClientMessage(playerid,COLOR_WHITE,"SERVER: Hydra saved.");
}
if(model == 473){
dinghy[playerid] -= 1;
SendClientMessage(playerid,COLOR_WHITE,"SERVER: Dinghy saved.");
}
}
}
fclose(save);
}
}
This script will save the vehicle into a file when called apon, however, it erases anything before it. The script is supposed to allow more than one vehicle saved, but it doesn't work the way I want it to.
Help would appreciated, I've tried everything I can think of to fix it.
Indentation is not an issue.
Re: Issues with saving vehicles to a file... [HELP!!!] -
Dak_Cobain - 02.09.2009
Never mind I got it. Delete please.