Jump to content
Sign in to follow this  
MadranLamont

Using BIS_fnc_spawnVehicle With position player

Recommended Posts

Hello all.

I am trying to make a mission were you can call in a vehicle with full crew and it will travel to you and stop, then you will have some options to use when near it. First thing i need to know is how to use "position player" with "BIS_fnc_spawnVehicle" with out it crushing me to death (as that is rather counter productive to the mission). I also need to know how to make the vehicle leave and then delete itself, and last but not least (i cant really do much with out this one) how do i use a script to name the vehicle i spawn? I know this seems like a lot but i have been at this for a long time and have had no luck. Can anyone help me out here? Many thanks to anyone who can.

this is what i have so far

_unit = [position player, 180, "BMP3", EAST] call bis_fnc_spawnvehicle;
_unit doMove (position player);

as you can see it spawns it right on top of me... I need it not to do that. Also i had a much more complex script to start out with this is just the most simple way i found.

Edited by MadranLamont

Share this post


Link to post
Share on other sites

if you are trying to make a mission, you posted in the wrong section (you are in ADDONS - configs and scripting)..posting in the section for missions means you'll get more help with you problem

Share this post


Link to post
Share on other sites

To get the vehicle to spawn further away, you have to give it more specific postion requirements. This will also help with your question about getting it to move away after. I also tackle the naming issue. Try this.

// Store the a position 500 meters north of the player's current postion.
vehicleOrigin = ((position player select 0), ((position player select 1) - 500), (position player select 2));

// Spawn a vehicle at the postion stored above.
myVehicleArray = [vehicleOrigin, 180, "BMP3", EAST] call bis_fnc_spawnvehicle;

// Store a pointer to the vehicle object returned as part of the function call above.
myVehicle = myVehicleArray select 0; // You can name it anything you want.

// Move the vehicle to the player's current postion.
myVehicle doMove (position player);

You do not need to name the vehicle in the traditional manner because bis_fnc_spawnvehicle returns an array in this format:

select 0: created vehicle (Object), select 1: all crew (Array of Objects), select 2: vehicle's group (Group)

So, if you store the first element in the array to a global variable you can then refer to the vehicle.

There are several ways to get the vehicle to move off when you are finished: Waypoints, triggers, etc. Here is one way that is fairly simple:

// Return the vehicle to its origin.
myVehicle doMove vehicleOrigin;

// Wait two minutes to give the vehicle time to leave (adjust as needed).
sleep 120;

// Delete the vehicle's crew.
{deletevehicle _x} forEach crew myVehicle;

// Delete the vehicle.
waitUntil {(count crew myvehicle) == 0};
deletevehicle myvehicle;

Hope this helps! Good luck!

Share this post


Link to post
Share on other sites
To get the vehicle to spawn further away, you have to give it more specific postion requirements. This will also help with your question about getting it to move away after. I also tackle the naming issue. Try this.

// Store the a position 500 meters north of the player's current postion.
vehicleOrigin = ((position player select 0), ((position player select 1) - 500), (position player select 2));

// Spawn a vehicle at the postion stored above.
myVehicleArray = [vehicleOrigin, 180, "BMP3", EAST] call bis_fnc_spawnvehicle;

// Store a pointer to the vehicle object returned as part of the function call above.
myVehicle = myVehicleArray select 0; // You can name it anything you want.

// Move the vehicle to the player's current postion.
myVehicle doMove (position player);

You do not need to name the vehicle in the traditional manner because bis_fnc_spawnvehicle returns an array in this format:

select 0: created vehicle (Object), select 1: all crew (Array of Objects), select 2: vehicle's group (Group)

So, if you store the first element in the array to a global variable you can then refer to the vehicle.

There are several ways to get the vehicle to move off when you are finished: Waypoints, triggers, etc. Here is one way that is fairly simple:

// Return the vehicle to its origin.
myVehicle doMove vehicleOrigin;

// Wait two minutes to give the vehicle time to leave (adjust as needed).
sleep 120;

// Delete the vehicle's crew.
{deletevehicle _x} forEach crew myVehicle;

// Delete the vehicle.
waitUntil {(count crew myvehicle) == 0};
deletevehicle myvehicle;

Hope this helps! Good luck!

Well first off let me say thank you for your help on this. But, here comes the bad news... it seems that the vehicle now no longer spawns when i use

vehicleOrigin = ((position player select 0), ((position player select 1) - 500), (position player select 2));

myVehicleArray = [vehicleOrigin, 180, "BMP3", EAST] call bis_fnc_spawnvehicle;

any thoughts?

Edit: well i found that it is making it not spawn

vehicleOrigin = ((position player select 0), ((position player select 1) - 500), (position player select 2));

because it spawns when i use simple

vehicleOrigin = position player;

its just that it still kills me like i new that would. I will try and mess with it and get it working but if you or any one knows what could be making it not spawn that would be a big help.

Edit2: Ok I got it to work with

vehicleOrigin = [(position player select 0), (position player select 1) - 500, (position player select 2)];

myVehicleArray = [vehicleOrigin, 180, "BMP3", EAST] call bis_fnc_spawnvehicle;

myVehicle = myVehicleArray select 0;

myVehicle doMove (position player);  

Thanks for all the help.

Edited by MadranLamont

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×