OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Knight Trane 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.
_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.
"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
-
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"
-
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,
-
The biki says that createUnit has the following parameters:
Note that there are two createUnit commands that take different parameters each:
- createUnit (http://community.bistudio.com/wiki/createUnit)
- createUnit array (http://community.bistudio.com/wiki/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 (http://www.ofpec.com/COMREF/index.php?action=details&id=758) to solve the problem.
-
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'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.