{"name":"BIS_fnc_initIntelObject","operator":null,"title":"BIS fnc initIntelObject","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_initIntelObject","revid":349474,"updated":"2023-11-08T16:49:19Z","groups":["Interaction"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.00"}],"since":{"game":"arma3","name":"Arma 3","version":"1.00"},"arma3_since":"1.00","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"This function sets up an object as intel retrievable by the players by adding a \"Take Intel\" addAction to it.\n\nWhen a player uses the action, they will play an animation to pick the object up and the object will be deleted from the mission.\n\nThe player and any defined recipients will then receive a diary entry which can contain a *title*, *description* and *picture*.\n\nThe diary entry will also contain a marker shortcut showing where the intel was found.\n\nThis function is similar to placing an intel object as Zeus, but the Zeus interface provides some extra options like:\n\n- Which sides can interact with the action\n- The picture, title and description used in the diary entry\n\nWhen using this function from script there are several variables that need to be set up to acquire the same results (see the examples below).\n\nWithout this extra setup the functionality provided is minimal and only includes:\n- The \"Take Intel\" action on the object\n- The object can be picked up by a player from any side\n- When picked up it will have no title or description and the picture will be a default exclamation mark\n- The diary entry will only be given to the person who picked it up\n\nThere are some optional features of intel objects that can be used:\n- The diary entry's *description* can be further enhanced by using the supported tags found on the createDiaryRecord page.\n- There is also a scripted eventhandler called *\"IntelObjectFound\"* that can be registered  on the intel object. The event provides the parameters [object, caller] where *object* is the intel object and *caller* the person who picked it up.\n- A Zeus who has the intel object registered as a curator editable object can also receive feedback that the intel has been picked up if the scripted eventhandler called *\"intelObjectFound\"* was registered on the curator module. The event provides the parameters [zeus, caller, object] where *zeus* is the curator module, *caller* the person who picked it up and *object* is the intel object.\nThe usage of these scripted event handlers is shown in #Example 3.","syntaxes":[{"syntax":"[object] call BIS_fnc_initIntelObject","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":"object to place intel action on","types":["Object"],"since":null,"text":"object: Object - object to place intel action on"}],"returns":{"type":"Boolean","types":["Boolean"],"description":"true when done","text":"Boolean - true when done"}}],"examples":[{"text":"Setup an object as intel from its init attribute in the editor.\n\nBasic version including *picture*, *title*, *description*, *recipients* and *sides that can interact with it*:\n\n```sqf\n[this] call BIS_fnc_initIntelObject;\n\nif (isServer) then\n{\n    // Diary picture:\n    this setVariable [\n        \"RscAttributeDiaryRecord_texture\",\n        \"a3\\structures_f_epc\\Items\\Documents\\Data\\document_secret_01_co.paa\", // Path to picture\n        true\n    ];\n\n    // Diary Title and Description:\n    [\n        this,\n        \"RscAttributeDiaryRecord\",\n        [\"New Intel\", \"The enemies have a cave troll!\"] // Array in format [Title, Description]\n    ] call BIS_fnc_setServerVariable;\n\n    // Diary entry shared with (follows BIS_fnc_MP target rules):\n    this setVariable [\"recipients\", west, true];\n\n    // Sides that can interact with the intel object:\n    this setVariable [\"RscAttributeOwners\", [west], true];\n};\n```","code":["[this] call BIS_fnc_initIntelObject;\n\nif (isServer) then\n{\n\t// Diary picture:\n\tthis setVariable [\n\t\t\"RscAttributeDiaryRecord_texture\",\n\t\t\"a3\\structures_f_epc\\Items\\Documents\\Data\\document_secret_01_co.paa\", // Path to picture\n\t\ttrue\n\t];\n\n\t// Diary Title and Description:\n\t[\n\t\tthis,\n\t\t\"RscAttributeDiaryRecord\",\n\t\t[\"New Intel\", \"The enemies have a cave troll!\"] // Array in format [Title, Description]\n\t] call BIS_fnc_setServerVariable;\n\n\t// Diary entry shared with (follows BIS_fnc_MP target rules):\n\tthis setVariable [\"recipients\", west, true];\n\n\t// Sides that can interact with the intel object:\n\tthis setVariable [\"RscAttributeOwners\", [west], true];\n};"]},{"text":"To set up an object as intel from its init attribute in the editor with a custom addAction title, replace the first line of #Example 1 with the following:\n\n```sqf\nif (hasInterface) then\n{\n    this addAction [\n        \"Pick up laptop\", // custom addAction title\n        { [_this, \"action\"] spawn BIS_fnc_initIntelObject },\n        [],\n        10,\n        true,\n        true,\n        \"\",\n        \"isPlayer _this && { _this distance _target < 2 } &&\n        { (side group _this) in (_target getVariable ['RscAttributeOwners', [west, east, resistance, civilian]]) }\"\n    ];\n};\n```","code":["if (hasInterface) then\n{\n\tthis addAction [\n\t\t\"Pick up laptop\", // custom addAction title\n\t\t{ [_this, \"action\"] spawn BIS_fnc_initIntelObject },\n\t\t[],\n\t\t10,\n\t\ttrue,\n\t\ttrue,\n\t\t\"\",\n\t\t\"isPlayer _this && { _this distance _target < 2 } &&\n\t\t{ (side group _this) in (_target getVariable ['RscAttributeOwners', [west, east, resistance, civilian]]) }\"\n\t];\n};"]},{"text":"Set up an object as intel from its init attribute in the editor.\n\nBasic version plus curator and scripted event handlers:\n\n```sqf\n[this] call BIS_fnc_initIntelObject;\n\nif (isServer) then\n{\n    // Diary picture:\n    this setVariable [\n        \"RscAttributeDiaryRecord_texture\",\n        \"a3\\structures_f_epc\\Items\\Documents\\Data\\document_secret_01_co.paa\", // Path to picture\n        true\n    ];\n\n    // Diary Title and Description:\n    [\n        this,\n        \"RscAttributeDiaryRecord\",\n        [\"New Intel\", \"The enemies have a cave troll!\"] // Array in format [Title, Description]\n    ] call BIS_fnc_setServerVariable;\n\n    // Diary entry shared with (follows BIS_fnc_MP target rules):\n    this setVariable [\"recipients\", west, true];\n\n    // Sides that can interact with the intel object:\n    this setVariable [\"RscAttributeOwners\", [west], true];\n\n    // Register intel object with Zeus as curator editable (_zeus is the curator module):\n    _zeus addCuratorEditableObjects [[this], false];\n\n    // Add Zeus scripted event:\n    [_zeus, \"IntelObjectFound\", {hint \"Intel found\"}] call BIS_fnc_addScriptedEventHandler;\n\n    // Add a scripted event that notifies all clients via systemChat when the intel is found:\n    [\n        this,\n        \"IntelObjectFound\",\n        {\n            params [\"\", \"_foundBy\"];\n            private _msg = format [\"Intel found by %1\", name _foundBy];\n            _msg remoteExec [\"systemChat\", 0];\n        }\n    ] call BIS_fnc_addScriptedEventHandler;\n};\n```\n\nAlthough both scripted event handlers supply a reference to the intel object, it is deleted from the mission almost immediately, so it could already be null when queried.","code":["[this] call BIS_fnc_initIntelObject;\n\nif (isServer) then\n{\n\t// Diary picture:\n\tthis setVariable [\n\t\t\"RscAttributeDiaryRecord_texture\",\n\t\t\"a3\\structures_f_epc\\Items\\Documents\\Data\\document_secret_01_co.paa\", // Path to picture\n\t\ttrue\n\t];\n\n\t// Diary Title and Description:\n\t[\n\t\tthis,\n\t\t\"RscAttributeDiaryRecord\",\n\t\t[\"New Intel\", \"The enemies have a cave troll!\"] // Array in format [Title, Description]\n\t] call BIS_fnc_setServerVariable;\n\n\t// Diary entry shared with (follows BIS_fnc_MP target rules):\n\tthis setVariable [\"recipients\", west, true];\n\n\t// Sides that can interact with the intel object:\n\tthis setVariable [\"RscAttributeOwners\", [west], true];\n\n\t// Register intel object with Zeus as curator editable (_zeus is the curator module):\n\t_zeus addCuratorEditableObjects [[this], false];\n\n\t// Add Zeus scripted event:\n\t[_zeus, \"IntelObjectFound\", {hint \"Intel found\"}] call BIS_fnc_addScriptedEventHandler;\n\n\t// Add a scripted event that notifies all clients via systemChat when the intel is found:\n\t[\n\t\tthis,\n\t\t\"IntelObjectFound\",\n\t\t{\n\t\t\tparams [\"\", \"_foundBy\"];\n\t\t\tprivate _msg = format [\"Intel found by %1\", name _foundBy];\n\t\t\t_msg remoteExec [\"systemChat\", 0];\n\t\t}\n\t] call BIS_fnc_addScriptedEventHandler;\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":[],"notes":[],"categories":["Arma 3: Functions","Arma 3: New Functions","Function Group: Interaction","Functions","Introduced with Arma 3 version 1.00"],"docblock":null,"filled_from_docblock":[]}