BIS fnc setUnitInsignia: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "(\|[pr][0-9]+ *= *[^- ]*) *- *R([a-z ])" to "$1 - r$2")
 
(72 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 1.24


| arma3 |= Game name
|gr1= Object Manipulation


|1.24|= Game version
|arg= global


|arg= global |= Arguments in MP
|eff= global


|eff= global |= Effects in MP
|descr= Sets unit insignia (e.g., shoulder insignia on soldiers). See [[Arma 3: Unit Insignia]] for more details and a list of official insignias.
____________________________________________________________________________________________


| <pre>/*
|s1= [target, className] call [[BIS_fnc_setUnitInsignia]]


Description:
|p1= target: [[Object]] - unit to which the insignia is going to be attached
Set unit inisgnia (e.g., should insignia on soldiers)


Parameter(s):
|p2= class: [[String]] - CfgUnitInsignia class name to use. Use an empty string to remove the current insignia.
0: OBJECT
2: STRING - CfgUnitInsignia class


Returns:
|r1= [[Boolean]] - returns [[true]] if successful.
BOOL - true if insignia was set
*/


</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
|x1= Place insignia:
____________________________________________________________________________________________
<sqf>[player, "111thID"] call BIS_fnc_setUnitInsignia;</sqf>


| [ [[player]] , "111thID" ] [[call]] [[BIS_fnc_setUnitInsignia]]; |= Syntax
|x2= Remove insignia:
<sqf>[player, ""] call BIS_fnc_setUnitInsignia;</sqf>


|p1= |= Parameter 1
|seealso= [[BIS_fnc_getUnitInsignia]]
|p2= |= Parameter 2
}}
 
| [[Boolean]] - true if successful |= Return value
____________________________________________________________________________________________
 
|x1= <code></code> |=
____________________________________________________________________________________________
 
| [[Arma 3 Unit Insignia]], [[BIS_fnc_getUnitInsignia]] |= See also


{{Note
|user= Pierre MGI
|timestamp= 20160809052600
|text=In [[Arma 3: Unit Insignia]], you can read:
{{Feature|quote|You can add a new insignia in Config.cpp and Description.ext.}}
If it is possible to add a cfgUnitInsignia class in a description.ext, please note that the path of the texture differs for server and client in MP environment.
Config.cpp (addon) is more reliable. Description.ext, in this case, should be used for SP mission only.<br>
This function calls [[setObjectTextureGlobal]], which is a broken command in MP (see feedback tracker) August 2016.
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Leopard20
<!-- Note Section BEGIN -->
|timestamp= 20210621215100
<dd class="notedate">Posted on July 28, 2014 - 12:58 (UTC)
|text= To set the insignia after respawn, add this code to [[Event Scripts#initPlayerLocal.sqf|initPlayerLocal.sqf]]
<dt class="note>'''[[User:Sxp2hiiigh|Sxp2hiiigh]]'''
<sqf>
<dd class="note">Multiplayer locality (As of Arma 3 v1.24):
params ["_player"];
<br>Effect of this function is global, it should be executed consistently for JIP otherwise insignias are gone after respawn, so they have to be reapplied afterwards (On all machines again).
_player addMPEventHandler ["MPRespawn", {
<br>
params ["_unit", "_corpse"];
This would apply insignia "111thID" to player unit on all machines (incl. Join In Progress):
private _insignia = [_corpse] call BIS_fnc_getUnitInsignia;
<code>[[ [[player]], "111thID"], "[[BIS_fnc_setUnitInsignia]]", nil, [[true]], [[true]]] [[call]] [[BIS_fnc_MP]];</code>
[_unit, _insignia] spawn {
 
params ["_unit", "_insignia"];
<dd class="notedate">Posted on July 29, 2014 1500
sleep 1;
<dt class="note>'''[[User:ffur2007slx2_5|ffur2007slx2_5]]'''
isNil {
<dd class="note">(A3 1.24)Predefined textures that can be used directly in game.
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil]; // you can also do [_unit, ""] call BIS_fnc_setUnitInsignia, but this way is faster (plus no network traffic)
{| class="wikitable sortable"
[_unit, _insignia] call BIS_fnc_setUnitInsignia;
 
};
! Img
! Code
! Note
 
|-
| [[File:111thID ca.png|50px]]
| <code>[this,"111thID"] [[call]] [[BIS_fnc_setUnitInsignia]];</code>
| NATO division which dispatched one brigade to liberate Altis in Episode 3 - Win.
 
|-
| [[File:bi ca.png|50px]]
| <code>[this,"BI"] [[call]] [[BIS_fnc_setUnitInsignia]];</code>
| [[Bohemia Interactive]] glyph
 
|-
| [[File:curator ca.png|50px]]
| <code>[this,"Curator"] [[call]] [[BIS_fnc_setUnitInsignia]];</code>
| [[Zeus]] eye
 
|-
| [[File:gryffinRegiment ca.png|50px]]
| <code>[this,"GryffinRegiment"] [[call]] [[BIS_fnc_setUnitInsignia]];</code>
| CSAT regiment that occupied Altis in episodes 2 and 3 of the Arma 3 campaign.
 
|-
| [[File:manw ca.png|50px]]
| <code>[this,"MANW"] [[call]] [[BIS_fnc_setUnitInsignia]];</code>
| Make Arma Not War competition logo
 
|-
| [[File:TFAegis ca.png|50px]]
| <code>[this,"TFAegis"] [[call]] [[BIS_fnc_setUnitInsignia]];</code>
| Combined force of NATO and AAF which operated on Stratis and Altis at the beginning of Episode 1 and in the Bootcamp campaign.
 
|}
 
 
<dd class="notedate">Posted on September 29, 2014 1500
<dt class="note>'''[[User:BrotherhoodOfHam|BrotherhoodOfHam]]'''
<dd class="note">There are two ways of removing an insignia when placed.<br/>
The first way would be to run this function on the unit:
<br/>
<code>fnc_removeUnitInsignia =
{
_unit = _this [[select]] 0;
_index = -1;
{
if (_x == "insignia") [[exitwith]] {_index = _foreachindex;};
} foreach getarray (configfile >> "CfgVehicles" >> [[gettext]] ( [[configfile]] >> "CfgWeapons" >> [[uniform]] _unit >> "ItemInfo" >> "uniformClass") >> "hiddenSelections");
_unit [[setObjectTextureGlobal]] [_index, ""];
};
</code>
<code>[player] [[call]] fnc_removeUnitInsignia</code>
<br/>
The second way would be to create an empty cfgUnitInsignia class in the description.ext:
<br/>
<code>class CfgUnitInsignia
{
class empty
{
author = "";
displayName = "";
texture = "";
};
};
};</code>
}];
And then run it the normal way:
</sqf>
<code>[player, "empty"] [[call]] [[BIS_fnc_setUnitInsignia]]</code>
Notice that the previous insignia has been '''cleared''' first to make the change happen (possibly a bug as of {{arma3}} v2.05)
 
}}
<!-- Note Section END -->
</dl>
 
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Strategic|{{uc:setUnitInsignia}}]]
[[Category:Functions|{{uc:setUnitInsignia}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:setUnitInsignia}}]]
 
<!-- CONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Latest revision as of 15:47, 8 November 2023

Hover & click on the images for description

Description

Description:
Sets unit insignia (e.g., shoulder insignia on soldiers). See Arma 3: Unit Insignia for more details and a list of official insignias.
Execution:
call
Groups:
Object Manipulation

Syntax

Syntax:
[target, className] call BIS_fnc_setUnitInsignia
Parameters:
target: Object - unit to which the insignia is going to be attached
class: String - CfgUnitInsignia class name to use. Use an empty string to remove the current insignia.
Return Value:
Boolean - returns true if successful.

Examples

Example 1:
Place insignia:
[player, "111thID"] call BIS_fnc_setUnitInsignia;
Example 2:
Remove insignia:
[player, ""] call BIS_fnc_setUnitInsignia;

Additional Information

See also:
BIS_fnc_getUnitInsignia

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
Pierre MGI - c
Posted on Aug 09, 2016 - 05:26 (UTC)
In Arma 3: Unit Insignia, you can read:
«
« You can add a new insignia in Config.cpp and Description.ext. »

If it is possible to add a cfgUnitInsignia class in a description.ext, please note that the path of the texture differs for server and client in MP environment. Config.cpp (addon) is more reliable. Description.ext, in this case, should be used for SP mission only.
This function calls setObjectTextureGlobal, which is a broken command in MP (see feedback tracker) August 2016.

Leopard20 - c
Posted on Jun 21, 2021 - 21:51 (UTC)
To set the insignia after respawn, add this code to initPlayerLocal.sqf
params ["_player"]; _player addMPEventHandler ["MPRespawn", { params ["_unit", "_corpse"]; private _insignia = [_corpse] call BIS_fnc_getUnitInsignia; [_unit, _insignia] spawn { params ["_unit", "_insignia"]; sleep 1; isNil { _unit setVariable ["BIS_fnc_setUnitInsignia_class", nil]; // you can also do [_unit, ""] call BIS_fnc_setUnitInsignia, but this way is faster (plus no network traffic) [_unit, _insignia] call BIS_fnc_setUnitInsignia; }; }; }];
Notice that the previous insignia has been cleared first to make the change happen (possibly a bug as of Arma 3 v2.05)