SA-MP Forums Archive
[Ajuda] Deletar a tunagem do carro automatico quando vender o veiculo - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Deletar a tunagem do carro automatico quando vender o veiculo (/showthread.php?tid=635535)



Deletar a tunagem do carro automatico quando vender o veiculo - rodrigo147 - 08.06.2017

Quero fazer para deletar o tunning do carro vendido, deletar automaticamente.

Код:
CMD:vendermeucarro(playerid, params[])
	{
            new vehid = GetPlayerVehicleID(playerid);
	    	if(PlayerInfo[playerid][pCarKey] == 0 && PlayerInfo[playerid][pCarKey2] == 0&& PlayerInfo[playerid][pCarKey3] == 0&& PlayerInfo[playerid][pCarKey4] == 0&& PlayerInfo[playerid][pCarKey5] == 0)
			{
				SendClientMessage(playerid, COLOR_GREY, "Vocк nгo tem um Carro VIP.");
				return true;
			}
			if(!IsPlayerInAnyVehicle(playerid))
			{
				SendClientMessage(playerid,COLOR_GREY,"Vocк precisa estar no seu veiculo VIP!");
				return 1;
			}
			if(PlayerInfo[playerid][pCarKey] != vehid && PlayerInfo[playerid][pCarKey2] != vehid &&
			PlayerInfo[playerid][pCarKey3] != vehid &&
			PlayerInfo[playerid][pCarKey4] != vehid &&
			PlayerInfo[playerid][pCarKey5] != vehid)
			{
				SendClientMessage(playerid, COLOR_GREY, "Esse nгo й seu Carro VIP.");
				return true;
			}
			new carid;
			new Veiculo;
			new pcarro[MAX_PLAYERS];
    	    new string[128];
    	    new Float:x,Float:y,Float:z;
			new Float:a;
			if(vehid == PlayerInfo[playerid][pCarKey])
			{
				carid = PlayerInfo[playerid][pCarKey];
				Veiculo = PlayerInfo[playerid][pVeiculo];
				pcarro[playerid] = 1;
			}
			else if(vehid == PlayerInfo[playerid][pCarKey2])
			{
				carid = PlayerInfo[playerid][pCarKey2];
				Veiculo = PlayerInfo[playerid][pVeiculo2];
				pcarro[playerid] = 2;
			}
			else if(vehid == PlayerInfo[playerid][pCarKey3])
			{
				carid = PlayerInfo[playerid][pCarKey3];
				Veiculo = PlayerInfo[playerid][pVeiculo3];
				pcarro[playerid] = 3;
			}
			else if(vehid == PlayerInfo[playerid][pCarKey4])
			{
				carid = PlayerInfo[playerid][pCarKey4];
				Veiculo = PlayerInfo[playerid][pVeiculo4];
				pcarro[playerid] = 4;
			}
			else if(vehid == PlayerInfo[playerid][pCarKey5])
			{
				carid = PlayerInfo[playerid][pCarKey5];
				Veiculo = PlayerInfo[playerid][pVeiculo5];
				pcarro[playerid] = 5;
			}

				GetPlayerName(playerid, playername, sizeof(playername));
				GetVehiclePos(carid, x, y, z);
				GetVehicleZAngle(carid, a);
				new Float:carropos[3];
    			new Float:Cangulo;
				if(IsPlayerInVehicle(playerid,carid) && CarInfo[Veiculo][cOwned] == 1)
				{
                GetVehiclePos(Veiculo, carropos[0],carropos[1],carropos[2]);
                GetVehicleZAngle(Veiculo, Cangulo);
                SetVehicleToRespawn(Veiculo);
                SalvarCarrosTunados(Veiculo);
	   			GetVehiclePos(Veiculo, carropos[0],carropos[1],carropos[2]);
       			GetVehicleZAngle(Veiculo, Cangulo);
				CarInfo[Veiculo][cLocationx] = x;
				CarInfo[Veiculo][cLocationy] = y;
				CarInfo[Veiculo][cLocationz] = z;
				CarInfo[Veiculo][cAngle] = a;
				//GameTextForPlayer(playerid, "Veiculo Estacionado!~n~Ele vai nascer aqui!", 10000, 3);
				Controle(playerid, 1);
				SalvarCarro(Veiculo);
				DestroyVehicle(CarInfo[Veiculo][ownedvehicle]);
				CarInfo[Veiculo][ownedvehicle] = CreateVehicle(CarInfo[Veiculo][cModel],CarInfo[Veiculo][cLocationx],CarInfo[Veiculo][cLocationy],CarInfo[Veiculo][cLocationz]+1.0,CarInfo[Veiculo][cAngle],CarInfo[Veiculo][cColorOne],CarInfo[Veiculo][cColorTwo],60000);
				//SetVehicleToRespawn(CarInfo[Veiculo][ownedvehicle]);
				CarInfo[Veiculo][cOwned] = 0;
				GetPlayerName(playerid, sendername, sizeof(sendername));
				strmid(CarInfo[Veiculo][cOwner], "Ninguйm", 0, strlen("Ninguйm"), 999);
				GiveDinheiro(playerid,CarInfo[Veiculo][cValue]);
				PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				format(string, sizeof(string), "~w~Veiculo VIP Vendido Por:~g~$%d", CarInfo[Veiculo][cValue]);
				GameTextForPlayer(playerid, string, 10000, 3);
				format(CarInfo[Veiculo][cDescription], 64, "Sem Dono");
				//format(string, sizeof string, "{50AAFE}Dono: %s\n{FFFF00}Descriзгo\n{FFFFFF}»%s«", CarInfo[Veiculo][cOwner], CarInfo[Veiculo][cDescription]);
				//Update3DTextLabelText(CarInfo[Veiculo][cText], 0xFFFFAA, string);

				RemovePlayerFromVehicleEx(playerid);
				Controle(playerid, 1);
				
				if(pcarro[playerid] == 1)
				{
					PlayerInfo[playerid][pCarKey] = 0;
					PlayerInfo[playerid][pVeiculo] = 0;
				}
				if(pcarro[playerid] == 2)
				{
					PlayerInfo[playerid][pCarKey2] = 0;
					PlayerInfo[playerid][pVeiculo2] = 0;
				}
 				if(pcarro[playerid] == 3)
				{
					PlayerInfo[playerid][pCarKey3] = 0;
					PlayerInfo[playerid][pVeiculo3] = 0;
				}
				if(pcarro[playerid] == 4)
				{
					PlayerInfo[playerid][pCarKey4] = 0;
					PlayerInfo[playerid][pVeiculo4] = 0;
				}
				if(pcarro[playerid] == 5)
				{
					PlayerInfo[playerid][pCarKey5] = 0;
					PlayerInfo[playerid][pVeiculo5] = 0;
				}
				SalvarCarro(Veiculo);
			}
 	 		return true;
	}
Код:
CMD:destunar(playerid, params[])
	    {
            new vehid = GetPlayerVehicleID(playerid);
			new carid = PlayerInfo[playerid][pCarKey];
			if(!IsPlayerInAnyVehicle(playerid))
			{
				SendClientMessage(playerid,COLOR_GREY,"Vocк precisa estar no veiculo!");
				return 1;
			}
			if(PlayerInfo[playerid][pCarKey] != vehid && PlayerInfo[playerid][pCarKey2] != vehid &&
			PlayerInfo[playerid][pCarKey3] != vehid &&
			PlayerInfo[playerid][pCarKey4] != vehid &&
			PlayerInfo[playerid][pCarKey5] != vehid)
			{
				SendClientMessage(playerid, COLOR_GREY, "Esse nгo й seu Carro VIP.");
				return true;
			}
			 if(PlayerInfo[playerid][pCarKey] == 0)
			 {
			      SendClientMessage(playerid, COLOR_GREY, "Vocк nгo tem um Veiculo.");
				  return 1;
			 }
				for(new i = 0; i < sizeof(CarInfo); i++)
   				{
				  if(!strcmp(NomePlayer(playerid),CarInfo[i][cOwner],true))
   				  {
                  new Float:carropos[3];
                  new Float:Cangulo;
                  GetVehiclePos(carid, carropos[0],carropos[1],carropos[2]);
                  GetVehicleZAngle(carid, Cangulo);
			      CarrosTunados[carid][Tunamento1] = 0;
                  CarrosTunados[carid][Tunamento2] = 0;
                  CarrosTunados[carid][Tunamento3] = 0;
                  CarrosTunados[carid][Tunamento4] = 0;
                  CarrosTunados[carid][Tunamento5] = 0;
                  CarrosTunados[carid][Tunamento6] = 0;
                  CarrosTunados[carid][Tunamento7] = 0;
                  CarrosTunados[carid][Tunamento8] = 0;
                  CarrosTunados[carid][Tunamento9] = 0;
                  CarrosTunados[carid][Tunamento10] = 0;
                  CarrosTunados[carid][Tunamento11] = 0;
                  CarrosTunados[carid][Tunamento12] = 0;
                  CarrosTunados[carid][Tunamento13] = 0;
                  CarrosTunados[carid][Tunamento14] = 0;
                  CarrosTunados[carid][Tunamento15] = 0;
                  CarrosTunados[carid][Tunamento16] = 0;
                  CarrosTunados[carid][Tunamento17] = 0;
                  CarrosTunados[carid][Pintura] = 0;
                  CarrosTunados[carid][COR1] = 0;
                  CarrosTunados[carid][COR2] = 0;
                  DeletarTunamento(carid);
                  SetVehicleToRespawn(carid);
                  SetVehiclePos(PlayerInfo[playerid][pCarKey], carropos[0],carropos[1],carropos[2]);
                  SetVehicleZAngle(PlayerInfo[playerid][pCarKey], Cangulo);
                  PutPlayerInVehicle(playerid, PlayerInfo[playerid][pCarKey], 0);
				}
			}
    		return 1;
		}
Код:
public DeletarTunamento(vehicleid)
{
	new FormatoTunamento[256];
	format(FormatoTunamento,sizeof(FormatoTunamento),"Carros Tunados/%d.ini",vehicleid);
	if(DOF2_FileExists(FormatoTunamento))
	{
		DOF2_RemoveFile(FormatoTunamento);
	}
	else
	{
		DOF2_RemoveFile(FormatoTunamento);
	}
	return 0;
}



Re: Deletar a tunagem do carro automatico quando vender o veiculo - rodrigo147 - 12.06.2017

up ajudem


Re: Deletar a tunagem do carro automatico quando vender o veiculo - F1N4L - 12.06.2017

RemoveVehicleComponent(vehicleid, componentid)
Faзa um loop e remova todos os componentes de determinado veнculo e posteriormente salve.