netId: Difference between revisions
Jump to navigation
Jump to search
Killzone Kid (talk | contribs) No edit summary |
Killzone Kid (talk | contribs) (better function) |
||
Line 47: | Line 47: | ||
<code>KK_fnc_netId <nowiki>=</nowiki> { | <code>KK_fnc_netId <nowiki>=</nowiki> { | ||
[[if]] ([[isMultiplayer]]) [[exitWith]] {[[netId]] _this}; | [[if]] ([[isMultiplayer]]) [[exitWith]] {[[netId]] _this}; | ||
[[ | [[if]] ([[typeName]] _this !<nowiki>=</nowiki> "OBJECT" || {[[isNull]] _this}) [[exitWith]] {""}; | ||
[[if]] ([[isNil]] "KK_globIDs") [[then]] {KK_globIDs <nowiki>=</nowiki> [0]}; | |||
[[if]] ([[isNil]] " | [[private]] ["_i", "_cnt", "_netId"]; | ||
_i <nowiki>=</nowiki> KK_globIDs [[find]] _this; | |||
_netId <nowiki>=</nowiki> [[format]] ["0:%1", | [[if]] (_i < 0) [[exitWith]] { | ||
_cnt <nowiki>=</nowiki> (KK_globIDs [[select]] 0) + 1; | |||
}; | KK_globIDs [[set]] [0, _cnt]; | ||
_netId <nowiki>=</nowiki> [[format]] ["0:%1", _cnt]; | |||
KK_globIDs [[append]] [_netId, _this]; | |||
_netId | |||
}; | |||
KK_globIDs [[select]] (_i - 1) | |||
}; | }; | ||
//example | //example | ||
[[hint]] ([[player]] [[call]] KK_fnc_netId); | |||
</code> | </code> | ||
</dd> | </dd> | ||
</dl> | </dl> | ||
<!-- DISCONTINUE Notes --> | <!-- DISCONTINUE Notes --> |
Revision as of 11:43, 2 April 2015
Description
- Description:
- Unique ID of object or group.
- Groups:
- Uncategorised
Syntax
Examples
Additional Information
- See also:
- objectFromNetId
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
Bottom Section
- Posted on April 2, 2015 - 09:55 (UTC)
- Killzone Kid
-
netId in SP is "". Here is the function that will give you universal netId that works both in SP and MP
KK_fnc_netId = { if (isMultiplayer) exitWith {netId _this}; if (typeName _this != "OBJECT" || {isNull _this}) exitWith {""}; if (isNil "KK_globIDs") then {KK_globIDs = [0]}; private ["_i", "_cnt", "_netId"]; _i = KK_globIDs find _this; if (_i < 0) exitWith { _cnt = (KK_globIDs select 0) + 1; KK_globIDs set [0, _cnt]; _netId = format ["0:%1", _cnt]; KK_globIDs append [_netId, _this]; _netId }; KK_globIDs select (_i - 1) }; //example hint (player call KK_fnc_netId);