How to destroy vehicle after spawns a new one.
#1

Hi guys i have a /car code here
Код:
CMD:car(playerid, params[])
{
    if(PlayerInfo[playerid][Jailed] == true) return SendClientMessage(playerid, COLOR_RED, "You can't use this command when you are in jail");
    if(PlayerInfo[playerid][World] != DMWorldID && PlayerInfo[playerid][World] != TDMWorldID)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be the driver of the vehicle or be onfoot to use this command");
        new aVehicle[64], Color1, Color2;
        if(sscanf(params, "s[64]I(-1)I(-1)", aVehicle, Color1, Color2)) return SendClientMessage(playerid,COLOR_YELLOW, "Correct usage: /car [car ID/name] [color1] [color2]");
		new veh = GetVehicleModelID(aVehicle);
		if(veh < 400 || veh > 611) return SendClientMessage(playerid,COLOR_RED, "ERROR: This is not a valid vehicle name! Please try again ");
		if(IsPlayerInAnyVehicle(playerid)) DestroyVehicle(GetPlayerVehicleID(playerid));
		new Float:Pos[4];
        GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playerid, Pos[3]);
        new PVeh = CreateVehicle(veh, Pos[0], Pos[1], Pos[2], Pos[3]+90, Color1, Color2, -1);
        LinkVehicleToInterior(PVeh, GetPlayerInterior(playerid));
        SetVehicleVirtualWorld(PVeh, GetPlayerVirtualWorld(playerid));
		PutPlayerInVehicle(playerid, PVeh, 0);
		vehhasmissile[veh] = 0;
		vehhasminigun[veh] = 0;
		vehhascargo[veh] = 0;
		vehhaswindshieldupgrade[veh] = 0;
		vehhascarwreck[veh] = 0;
		SendCommandToAdmins(playerid,"/car");
		GameTextForPlayer(playerid, "~y~Enjoy your new ~r~ride", 2000, 1);
        return 1;
    }
    else return SendClientMessage(playerid, COLOR_RED, "ERROR: you can't use this command in this world");
}
And the problem is, the car didnt dissapeared or destroyed when i spawn a new one :/ Anyone how can i do that? Thanks.
Reply
#2

Search before you post!
https://sampforum.blast.hk/showthread.php?tid=348274
https://sampforum.blast.hk/showthread.php?tid=364512
https://sampforum.blast.hk/showthread.php?tid=330670
https://sampforum.blast.hk/showthread.php?tid=98289
https://sampforum.blast.hk/showthread.php?tid=94319

+rep me if these work
Reply
#3

Well... No one of that threads helps me... Sorry :/
Reply
#4

Do you want it to go back to it's original position, if so, use this:
pawn Код:
SetVehicleToRespawn(vehicleid)
Or if you just want it to be gone use:
pawn Код:
DestroyVehicle(vehicleid)
Reply
#5

I'm sorry, but where i need to put that?
Reply
#6

In the place where you want to destroy your vehicle.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)