createUnit: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(note the usefulness of init)
mNo edit summary
Line 27: Line 27:
Format of '''unitInfo''' is:
Format of '''unitInfo''' is:


[pos ([[Position]]), group ([[Group]]),init ([[String]]), skill ([[Number]]), rank ([[String]])]
[pos ([[Position]]), group ([[Group]]),init ([[Code]]), skill ([[Number]]), rank ([[String]])]


'''Note:''' init, skill and rank are optional, default values are:
'''Note:''' init, skill and rank are optional, default values are:
Line 42: Line 42:




'''Comments:'''
'''MP Note:'''


The code in init is executed on all connected clients in 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.
It can therefore be used to get around the [[publicVariable]] limitation of not being able to send strings and arrays over the network.

Revision as of 21:55, 18 July 2006


type creatUnit unitInfo


Operand types:

type: String

unitInfo: Array

Type of returned value:

Nothing

Compatibility:

Added in version 1.34

Description:

Create unit of given type.
Format of unitInfo is:

[pos (Position), group (Group),init (Code), skill (Number), rank (String)]

Note: init, skill and rank are optional, default values are:

"", 0.5, "PRIVATE".

Note: The Group parameter MUST be an existing group or the unit won't be created.


Examples:

"soldierWB" createUnit [ getMarkerPos "barracks", groupAlpha]
"soldierWB" createUnit [ getMarkerPos "marker_1", groupAlpha, "loon1 = this ; this addWeapon {binocular}, 0.6, "corporal"]


MP Note:

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.