Jump to content
Sign in to follow this  
Op4 BuhBye

Create Flying Plane with a script?

Recommended Posts

I am trying to create 2 Harriers and there pilots and I need them flying when they are made.

Ive got the whole thing down...

Make plane

Make pilot

Assign pilot as driver

Move pilot in plane

Set height (created)

Set flyinheight

Set velocity

Set speed full

Move to marker command.

What am I missing here? All that works perfect except, The pilot never starts the engine, he just glides till he looses lift and crashes.

Can I create a piloted plane through script as though I used the editor and set it flying?

Please tell me the trick.

Share this post


Link to post
Share on other sites

av81 = #createVehicle [av8b,west1, west1, 0,fly]

error type any expected string

This is what I get. The desctription is pretty vague in the Wiki.

Using

av81 = createVehicle [av8b,west1, west1, 0,fly]

Give no errors in the editor, but gives one in preview.

Using

createVehicle [av8b,west1, west1, 0,fly]

Like the Wiki shows give an error in the editor.?

Share this post


Link to post
Share on other sites

I just did this recently to simulate an aircraft providing an air-drop. Try modifying this extract to suit.

You've missed a heap of string quotes. In examples, words like av8b are most likely variable strings (assumed to be previously assigned), not class names.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_startPos = getMarkerPos "m_Start";

_pos = getMarkerPos "m_End";

_flyingHeight = 450;

_pilot = group _caller createUnit ["SoldierWPilot", [0,0,0], [], 0, "NONE"];

[_pilot] join grpNull; // optional

_plane = createVehicle ["AV8B2", _startPos, [], 0, "FLY"];

_plane setPos _startPos;

/*[_pilot] allowGetin true;

_pilot assignAsDriver _plane;*/

_pilot moveInDriver _plane;

//_plane setDir 90.0;

_plane FlyInHeight _flyingHeight;

//_plane setVelocity [50, 0, 0];

_wp = (group _plane) addWaypoint [_pos, 110.0];

_wp setWaypointType "MOVE";

Share this post


Link to post
Share on other sites

Thanx Eyeball Ill try it. I dont know what you mean though' "AV8B" is the class name listed for the Harrier with GBUs.

Share this post


Link to post
Share on other sites

Op4 BuhBye, first (classname) and last (special) array items are string:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">av81 = createVehicle ["av8b",west1, west1, 0,"fly"]

Remember that if it's a classname it's always string, and most things that aren't objects, arrays, or numbers are usually string.

Also be advised that by using west1 twice like that is automatically incorrect, since the second item should be a position array and the third should be an array of markers. Though depening on what west1 actually is (ex: if it's a position array) it might not give you an error (or might not even have any effect).

Share this post


Link to post
Share on other sites

As I said above the wiki is extreemly vague with this. And not being a scripting guru Im not sure what some of the array requirements are.

createVehicle [type, position, markers, placement, special]

Type: I assume its the class name you want to create.

Position: I assume this is "where" you want the created object put. But what is it looking for? The example in the wiki is position player, but can you use a marker or something else?

Markers: is pretty clear to me. Use one its put there, use many its placed random.

Placement: I dont understand at all. Whats the differance between position and placement? And what is it looking for in this field?

Special: I understand.

I also assume by the example that if you dont want to use a field in the array you use "[]"?

And there are still 2 questions I had above unanswered.

Thanx to anyone who can clear this up.

Share this post


Link to post
Share on other sites

Op4 BuhBye, you're complicating things by translating the vocabulary too literally. You just can't do that.

Position: a position is always an array, never an object or marker. Position always means the actual coordinates themselves, it is not a reference to an object/marker. That's what the getPos/position/getMarkerPos commands are for. You will always be able to substitute something with code that returns that something: ex. you can substitute a position with any getPos object, position object, or getMarkerPos marker commands. If the command called for a reference to an object or a marker, the biki would state so (you'd see: Object or: Marker after it). If you have trouble remembering this, position will also always have: Array written next to it in the biki.

Placement: The biki clearly states it's a number, so that automatically means you must have a number writen in the space or some code that returns a number or some variable that is a number. That narrows it down. Then if you look at the description, the placement parameter is described: "The vehicle is placed inside a circle with this position as center and placement as its radius."

Type: string

&

Special: string

The biki always tells you what data type the parameters and retruned values are. These are both string, so even if you're confused about what they should be you know they have to be string. String must always be used with quotes around it.

Quote[/b] ]I also assume by the example that if you dont want to use a field in the array you use "[]"?

It depends. If the required type is an optional array then yes you'd use an empty array (which is what empty brackets are:[] ). If the command expects a specific type of array, say for example a position, then it must be in that format, so for positon it must be an array with 3 numeric values. If some parameters are optional then sometimes you can leave them blank. Sometimes you must use a special command like objNull for objects or grpNull for groups if the command requires the parameter but you don't want it to be an existing object or group. And sometimes the command just has alternative syntaxes. That's what the biki is for; keeping track of all this information.

Quote[/b] ]And there are still 2 questions I had above unanswered.

They were answered; 1. set special to "FLY", 2. no you must create the pilot seperately and move him into the vehicle.

Share this post


Link to post
Share on other sites

Ok so to create a plane at 100 feet and at a marker named west1 and have it flying. It should look like this...

av81 = createVehicle ["AV8B", [0,0,100], "west1", 0, "fly"]

Is this right?

I dont mean to anoy anyone but this stuff can get really complicated and its alot to take in AND retain.

Share this post


Link to post
Share on other sites

Well I got it to work but the "position" is still boggling my mind. I tried setting it to a marker and it didnt work, I also tried putting [0,0,100] in the position and got an error, so I placed the pilot where I wanted the plane and used...

av81 = createVehicle ["av8b", position pi1,[],0,"FLY"]

pi1 being the pilot. If I leave the position field blank it gives me an error in game, so I bailed on the marker and used the above.

Share this post


Link to post
Share on other sites

I've already told you, you can't use a marker or an object when it requires a position array! A position array is [x,y,z], that's what it must be. "west1" is a marker, it is not a position array! It's not that complicated, you're only trying to make it more complicated than it is. If you want to use a marker as a reference for your position, you need to use getMarkerPos to return it's position as a position array:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">av81 = createVehicle ["AV8B",getMarkerPos "west1",[],0,"FLY"]

You can't leave the position parameter blank, it needs to contain something. The position [0,0,100] is NOT a relative position, it can't possibly be since there is no reference. [0,0,100] is over the ocean. Also, you're still forgetting to use brackets for your arrays sometimes. The markers parameter's gotta be an array, you had just "west1" without any brackets around it. It needs to be ["west1"] so it is an array.

Share this post


Link to post
Share on other sites

Thanx Kyle, i just miss read the Wiki on markers...

Quote[/b] ]If the markers array contains several marker names, the position of a random one is used. Otherwise, the given position is used.

Some how I read it to say if there isnt multi markers then it uses one. Either or kinda thing. I understand it all now. Thanx for the help.

And ya I need a spankin for not using my brackets. whistle.gif

Share this post


Link to post
Share on other sites

Hey!

You could try my editor example wink_o.gif

You can define the following things in the startarray:

- StartPos

- Airtyp

- Pilottyp

- Target

- Height

- Gunner (yes or no)

- Skill

- Behaviour

- Leader ( unit(enemy/friendly) on the map, a Logic, or Player)

- Count of vehicles

Mr-Murray´s Airvehicle Creator

If u need help with it, write me a PM

Regards

Mr-Murray

Share this post


Link to post
Share on other sites

Thanx Murray, Ive spent days on this and Ive got it working now but Ill keep it in mind for the next one. thumbs-up.gif

Share this post


Link to post
Share on other sites

Does this work in MP, Mr Murray, or the other create script.

Cheers

GC

Share this post


Link to post
Share on other sites

For sure.

We tested it particulary but not enough. But I´m really sure

that it works. There were some problems with the 1.08 patch

and my airstrike/flying jets, but it´s a bug who will be hopefully fixed with the next patch.

If I´m ready with my Editing Guide Project I´ll rescript my

scripts for Arma, maybe convert them to functions.

Regards,

Mr-Murray

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  

×