Destroy specific vehicle when player exit vehicle
#1

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
Reply
#2

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.
Reply
#3

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

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.
Reply
#5

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

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.
Reply
#7

So what should i add to destroy the Train?
Reply
#8

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

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

yes you can, just tested it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)