Jump to content
Sign in to follow this  
tryteyker

Moving player into spawned helicopter

Recommended Posts

Hey,

I've got a couple of issues with a random mission I'm currently working on.

First of all, I have an issue with moving the player into a recently spawned (empty) helicopter.

This is the code I'm using:

_chinook = createvehicle ["CH_47F_EP1",getmarkerpos "chspawn",[],0,"NONE"];
_chinook setdir 220;
_chinook setvehiclevarname chinook;

player assignasdriver chinook;
hintSilent "Switched to Chinook";
deletevehicle huey;


huey removeaction ID;
huey removeaction IID;
huey removeaction switchchinook;
chinook addaction ["Give me a challenge","randomchallenge.sqf"];

I start the mission in a Huey (placed the player inside via moveindriver), and then added an action to the vehicle to switch to a Chinook.

The Chinook spawns and everything executes, the Huey despawns and the actions are gone.

But the player isn't getting assigned to the driver seat of the Chinook.

I've been playing around with different things, such as "name", "setvehiclevarname" and others, but none worked.

I simply get ejected from the Huey, but can enter and continue normally.

My second issue is the action at the end of the script. Since "chinook" isn't defined at all the action does not get added and the script has no clue what chinook is.

I've tried adding something to _chinook like this:

_chinook = createvehicle ["CH_47F_EP1",getmarkerpos "chspawn",[],0,"NONE",[color="#FF0000"]"chinook=this"[/color]];

Just something I found in Murrays Editing Guide when I searched through it, but that didn't work out.

Share this post


Link to post
Share on other sites

_chinook = createvehicle ["CH_47F_EP1",getmarkerpos "chspawn",[],0,"NONE"];
_chinook setdir 220;
_chinook setvehiclevarname "chinook"; //This line is not needed unless you want to refer to this chopper outside of the script

player assignasdriver _chinook; //This assigns the player as the driver of the chopper
player moveInDriver _chinook; //This moves the player into the driver seat of the chopper
hintSilent "Switched to Chinook";
deletevehicle huey;


huey removeaction ID;
huey removeaction IID;
huey removeaction switchchinook;
_chinook addaction ["Give me a challenge","randomchallenge.sqf"];

Try that out, I added comments to the script to help you understand it better.

-Bigshot

Share this post


Link to post
Share on other sites

So I have to use both assignasdriver & moveindriver for it to work? I've used moveindriver before but it didn't work out.

And FYI. I'm referring to the vehicle outside the script aswell.

Thanks for your help though, I'll test this.

//Edit:

Tested this, I still just get ejected from the helicopter and nothing happens, I don't get moved into the driver seat of the Chinook.

Maybe he's having issues with my previously issued "player moveindriver huey" via the init of the player?

I'm not sure if this automatically assigns the player to the vehicle, if that's the case unassignvehicle might help. I'll test that.

//

Isn't that either it seems like.

Edited by tryteyker

Share this post


Link to post
Share on other sites

Assigning the the driver for the player is not necessary, that is more for AI. It forces the soldier to be the driver and only the driver of the vehicle. So if you were to tell the same soldier to move to the back or get in the gunner, you would need to un-assign them from the driver seat and either re-assign them somewhere else or let them choose for themselves.

Share this post


Link to post
Share on other sites

(I know this is kind of a bump)

I've been working on this for a bit again, and it seems that

_chinook setvehiclevarname "chinook";

doesn't really work out. I can't access the vehicle in other scripts.

Also, I'm still hanging at the issue with the moveindriver, I'm unsure what else I could try out there to make it work.

Share this post


Link to post
Share on other sites

What? That is strange that moveInDriver is not working. That should immediately teleport the player into the chopper. Have you assigned the player as driver in the Huey? If so then use the command unassignVehicle.

Here is an updated version of script:

private["_chinook"];

_chinook = createvehicle ["CH_47F_EP1",getmarkerpos "chspawn",[],0,"NONE"]; 
_chinook setdir 220; 
_chinook setvehiclevarname "chinook"; //This line is not needed unless you want to refer to this chopper outside of the script 

player unassignVehicle; // This unassigns the player from any vehicle they are assigned to
player assignasdriver _chinook; //This assigns the player as the driver of the chopper 
player moveInDriver _chinook; //This moves the player into the driver seat of the chopper 
hintSilent "Switched to Chinook"; 
deletevehicle huey; 


huey removeaction ID; 
huey removeaction IID; 
huey removeaction switchchinook; 
_chinook addaction ["Give me a challenge","randomchallenge.sqf"];

Here is a little check to make sure the chopper is being named properly:

if(isNull chinook) then {
hintSilent "The chopper name is not assigned";
} else {
hintSilent "The chopper name is assigned";
};

Just save this as check.sqf or what ever you like, and use the addAction command in the players init like this:

this addAction ["Check Chopper Name","check.sqf"];

Hope this helps!

-Bigshot

Share this post


Link to post
Share on other sites

Using unassignvehicle didn't really help.

Strangely, the check didn't perform at all. It's not giivng me any errors, but it simply doesn't say anything.

I've assigned the check to the player (the rest of the actions, such as switching to the chinook, were assigned to the vehicle (ie "huey addaction") since I wouldn't be able to access them otherwise) so it will be available after I spawned the Chinook.

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  

×