createUnit: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (see also)
m (expanded parameter description)
Line 11: Line 11:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Create unit of given '''Classname''' from a CfgVehicles addon
| Create unit of a class that's defined in [[:Category:CfgVehicles|CfgVehicles]].


The Group parameter '''MUST''' be an existing group or the unit won't be created. |= Description
The Group parameter '''MUST''' be an existing group or the unit won't be created. |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


| "ClassName" '''createUnit''' [ [[Position]], [[Group]], "init", skill, rank] |= Syntax
| "ClassName" '''createUnit''' [ position, group, initialization, skill, rank] |= Syntax
,init ([[String]]), skill ([[Number]]), rank ([[String]])]
,init ([[String]]), skill ([[Number]]), rank ([[String]])]


|p1= ClassName: [[String]] - Classname of unit to be createdas per cfgVehicles |= Parameter 1
|p1= ClassName: [[String]] - Classname of unit to be createdas per cfgVehicles |= Parameter 1
|p2= [[Position]] |= Parameter 2
|p2= position: [[Position]] - Location unit is created at. |= Parameter 2
|p3= [[Group]] |= Parameter 3
|p3= group: [[Group]] - Existing group new unit will join. |= Parameter 3
|p4= init: [[String]] Optional. Default "" |= Parameter 4
|p4= initialization: [[String]] - (optional, default "") Command to be executed upon creation of unit. |= Parameter 4
|p5= skill: [[Number]] Optional. Default 0.5 |= Parameter 5
|p5= skill: [[Number]] - (optional, default 0.5) |= Parameter 5
|p6= rank: [[String]] Optional. Default "PRIVATE"|= Parameter 6
|p6= rank: [[String]] - (optional, default "PRIVATE") |= Parameter 6


| [[Nothing]] |= Return value
| [[Nothing]] |= Return value
Line 46: Line 46:
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on August 13, 2006 - 12:32</dd>
<dd class="notedate">Posted on August 13, 2006 - 12:32</dd>
<dt class="note">'''[[User:Raedor|raedor]]'''</dt><dd class="note">Does not return anything. To give a newly created unit a name, put "newUnit = this" in the init.</dd>
<dt class="note">'''[[User:Raedor|raedor]]'''</dt><dd class="note">To give a newly created unit a name, put "newUnit = this" in the init field.</dd>
<dd class="notedate">Posted on 18:41, 5 April 2007 (CEST)</dd>
<dd class="notedate">Posted on 18:41, 5 April 2007 (CEST)</dd>
<dt class="note">'''[[User:Shuko|Shuko]]'''</dt><dd class="note">The eventhandlers added with [[addEventHandler]] in the init parameter will only fire locally on the machine where this creation command is called from.</dd>
<dt class="note">'''[[User:Shuko|Shuko]]'''</dt><dd class="note">The eventhandlers added with [[addEventHandler]] in the init parameter will only fire locally on the machine where this creation command is called from.</dd>

Revision as of 01:06, 18 November 2008

Hover & click on the images for description

Description

Description:
Create unit of a class that's defined in CfgVehicles. The Group parameter MUST be an existing group or the unit won't be created.
Multiplayer:
The code in init is executed on all connected clients in multiplayer. It can therefore be used to get around the publicVariable limitation of not being able to send strings and arrays over the network.
Groups:
Uncategorised

Syntax

Syntax:
"ClassName" createUnit [ position, group, initialization, skill, rank]
Parameters:
ClassName: String - Classname of unit to be createdas per cfgVehicles
position: Position - Location unit is created at.
group: Group - Existing group new unit will join.
initialization: String - (optional, default "") Command to be executed upon creation of unit.
skill: Number - (optional, default 0.5)
rank: String - (optional, default "PRIVATE")
Return Value:
Nothing

Examples

Example 1:
"SoldierWB" createUnit [position player, group player]
Example 2:
"soldierWB" createUnit [getMarkerPos "barracks", _groupAlpha]
Example 3:
"soldierWB" createUnit [getMarkerPos "marker_1", _groupAlpha,"loon1 = this ;
 this addweapon {binocular}", 0.6, "corporal"]

Additional Information

See also:
createUnit arraycreateCentercreateGroupcreateVehicle

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Posted on August 13, 2006 - 12:32
raedor
To give a newly created unit a name, put "newUnit = this" in the init field.
Posted on 18:41, 5 April 2007 (CEST)
Shuko
The eventhandlers added with addEventHandler in the init parameter will only fire locally on the machine where this creation command is called from.
Posted on December 24, 2007 - 00:33
MulleDK13
If you do not wish it to be in a group, you can create a gamelogic and group it to that.
Note: The unit will deny to move away from the gamelogic.

Bottom Section