createUnit: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 11: Line 11:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Create unit of given '''type'''.
| Create unit of given '''Classname''' from a CfgVehicles addon
 
Format of '''unitInfo''' is:
 
[pos ([[Position]]), group ([[Group]]),init ([[String]]), skill ([[Number]]), rank ([[String]])]
 
init, skill and rank are optional, default values are: "", 0.5, "PRIVATE".


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
____________________________________________________________________________________________
____________________________________________________________________________________________


| "type" '''createUnit''' unitInfo |= Syntax
| "ClassName" '''createUnit''' [ [[Position]], [[Group]], "init", skill, rank] |= Syntax
 
,init ([[String]]), skill ([[Number]]), rank ([[String]])]
|p1= type: [[String]] - Classname of unit to be createdas per cfgVehicles |= Parameter 1


|p2= unitInfo: [[Array]] (see above) |= Parameter 2
|p1= ClassName: [[String]] - Classname of unit to be createdas per cfgVehicles |= Parameter 1
|p2= [[Position]] |= Parameter 2
|p3= [[Group]] |= Parameter 3
|p4= init: [[String]] Optional. Default "" |= Parameter 4
|p5= skill: [[Number]] Optional. Default 0.5 |= Parameter 5
|p6= rank: [[String]]  Optional. Default "PRIVATE"|= Parameter 6


| [[Nothing]] |= Return value
| [[Nothing]] |= Return value
Line 35: Line 33:
   
   
|x1= <pre>"SoldierWB" createUnit [position player, group player]</pre> |= Example 1
|x1= <pre>"SoldierWB" createUnit [position player, group player]</pre> |= Example 1
|x2= <pre>"soldierWB" createUnit [getMarkerPos "barracks", groupAlpha]</pre> |= Example 2
|x2= <pre>"soldierWB" createUnit [getMarkerPos "barracks", _groupAlpha]</pre> |= Example 2
|x3= <pre>"soldierWB" createUnit [getMarkerPos "marker_1", groupAlpha,"loon1 = this ;
|x3= <pre>"soldierWB" createUnit [getMarkerPos "marker_1", _groupAlpha,"loon1 = this ;
  this addweapon {binocular}", 0.6, "corporal"]</pre> |= Example 3
  this addweapon {binocular}", 0.6, "corporal"]</pre> |= Example 3
____________________________________________________________________________________________
____________________________________________________________________________________________

Revision as of 08:21, 27 August 2007

Hover & click on the images for description

Description

Description:
Create unit of given Classname from a CfgVehicles addon 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, "init", skill, rank]
Parameters:
ClassName: String - Classname of unit to be createdas per cfgVehicles
Position
Group
init: String Optional. Default ""
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:
createVehiclecreateUnit arraycreateVehicle arraycreateVehicleLocaldeleteVehicle

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
Does not return anything. To give a newly created unit a name, put "newUnit = this" in the init.
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.

Bottom Section