SA-MP Forums Archive
Destroy specific vehicle when player exit vehicle - 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)
+--- Thread: Destroy specific vehicle when player exit vehicle (/showthread.php?tid=410484)



Destroy specific vehicle when player exit vehicle - se7evolution - 25.01.2013

Hello,
I am trying to create something so if player exit a vehicle Here a Brownstreak the vehicle will be destroyed.
This is my code for spawn into a Brownstreak. Never tested it because i am on my netbook. So, Should it be working?

pawn Code:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == checkpointtele)
    {
        brownstreakLS = AddStaticVehicleEx (538, 1699.156494, -1953.658203, 14.875619, 82.2873, -1, -1, 1);
        PutPlayerInVehicle(playerid,brownstreakLS,0);
        SendClientMessage(playerid, 0x9370DBFF, "You have been spawned into a Train. If you exit the train it will get destroyed.");
        SendClientMessage(playerid, 0x9370DBFF, "Please enter the command /work to get a mission!");
        SetPlayerVirtualWorld(playerid, 0);
    }
    return 1;
}
Thanks,
Se7evolution


Re: Destroy specific vehicle when player exit vehicle - DrDoom151 - 25.01.2013

https://sampwiki.blast.hk/wiki/AddStaticVehicleEx

Quote:

You can use this function to add vehicles to your gamemode. This function can only create vehicles in the OnGameModeInit callback, and vehicles created with this function cannot be removed. Check CreateVehicle if you are interested in creating vehicles during game-runtime.

You have to use CreateVehicle.


Re: Destroy specific vehicle when player exit vehicle - se7evolution - 25.01.2013

What do i have to add after CreateVehicle?
Edit: The spawn doesnt work with CreateVehicle:
Code:
 Only create trains with AddStaticVehicle/Ex



Re: Destroy specific vehicle when player exit vehicle - DrDoom151 - 25.01.2013

https://sampwiki.blast.hk/wiki/CreateVehicle

Quote:

(modelid, Float: x, Float: y, Float: z, Float:angle, color1, color2, respawn_delay)

In other words: exactly the same at AddStaticVehicleEx, only difference is that CreateVehicle will works whilst your gamemode is running.


Re: Destroy specific vehicle when player exit vehicle - MP2 - 25.01.2013

You can't create trains with CreateVehicle. You have to add them with AddStaticVehicle(Ex) at server startup.


Re: Destroy specific vehicle when player exit vehicle - DrDoom151 - 25.01.2013

Quote:
Originally Posted by MP2
View Post
You can't create trains with CreateVehicle. You have to add them with AddStaticVehicle(Ex) at server startup.
Damn, I forgot all about that.


Re: Destroy specific vehicle when player exit vehicle - se7evolution - 25.01.2013

So what should i add to destroy the Train?


Re: Destroy specific vehicle when player exit vehicle - zde5 - 25.01.2013

you can add it with AddStaticVehicleEx outside OnGameModeInit, wiki information is wrong.


Re: Destroy specific vehicle when player exit vehicle - DrDoom151 - 25.01.2013

You have to add trains using AddStaticVehicle(Ex), but you can't delete it.


Re: Destroy specific vehicle when player exit vehicle - zde5 - 25.01.2013

yes you can, just tested it.