SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 08/05/2016, 01:40 PM   #1
James585
Little Clucker
 
Join Date: Nov 2015
Posts: 23
Reputation: 0
Angry Save Tuning

Hey guys I downloaded AVS (Advanced Vehicle System) and I came out that I Do not Save Tuning .. Please correct me this code .. Thanks

Code:
public OnVehicleSpawn(vehicleid)
{
	VehicleSecurity[vehicleid] = 0;
	new id = GetVehicleID(vehicleid);
	if(IsValidVehicle(id))
	{
		if(VehicleColor[id][0] >= 0 && VehicleColor[id][1] >= 0)
			ChangeVehicleColor(vehicleid, VehicleColor[id][0], VehicleColor[id][1]);
		LinkVehicleToInterior(vehicleid, VehicleInterior[id]);
		SetVehicleVirtualWorld(vehicleid, VehicleWorld[id]);
		for(new i=0; i < sizeof(VehicleMods[]); i++)
		{
			AddVehicleComponent(vehicleid, VehicleMods[id][i]);
		}
		ChangeVehiclePaintjob(vehicleid, VehiclePaintjob[id]);
		if(VehicleLock[id]) ToggleDoors(vehicleid, VEHICLE_PARAMS_ON);
		if(VehicleAlarm[id]) VehicleSecurity[vehicleid] = 1;
	}
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	new id = GetVehicleID(vehicleid);
	if(IsValidVehicle(id))
	{
		VehicleMods[id][GetVehicleComponentType(componentid)] = componentid;
		SaveVehicle(id);
	}
	return 1;
}

SaveVehicle(vehicleid)
{
	new filename[64], line[256];
	format(filename, sizeof(filename), VEHICLE_FILE_PATH "v%d.ini", vehicleid);
	new File:handle = fopen(filename, io_write);
	format(line, sizeof(line), "Created=%d\r\n", VehicleCreated[vehicleid]); fwrite(handle, line);
	format(line, sizeof(line), "Model=%d\r\n", VehicleModel[vehicleid]); fwrite(handle, line);
	format(line, sizeof(line), "Pos=%.3f,%.3f,%.3f,%.3f\r\n", VehiclePos[vehicleid][0], VehiclePos[vehicleid][1],
		VehiclePos[vehicleid][2], VehiclePos[vehicleid][3]);
	fwrite(handle, line);
	format(line, sizeof(line), "Colors=%d,%d\r\n", VehicleColor[vehicleid][0], VehicleColor[vehicleid][1]); fwrite(handle, line);
	format(line, sizeof(line), "Interior=%d\r\n", VehicleInterior[vehicleid]); fwrite(handle, line);
	format(line, sizeof(line), "VirtualWorld=%d\r\n", VehicleWorld[vehicleid]); fwrite(handle, line);
	format(line, sizeof(line), "Owner=%s\r\n", VehicleOwner[vehicleid]); fwrite(handle, line);
	format(line, sizeof(line), "NumberPlate=%s\r\n", VehicleNumberPlate[vehicleid]); fwrite(handle, line);
	format(line, sizeof(line), "Value=%d\r\n", VehicleValue[vehicleid]); fwrite(handle, line);
	format(line, sizeof(line), "Lock=%d\r\n", VehicleLock[vehicleid]); fwrite(handle, line);
	format(line, sizeof(line), "Alarm=%d\r\n", VehicleAlarm[vehicleid]); fwrite(handle, line);
	format(line, sizeof(line), "Paintjob=%d\r\n", VehiclePaintjob[vehicleid]); fwrite(handle, line);
	for(new t=0; t < sizeof(VehicleTrunk[]); t++)
	{
		format(line, sizeof(line), "Trunk%d=%d,%d\r\n", t+1, VehicleTrunk[vehicleid][t][0], VehicleTrunk[vehicleid][t][1]);
		fwrite(handle, line);
	}
	for(new m=0; m < sizeof(VehicleMods[]); m++)
	{
		format(line, sizeof(line), "Mod%d=%d\r\n", m, VehicleMods[vehicleid][m]);
		fwrite(handle, line);
	}
	fclose(handle);
}
James585 is offline   Reply With Quote
Old 08/05/2016, 01:50 PM   #2
OmegaKiller72
Big Clucker
 
Join Date: Sep 2013
Location: Ukraine
Posts: 93
Reputation: 0
Default Re: Save Tuning

do you have all needed folders in scriptfiles?
OmegaKiller72 is offline   Reply With Quote
Old 08/05/2016, 02:01 PM   #3
James585
Little Clucker
 
Join Date: Nov 2015
Posts: 23
Reputation: 0
Default Re: Save Tuning

Yes..
James585 is offline   Reply With Quote
Old 08/05/2016, 04:07 PM   #4
ikey07
High-roller
 
ikey07's Avatar
 
Join Date: Jul 2010
Location: Latvia,Riga
Posts: 1,363
Reputation: 180
Default Re: Save Tuning

I would really suggest you to make sub-folders to save vehicle files in it and use io_append when you open a file, not io_write.
__________________
ikey07 is offline   Reply With Quote
Old 08/05/2016, 05:08 PM   #5
James585
Little Clucker
 
Join Date: Nov 2015
Posts: 23
Reputation: 0
Default Re: Save Tuning

still nothing
James585 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me sql save tuning Aloula Scripting Help 5 01/12/2012 06:50 PM
Save tuning Dasine94 Scripting Help 2 01/07/2012 01:41 PM
Save Tuning Roymer Help Archive 5 17/01/2011 04:22 PM


All times are GMT. The time now is 11:22 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.