Home   Help Search Login Register  

Author Topic: "createUnit" with Init line  (Read 4328 times)

0 Members and 1 Guest are viewing this topic.

Offline Knight Trane

  • Members
  • *
"createUnit" with Init line
« on: 14 Feb 2009, 19:52:34 »
Hey guys,

A quick question on "createUnit". 

I know how to use "createUnit", and setpos them where I want, but I can't figure out how to have an "init line" attached to them.  For instance,  using a ready made script thats called from a units "init line", or allows you to name the unit so it cane be manipulated by other scripts.

The Command Ref shows 2 createUnit commands. 

The first one, the group is created as an element in the array and the "init line" entry is also an element in that array.
Code: [Select]
_unit = group player createUnit ["SoldierWB", position player, [], 0, "FORM"] Is the second Command for OPF only?  If so is there a generic work around in ArmA?

The second one, you have to createGroup first, and it doesn't have an array element for "init line" entry.
Code: [Select]
"soldierWB" createUnit [getMarkerPos "marker_1", groupAlpha,"loon1 = this ; this addweapon {binocular}", 0.6, "corporal"]
I'm just a little confused by the whole thing.

Cheers
 

Offline Ext3rmin4tor

  • Members
  • *
Re: "createUnit" with Init line
« Reply #1 on: 14 Feb 2009, 20:12:34 »
The biki says that createUnit has the following parameters:

type: Classname of the vehicle or unit to create
[position, group, init, skill, rank]: Array

 - position: Position3D
 - group: existing group the unit will join
 - init: String, command to execute when the unit is created
 - skill: Number, skill of the unit
 - rank: String, rank of the unit

the last 3 parameters are optional and skill and rank have a default value of 0.5 and "PRIVATE"
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline Knight Trane

  • Members
  • *
Re: "createUnit" with Init line
« Reply #2 on: 14 Feb 2009, 20:20:40 »
That Biki page is for OFP.  But if it works for ArmA, could someone fix the Command Ref?  I have to go right now.  I'll be back tonight and test that format.

Thanks,

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: "createUnit" with Init line
« Reply #3 on: 14 Feb 2009, 20:54:06 »
The biki says that createUnit has the following parameters:
Note that there are two createUnit commands that take different parameters each:
- createUnit
- createUnit array


That Biki page is for OFP.
Nope, it's for ArmA and OFP. Take a look at the page again: the command was "Introduced in" OFP!


Anyway, both commands work just fine in ArmA. The BIKI article for "createUnit array" contains a nasty pitfall in example 3 though:

   "loon1 = this ; this addweapon {binocular}"

The curly braces work like quotes in OFP. But not in ArmA. To have quotes inside a string you have to use single quotes or two double quotes each:

   "loon1 = this ; this addweapon 'binocular' "
   "loon1 = this ; this addweapon ""binocular"" "



BTW: You can also use setVehicleInit to solve the problem.

try { return true; } finally { return false; }

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: "createUnit" with Init line
« Reply #4 on: 14 Feb 2009, 20:54:51 »
I'm sorry, but I don't understand, what exactly is needing fixed in the Comref for the createUnit commands?

I checked them over and everything looks fine and dandy to me, maybe I missed exactly what you found was incorrect?


Planck
I know a little about a lot, and a lot about a little.

Offline Knight Trane

  • Members
  • *
Re: "createUnit" with Init line
« Reply #5 on: 02 Mar 2009, 22:00:41 »
I'm sorry, but I don't understand, what exactly is needing fixed in the Comref for the createUnit commands

Everything is fine with Command Ref.  The example Worldeater sighted was confusing me, and I didn't realize "createUnit" was introduced in OFP.  I thought it only worked in OFP.  My mistake.


« Last Edit: 03 Mar 2009, 07:51:20 by h- »