Car Saving
#1

Hi. I have little problem. I created simple vehicle system but always when i "sell" (remove) vehicle from my garage is always good, but after i save all vehicles and this removed vehicle is back in my garage and in scriptfiles too.. I don't know how this car doing this but he maybe want be my car or i don't know Please help boys

HTML Code:
#define MAX_PLAYER_VEHICLES 5

stock BuyCar(playerid, vehicleid, col1, col2)
{
	new carid = GetFreeVehicleSlot(playerid);
	CarInfo[playerid][ID][carid] = vehicleid;
	CarInfo[playerid][Color1][carid] = col1;
	CarInfo[playerid][Color2][carid] = col2;
	CarInfo[playerid][UsedSlot][carid] = true;
	CarInfo[playerid][Vehicle][carid] = CreateVehicle(vehicleid, 111.111, 111.111, 111.111, 111.111, col1, col2, -1);
	SetVehicleVirtualWorld(CarInfo[playerid][Vehicle][carid], playerid + 1);
	return carid;
}

stock SaveCarData(playerid, slot)
{
	new cesta[50];
	format(cesta, sizeof(cesta), "Cars/%s.%i.cfg", Nick(playerid), slot);
	if(CarInfo[playerid][UsedSlot][slot])
	{
		if(!fexist(cesta)) DOF2_CreateFile(cesta);
		DOF2_SetInt(cesta, "VehicleModel", CarInfo[playerid][ID][slot]);
		DOF2_SetInt(cesta, "Color1", CarInfo[playerid][Color1][slot]);
		DOF2_SetInt(cesta, "Color2", CarInfo[playerid][Color2][slot]);
		DOF2_SaveFile(cesta);
		DestroyVehicle(CarInfo[playerid][Vehicle][slot]);
		CarInfo[playerid][UsedSlot][slot] = false;
	}
	return 1;
}

stock LoadCarData(playerid, slot)
{
	new cesta[50];
	format(cesta, sizeof(cesta), "Cars/%s.%i.cfg", Nick(playerid), slot);
	if(fexist(cesta)) return BuyCar(playerid, DOF2_GetInt(cesta, "VehicleModel"), DOF2_GetInt(cesta, "Color1"), DOF2_GetInt(cesta, "Color2"));
	else return 1;
}

stock DeleteCarData(playerid, slot)
{
	new cesta[50];
	format(cesta, sizeof(cesta), "Cars/%s.%i.cfg", Nick(playerid), slot);
	if(fexist(cesta))
	{
		fremove(cesta);
		CarInfo[playerid][ID][slot] = 0;
		CarInfo[playerid][Color1][slot] = 0;
		CarInfo[playerid][Color2][slot] = 0;
		CarInfo[playerid][UsedSlot][slot] = false;
		DestroyVehicle(CarInfo[playerid][Vehicle][slot]);

		for(new i = 0; i < MAX_PLAYER_VEHICLES; i++)
		{
			SaveCarData(playerid, i);
			LoadCarData(playerid, i);
		}

		return 1;
	}
	return 1;
}
For deleting car i using command and dialog.. I have in DeleteCarData saving & loading all vehicles because if i have 4 vehicles, and i remove vehicle on slot 2 so be shown "0, 1, 3, 4, none" and no "0, 1, none, 3, 4".. But in scriptfiles is still "nick.0, nick.1, nick.3, nick.4...". Thanks for help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)