Jump to content

ribera1945e

Member
  • Content Count

    33
  • Joined

  • Last visited

  • Medals

Posts posted by ribera1945e


  1. Hi mrcurry.
    I have tried many times and it crashes randomly only when the unit that the script described in my previous post is executed dies.
    I was able to confirm this in a test scenario where I extracted only this script.

    I have tested it by adding to the script you added the code to so that it is also debugged output at the end of the script.

    The test is to use Zeus to get the CUP's Takistan locals infantry out from under the list and shoot to kill.
    I ran the test 3 times and in each case it crashed when I killed a random unit before finishing the entire list.
    I checked the _arrayLoadout of the units that crashed on kill and found a common denominator. To my surprise, the _headgear stored the uniform class name.

    19 hours ago, ribera1945e said:

    "CUP_O_TKI_Khet_Partug_06",


    We checked the arsenal of scripted units with the script limited to only this much headgear, and found that they had uniforms in their headgear and would crash if we killed a unit with such incorrect equipment. If the wrong one of the 33 class names on the headgear list was drawn, a "mine unit" would be created.
     

    I don't know if I was tired or drunk when I wrote this list of scripts, but there is a saying in Japanese: "It is darkest under the lamp. It is probably because of my belief that the list I wrote is correct that I did not notice such a careless mistake.

    And so the crashing mission that had tormented me for two years was back to normal.

    Thank you both. Cheers to all the wonderful forum members.

     

    • Like 2

  2. Hello, JCataclisma.
    I have split and tested the scripts of the mission.
    As a result, I have identified the scripts that contain the cause.
    This is the script that gives the AI units randomized equipment by reference to their class name.

     

    /*
    Script aiLoadout
    
    Description:
    - setUnitLoadoutを使用しユニットロードアウト配列に従ってAIの装備を変更する。
    
    Parameter(s):
    - unit		: <OBJECT> 装備を変更したいユニット
    
    Example:
    - nul = [this] execVM "scripts\aiLoadout.sqf";
    
    Returns:
    - Nothing
    
    Author:
    - ribera1945e
    */
    params [["_unit", objNull, [objNull]]];
    
    if (isNull _unit) exitWith {};
    if (!local _unit) exitWith {};
    
    if (side _unit != MC_VAR_EnemySide) exitWith {};
    
    /* 初期化 */
    
    private [
    	"_arrayPrimary","_primary","_elementPrimary",
    	"_secondary","_elementSecondary",
    	"_handgun","_elementHandgun",
    	"_arrayUniform","_uniform","_elementUniform",
    	"_arrayVest","_vest","_elementVest",
    	"_arrayBackpack","_backpack","_elementBackpack",
    	"_arrayHeadgear","_headgear",
    	"_arrayGoggles","_goggles",
    	"_bino","_elementBino",
    	"_NV"
    ];
    _arrayPrimary = [];
    _primary = [];
    _elementPrimary = [];
    _secondary = [];
    _elementSecondary = [];
    _handgun = [];
    _elementHandgun = [];
    _arrayUniform = [];
    _uniform = [];
    _elementUniform = [];
    _arrayVest = [];
    _vest = [];
    _elementVest = [];
    _arrayBackpack = [];
    _backpack = [];
    _elementBackpack = [];
    _arrayHeadgear = [];
    _headgear = [];
    _arrayGoggles = [];
    _goggles = [];
    _bino = [];
    _elementBino = [];
    _NV = [];
    //空の装備を読み込み
    private _arrayLoadout = getUnitLoadout (configFile >> "EmptyLoadout");
    
    /* 共通装備登録 */
    _arrayHeadgear = [
    	"CUP_O_TKI_Khet_Partug_06",
    	"CUP_H_TKI_Lungee_Open_06",
    	"CUP_H_TK_Lungee",
    	"CUP_H_TKI_Lungee_Open_01",
    	"CUP_H_TKI_Lungee_Open_02",
    	"CUP_H_TKI_Lungee_Open_03",
    	"CUP_H_TKI_Lungee_Open_04",
    	"CUP_H_TKI_Lungee_Open_05",
    	"CUP_H_TKI_Lungee_Open_06",
    	"CUP_H_TKI_Lungee_01",
    	"CUP_H_TKI_Lungee_02",
    	"CUP_H_TKI_Lungee_03",
    	"CUP_H_TKI_Lungee_04",
    	"CUP_H_TKI_Lungee_05",
    	"CUP_H_TKI_Lungee_06",
    	"CUP_H_TKI_Pakol_1_01",
    	"CUP_H_TKI_Pakol_2_04",
    	"CUP_H_TKI_Pakol_2_05",
    	"CUP_H_TKI_Pakol_2_06",
    	"CUP_H_TKI_Pakol_1_02",
    	"CUP_H_TKI_Pakol_1_03",
    	"CUP_H_TKI_Pakol_1_04",
    	"CUP_H_TKI_Pakol_1_05",
    	"CUP_H_TKI_Pakol_1_06",
    	"CUP_H_TKI_Pakol_2_01",
    	"CUP_H_TKI_Pakol_2_02",
    	"CUP_H_TKI_Pakol_2_03",
    	"CUP_H_TKI_SkullCap_01",
    	"CUP_H_TKI_SkullCap_02",
    	"CUP_H_TKI_SkullCap_03",
    	"CUP_H_TKI_SkullCap_04",
    	"CUP_H_TKI_SkullCap_05",
    	"CUP_H_TKI_SkullCap_06"
    ];
    _headgear = selectRandom _arrayHeadgear;
    
    _arrayUniform = [
    	"CUP_O_TKI_Khet_Jeans_04",
    	"CUP_O_TKI_Khet_Jeans_02",
    	"CUP_O_TKI_Khet_Jeans_01",
    	"CUP_O_TKI_Khet_Jeans_03",
    	"CUP_O_TKI_Khet_Partug_04",
    	"CUP_O_TKI_Khet_Partug_02",
    	"CUP_O_TKI_Khet_Partug_01",
    	"CUP_O_TKI_Khet_Partug_07",
    	"CUP_O_TKI_Khet_Partug_08",
    	"CUP_O_TKI_Khet_Partug_05",
    	"CUP_O_TKI_Khet_Partug_06"
    ];
    _uniform = selectRandom _arrayUniform;
    
    _arrayVest = [
    	"CUP_V_OI_TKI_Jacket2_04",
    	"CUP_V_OI_TKI_Jacket4_04",
    	"CUP_V_OI_TKI_Jacket4_05",
    	"CUP_V_OI_TKI_Jacket4_02",
    	"CUP_V_OI_TKI_Jacket4_06",
    	"CUP_V_OI_TKI_Jacket4_03",
    	"CUP_V_OI_TKI_Jacket4_01",
    	"CUP_V_OI_TKI_Jacket3_04",
    	"CUP_V_OI_TKI_Jacket3_02",
    	"CUP_V_OI_TKI_Jacket3_03",
    	"CUP_V_OI_TKI_Jacket3_05",
    	"CUP_V_OI_TKI_Jacket3_06",
    	"CUP_V_OI_TKI_Jacket3_01",
    	"CUP_V_OI_TKI_Jacket6_04",
    	"CUP_V_OI_TKI_Jacket6_05",
    	"CUP_V_OI_TKI_Jacket6_02",
    	"CUP_V_OI_TKI_Jacket6_06",
    	"CUP_V_OI_TKI_Jacket6_03",
    	"CUP_V_OI_TKI_Jacket6_01",
    	"CUP_V_OI_TKI_Jacket2_04",
    	"CUP_V_OI_TKI_Jacket2_06",
    	"CUP_V_OI_TKI_Jacket2_03",
    	"CUP_V_OI_TKI_Jacket2_02",
    	"CUP_V_OI_TKI_Jacket2_05",
    	"CUP_V_OI_TKI_Jacket2_01"
    ];
    _vest = selectRandom _arrayVest;
    
    _arrayBackpack = [
    	"CUP_B_AlicePack_Bedroll",
    	"CUP_B_AlicePack_Khaki",
    	"CUP_B_AlicePack_OD",
    	"CUP_B_Bergen_BAF",
    	"CUP_B_CivPack_WDL",
    	"CUP_B_ACRPara_dpm",
    	"CUP_B_ACRPara_m95",
    	"CUP_B_HikingPack_Civ",
    	"CUP_B_RUS_Backpack",
    	"CUP_B_TacticalPack_CCE",
    	"CUP_B_TacticalPack_TTS"
    ];
    _backpack = selectRandom _arrayBackpack;
    
    _arrayGoggles = [
    	"G_Bandanna_blk",
    	"G_Bandanna_khk",
    	"G_Bandanna_oli",
    	"G_Bandanna_shades",
    	"G_Bandanna_sport",
    	"G_Bandanna_tan",
    	"TRYK_Beard_BK",
    	"TRYK_Beard_BK2",
    	"TRYK_Beard_BK3",
    	"TRYK_Beard_BK4",
    	"TRYK_SBeard_BK6",
    	"CUP_Beard_Black"
    ];
    _goggles = selectRandom _arrayGoggles;
    
    /* Identity */
    private ["_arrayFace","_face","_arraySpeeker","_speeker","_pitch"];
    	_arrayFace = [
    	"PersianHead_A3_01",
    	"PersianHead_A3_02",
    	"PersianHead_A3_03"
    	];
    _face = selectRandom _arrayFace;
    
    	_arraySpeeker = [
    	"cup_d_male01_tk",
    	"cup_d_male02_tk",
    	"cup_d_male03_tk",
    	"cup_d_male04_tk",
    	"cup_d_male05_tk"
    	];
    _speeker = selectRandom _arraySpeeker;
    
    _pitch = random[0.8,1,1.2];
    
    /* Gear selection */
    private "_type";
    switch(typeOf _unit) do{
    	
    	case "CUP_I_TK_GUE_Soldier_AT":	// RPG7 man
    	{
    		_arrayPrimary = [
    			"CUP_arifle_AKMS_Early",
    			"CUP_arifle_AKMS",
    			"CUP_arifle_AKS"
    		];
    		_primary = selectRandom _arrayPrimary;
    		_elementPrimary = [_primary,
    			"",
    			"",
    			"",
    			["CUP_30Rnd_TE1_Green_Tracer_762x39_AK47_M",30],
    			[],
    			""
    		];
    		
    		_elementVest = [_vest,[
    			["CUP_30Rnd_TE1_Green_Tracer_762x39_AK47_M",6,30],
    			["rhs_mag_f1",1,1]
    		]];
    		
    		_secondary = "launch_RPG7_F";
    		_elementSecondary = [_secondary,
    			"",
    			"",
    			"",
    			["RPG7_F",1],
    			[],
    			""
    		];
    		
    		_elementBackpack = ["rhs_rpg_empty",[
    			["RPG7_F",2,1]
    		]];
    	};
    	
    	case "CUP_I_TK_GUE_Soldier_GL":	// Grenadier
    	{
    		_arrayPrimary = [
    			"CUP_arifle_AK47_GL_Early",
    			"CUP_arifle_AKM_GL_Early",
    			"CUP_arifle_AKM_GL",
    			"CUP_arifle_AKMS_GL_Early",
    			"CUP_arifle_AKMS_GL",
    			"CUP_arifle_AK47_GL"
    		];
    		_primary = selectRandom _arrayPrimary;
    		_elementPrimary = [_primary,
    			"",
    			"",
    			"",
    			["CUP_30Rnd_TE1_Green_Tracer_762x39_AK47_M",30],
    			["rhs_VOG25",1],
    			""
    		];
    		_elementVest = [_vest,[
    			["CUP_30Rnd_TE1_Green_Tracer_762x39_AK47_M",6,30],
    			["CUP_1Rnd_HE_GP25_M",1,1],
    			["rhs_mag_f1",1,1]
    		]];
    		_elementBackpack = [_backpack,[
    			["CUP_30Rnd_TE1_Green_Tracer_762x39_AK47_M",6,30],
    			["CUP_1Rnd_HE_GP25_M",1,1]
    		]];
    	};
    	
    	case "CUP_I_TK_GUE_Soldier_AR":	// Auto rifleman RPK74
    	{
    		_primary = "CUP_arifle_RPK74_45";
    		_elementPrimary = [_primary,
    			"",
    			"",
    			"",
    			["rhs_45Rnd_545X39_AK_Green",45],
    			[],
    			""
    		];
    		_elementVest = [_vest,[
    			["rhs_45Rnd_545X39_AK_Green",5,45],
    			["rhs_mag_f1",1,1]
    		]];
    		_elementBackpack = [_backpack,[
    			["rhs_45Rnd_545X39_AK_Green",5,40]
    		]];
    	};
    	
    	case "CUP_I_TK_GUE_Soldier_MG":	// Machinegunner
    	{
    		_primary = "CUP_lmg_PKM";
    		_elementPrimary = [_primary,
    			"",
    			"",
    			"",
    			["CUP_100Rnd_TE4_LRT4_762x54_PK_Tracer_Green_M",100],
    			[],
    			""
    		];
    		_elementVest = [_vest,[
    			["CUP_100Rnd_TE4_LRT4_762x54_PK_Tracer_Green_M",2,100],
    			["rhs_mag_f1",1,1]
    		]];
    		_elementBackpack = [_backpack,[
    			["CUP_100Rnd_TE4_LRT4_762x54_PK_Tracer_Green_M",3,100]
    		]];
    	};
    	
    	case "CUP_I_TK_GUE_Guerilla_Enfield":	// Marksman
    	{
    		_primary = "CUP_srifle_SVD";
    		_elementPrimary = [_primary,
    			"",
    			"",
    			"CUP_optic_PSO_1",
    			["CUP_10Rnd_762x54_SVD_M",10],
    			[],
    			""
    		];
    		_elementVest = [_vest,[
    			["CUP_10Rnd_762x54_SVD_M",6,10],
    			["rhs_mag_f1",1,1]
    		]];
    		_elementBackpack = [_backpack,[
    			["CUP_10Rnd_762x54_SVD_M",6,10]
    		]];
    	};
    	
    	case "CUP_I_TK_GUE_Sniper":	// Sniper
    	{
    		_primary = "CUP_srifle_ksvk";
    		_elementPrimary = [_primary,
    			"",
    			"",
    			"CUP_optic_PSO_3",
    			["CUP_5Rnd_127x108_KSVK_M",5],
    			[],
    			""
    		];
    		_elementVest = [_vest,[
    			["CUP_5Rnd_127x108_KSVK_M",4,5],
    			["rhs_mag_f1",1,1]
    		]];
    		_elementBackpack = [_backpack,[
    			["CUP_5Rnd_127x108_KSVK_M",4,5]
    		]];
    	};
    	
    	case "CUP_I_TK_GUE_Soldier_TL":	// Team Leader
    	{
    		_arrayVest = [
    			"V_TacVest_blk",
    			"V_TacVest_brn",
    			"V_TacVest_camo",
    			"V_TacVest_khk",
    			"V_TacVest_oli",
    			"V_I_G_resistanceLeader_F"
    		];
    		_vest = selectRandom _arrayVest;
    		
    		_primary = "CUP_arifle_M4A3_black";
    		_elementPrimary = [_primary,
    			"",
    			"CUP_acc_ANPEQ_15_Top_Flashlight_Black_L",
    			"CUP_optic_ACOG_TA31_KF",
    			["CUP_30Rnd_556x45_Stanag_Tracer_Red",30],
    			[],
    			""
    		];
    		_elementVest = [_vest,[
    			["CUP_30Rnd_556x45_Stanag_Tracer_Red",6,30],
    			["rhs_mag_f1",1,1]
    		]];
    		_elementBackpack = [_backpack,[
    			["CUP_30Rnd_556x45_Stanag_Tracer_Red",6,30]
    		]];
    	};
    	
    	case "CUP_I_TK_GUE_Commander":	// Warlord
    	{
    		_uniform = "CUP_O_TKI_Khet_Partug_01";
    		_elementPrimary = ["CUP_arifle_AKS74U",
    			"",
    			"",
    			"",
    			["CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M",30],
    			[],
    			""
    		];
    		_vest = "CUP_V_OI_TKI_Jacket5_04";
    		_elementVest = [_vest,[
    			["CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M",6,30],
    			["rhs_mag_f1",1,1]
    		]];
    		_backpack = "";
    		_face = "Mavros";
    		_speeker = "male03gre";
    		_headgear = "CUP_H_TKI_Lungee_Open_04";
    		_goggles = "CUP_Beard_Black";
    	};
    	
    	case "C_man_1":	// Civilian
    	{
    		_vest = "";
    		_backpack = "";
    	};
    	
    		default
    	{
    		_type = selectRandom ["typeAR","typeAK"];
    		switch(_type) do{
    			case "typeAR":
    			{
    				_arrayPrimary = [
    					"CUP_arifle_M16A2",
    					"CUP_arifle_Colt727",
    					"CUP_arifle_M4A1"
    				];
    				_primary = selectRandom _arrayPrimary;
    				_elementPrimary = [_primary,
    					"",
    					"",
    					"",
    					["CUP_30Rnd_556x45_Stanag_Tracer_Red",30],
    					[],
    					""
    				];
    				
    				_elementVest = [_vest,[
    					["CUP_30Rnd_556x45_Stanag_Tracer_Red",6,30],
    					["rhs_mag_f1",1,1]
    				]];
    				_elementBackpack = [_backpack,[
    					["CUP_30Rnd_556x45_Stanag_Tracer_Red",6,30]
    				]];
    			};
    			case "typeAK":
    			{
    				_arrayPrimary = [
    					"CUP_arifle_AK74",
    					"CUP_arifle_AKS74",
    					"CUP_arifle_AK74_Early",
    					"CUP_arifle_AKS74_Early"
    				];
    				_primary = selectRandom _arrayPrimary;
    				_elementPrimary = [_primary,
    					"",
    					"",
    					"",
    					["CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M",30],
    					[],
    					""
    				];
    				
    				_elementVest = [_vest,[
    					["CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M",6,30],
    					["rhs_mag_f1",1,1]
    				]];
    				_elementBackpack = [_backpack,[
    					["CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M",6,30]
    				]];
    			};
    		};
    	};
    };
    
    /* Uniform element set */
    _elementUniform = [_uniform,[
    	["ACE_fieldDressing",5],
    	["ACE_elasticBandage",5],
    	["ACE_packingBandage",5],
    	["ACE_tourniquet",1],
    	["ACE_splint",1]
    ]];
    
    
    /* Construct haracter */
    _arrayLoadout = [
    	_elementPrimary,
    	_elementSecondary,
    	_elementHandgun,
    	_elementUniform,
    	_elementVest,
    	_elementBackpack,
    	_headgear,
    	_goggles,
    	_elementBino,
    	[
    		"ItemMap",		// Map type
    		"ItemGPS",		// GPS type
    		"ItemRadio",	// Radio type
    		"ItemCompass",	// Compass type
    		"ItemWatch",	// Watch type
    		_NV				// NV type
    	]
    ];
    
    _unit setUnitLoadout _arrayLoadout;
    [_unit, _face, _speeker, _pitch] call BIS_fnc_setIdentity;
    
    nil

    If a unit to which this script is applied dies, it will crash with a certain probability.
    Is there something wrong with this script?
    Cheer.


  3. I created the mission using a script in an environment with add-ons in place.
    However, when testing in multiplayer, when I place a BRUFOR AI unit group in ZEUS and have them attack the AO, it crashes with access violations in the middle of the mission. This is the same on both dedicated and hosted servers.
    I am new to scripting and with the help of a friend I created a mission but could not find the cause of the crash.
    I would like to ask everyone to help me debug this mission.

    Here is the zip of the mission and the add-on preset html we are using

    Thanks.


  4. Apparently I was writing unnecessary processing.
    If you change the processing of the initial value, JIP will also be synchronized.
    I've finally got the code to work as intended in JIP-enabled multiplayer, so I'll share it:

    /*-----------------------------------------------------------------------------------
    Script: liveFeedUAV
    Description:
    	UAVのカメラフィードバックをモニターオブジェクトに行う。
    Parameters:
    	_monitor	- <OBJECT> フィードバック再生とaddActionを行うオブジェクト
    Return:
    	Nothing
    Examples:
    	(in initPlayerLocal.sqf)
    	nul = [yourMonitor] execVM "scripts\liveFeedUAV1.sqf";
    	(in init.sqf)
    	[missionNamespace, "arsenalClosed", {
    		[yourMonitor] execVM "scripts\liveFeedUAV1.sqf";
    	}] call BIS_fnc_addScriptedEventHandler;
    	["ace_arsenal_displayClosed", {
    		[yourMonitor] execVM "scripts\liveFeedUAV1.sqf";
    	}] call CBA_fnc_addEventHandler;
    Author:
    	ribera1945eBP
    -----------------------------------------------------------------------------------*/
    
    
    params ["_monitor"];
    
    if (isNull _monitor) exitWith {};
    sleep 1;
    
    if (localNamespace getVariable ["liveFeedUAV1done", false]) exitWith {
    	_cam1 = (localNamespace getVariable "cam1");
    	_cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
    };
    
    _monitor setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt1,1)"];
    
    _cam1 = "camera" camCreate [0,0,0];
    _cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
    _cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
    
    localNamespace setVariable ["cam1", _cam1];
    liveFeedUAV1cams = [];
    
    fnc_selectZoom = {
    	private _sZoom = _this select 0;
    	private _cam1 = _this select 1;
    	switch (_sZoom) do {
    		case "ULTRA WIDE":
    		{
    			missionNamespace setVariable ["zoomLevel", 0.46599999, true];
    		};
    		case "WIDE":
    		{
    			missionNamespace setVariable ["zoomLevel", 0.2, true];
    		};
    		case "MEDIUM":
    		{
    			missionNamespace setVariable ["zoomLevel", 0.1, true];
    		};
    		case "NARROW":
    		{
    			missionNamespace setVariable ["zoomLevel", 0.02, true];
    		};
    		case "NARROWER":
    		{
    			missionNamespace setVariable ["zoomLevel", 0.01, true];
    		};
    	};
    };
    
    fnc_selectMode = {
    	private _sMode = _this select 0;
    	switch (_sMode) do {
    		case "DTV":
    		{
    			missionNamespace setVariable ["camMode", [0], true];
    		};
    		case "NV":
    		{
    			missionNamespace setVariable ["camMode", [1], true];
    		};
    		case "WHOT":
    		{
    			missionNamespace setVariable ["camMode", [2], true];
    		};
    		case "BHOT":
    		{
    			missionNamespace setVariable ["camMode", [7], true];
    		};
    	};
    };
    
    
    {
    	private _actionTitle = format ["Select Zoom - %1",_x];
    	_monitor addAction [
    		_actionTitle,
    		{
    			private _Value = _this select 3 select 0;
    			[_Value, (localNamespace getVariable "cam1")] call fnc_selectZoom;
    		},
    		[_x],3.3,true,false,"","",8
    	];
    } forEach ["ULTRA WIDE", "WIDE", "MEDIUM", "NARROW", "NARROWER"];
    
    {
    	private _actionTitle = format ["Select Mode - %1",_x];
    	_monitor addAction [
    		_actionTitle,
    		{
    			private _Value = _this select 3 select 0;
    			[_Value] call fnc_selectMode;
    		},
    		[_x],3.3,true,false,"","",8
    	];
    } forEach ["DTV", "NV", "WHOT", "BHOT"];
    
    localNamespace setVariable ["liveFeedUAV1done", true];
    
    0 = liveFeedUAV1cams pushBack [localNamespace getVariable "cam1"];
    
    addMissionEventHandler ["Draw3D", {
    	{
    		_cam1 = _x select 0;
    		_dir = 
    			(MQ_1 selectionPosition "laser_start") 
    				vectorFromTo 
    			(MQ_1 selectionPosition "laser_end");
    		_cam1 setVectorDirAndUp [
    			_dir, 
    			_dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
    		];
    		_cam1 camSetFov (missionNamespace getVariable ["zoomLevel", 0.46599999]);
    		"uavrtt1" setPiPEffect (missionNamespace getVariable ["camMode", [0]]);
    	} count liveFeedUAV1cams;
    }];

    There is still a possibility of optimization, but this is the end for the time being.

    @7erra

    @pierremgi

    Thanks for teaching me a lot!

    • Like 4

  5. Thank you for the detailed lecture.
    I thought that everything would work if remoteExec was done. Please forgive the script rookie.
    Now I'm running camSetFov and setPiPEffect in Draw3D. This works as intended in multiplayer.

    Spoiler
    
    /*-----------------------------------------------------------------------------------
    Script: liveFeedUAV
    Description:
    	UAVのカメラフィードバックをモニターオブジェクトに行う。
    Parameters:
    	_monitor	- <OBJECT> フィードバック再生とaddActionを行うオブジェクト
    Return:
    	Nothing
    Examples:
    	(in initPlayerLocal.sqf)
    	nul = [yourMonitor] execVM "scripts\liveFeedUAV1.sqf";
    	(in init.sqf)
    	[missionNamespace, "arsenalClosed", {
    		[yourMonitor] execVM "scripts\liveFeedUAV1.sqf";
    	}] call BIS_fnc_addScriptedEventHandler;
    	["ace_arsenal_displayClosed", {
    		[yourMonitor] execVM "scripts\liveFeedUAV1.sqf";
    	}] call CBA_fnc_addEventHandler;
    Author:
    	ribera1945eBP
    -----------------------------------------------------------------------------------*/
    
    
    params ["_monitor"];
    
    if (isNull _monitor) exitWith {};
    sleep 1;
    
    if (localNamespace getVariable ["liveFeedUAV1done", false]) exitWith {
    	_cam1 = (localNamespace getVariable "cam1");
    	_cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
    };
    
    if (missionNamespace getVariable ["liveFeedUAV1doneNoJIP", true]) then {
    	missionNamespace setVariable ["zoomLevel", 0.46599999];
    	missionNamespace setVariable ["camMode", [0]];
    };
    
    _monitor setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt1,1)"];
    
    _cam1 = "camera" camCreate [0,0,0];
    _cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
    _cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
    
    localNamespace setVariable ["cam1", _cam1];
    liveFeedUAV1cams = [];
    
    fnc_selectZoom = {
    	private _sZoom = _this select 0;
    	private _cam1 = _this select 1;
    	switch (_sZoom) do {
    		case "ULTRA WIDE":
    		{
    			missionNamespace setVariable ["zoomLevel", 0.46599999, true];
    		};
    		case "WIDE":
    		{
    			missionNamespace setVariable ["zoomLevel", 0.2, true];
    		};
    		case "MEDIUM":
    		{
    			missionNamespace setVariable ["zoomLevel", 0.1, true];
    		};
    		case "NARROW":
    		{
    			missionNamespace setVariable ["zoomLevel", 0.02, true];
    		};
    		case "NARROWER":
    		{
    			missionNamespace setVariable ["zoomLevel", 0.01, true];
    		};
    	};
    };
    
    fnc_selectMode = {
    	private _sMode = _this select 0;
    	switch (_sMode) do {
    		case "DTV":
    		{
    			missionNamespace setVariable ["camMode", [0], true];
    		};
    		case "NV":
    		{
    			missionNamespace setVariable ["camMode", [1], true];
    		};
    		case "WHOT":
    		{
    			missionNamespace setVariable ["camMode", [2], true];
    		};
    		case "BHOT":
    		{
    			missionNamespace setVariable ["camMode", [7], true];
    		};
    	};
    };
    
    
    {
    	private _actionTitle = format ["Select Zoom - %1",_x];
    	_monitor addAction [
    		_actionTitle,
    		{
    			private _Value = _this select 3 select 0;
    			[_Value, (localNamespace getVariable "cam1")] call fnc_selectZoom;
    		},
    		[_x],3.3,true,false,"","",8
    	];
    } forEach ["ULTRA WIDE", "WIDE", "MEDIUM", "NARROW", "NARROWER"];
    
    {
    	private _actionTitle = format ["Select Mode - %1",_x];
    	_monitor addAction [
    		_actionTitle,
    		{
    			private _Value = _this select 3 select 0;
    			[_Value] call fnc_selectMode;
    		},
    		[_x],3.3,true,false,"","",8
    	];
    } forEach ["DTV", "NV", "WHOT", "BHOT"];
    
    localNamespace setVariable ["liveFeedUAV1done", true];
    missionNamespace setVariable ["liveFeedUAV1doneNoJIP", false];
    
    0 = liveFeedUAV1cams pushBack [localNamespace getVariable "cam1"];
    
    addMissionEventHandler ["Draw3D", {
    	{
    		_cam1 = _x select 0;
    		_dir = 
    			(MQ_1 selectionPosition "laser_start") 
    				vectorFromTo 
    			(MQ_1 selectionPosition "laser_end");
    		_cam1 setVectorDirAndUp [
    			_dir, 
    			_dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
    		];
    		_cam1 camSetFov (missionNamespace getVariable ["zoomLevel", 0.46599999]);
    		"uavrtt1" setPiPEffect (missionNamespace getVariable ["camMode", [0]]);
    	} count liveFeedUAV1cams;
    }];

     


    However, JIP still seems to be loading the initial values of zoomLevel and camMode.
    I want to borrow your wisdom once again.

     

    Thanks.


  6. @7erra

    Thank you for your reply.
    I wrote !IsServer at the beginning to prevent addAction from running on all machines.
    I modified the code based on your point:

     

    Spoiler
    
    /*-----------------------------------------------------------------------------------
    Script: liveFeedUAV
    Description:
    	UAVのカメラフィードバックをモニターオブジェクトに行う。
    Parameters:
    	_monitor	- <OBJECT> フィードバック再生とaddActionを行うオブジェクト
    Return:
    	Nothing
    Examples:
    	(in your monitor init)
    	nul = [this] execVM "scripts\liveFeedUAV1.sqf";
    	(in init.sqf)
    	[missionNamespace, "arsenalClosed", {
    		[yourMonitor] execVM "scripts\liveFeedUAV1.sqf";
    	}] call BIS_fnc_addScriptedEventHandler;
    	["ace_arsenal_displayClosed", {
    		[monitor_1] execVM "scripts\liveFeedUAV1.sqf";
    	}] call CBA_fnc_addEventHandler;
    Author:
    	ribera1945eBP
    -----------------------------------------------------------------------------------*/
    
    
    params ["_monitor"];
    
    if (isNull _monitor) exitWith {};
    sleep 1;
    
    if (missionNamespace getVariable ["liveFeedUAV1done", false]) exitWith {
    	// cam1 cameraEffect ["TERMINATE", "BACK"];
    	// camDestroy cam1;
    	
    	cam1 = "camera" camCreate [0,0,0];
    	cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
    	cam1 camSetFov 0.46599999;
    	"uavrtt1" setPiPEffect [0];
    	cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
    };
    
    _monitor setObjectTextureGlobal [0, "#(argb,512,512,1)r2t(uavrtt1,1)"];
    
    cam1 = objNull;
    missionNamespace setVariable ["cam1", cam1];
    
    cam1 = "camera" camCreate [0,0,0];
    cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
    cam1 camSetFov 0.46599999;
    "uavrtt1" setPiPEffect [0];
    
    cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
    
    fnc_selectZoom = {
    	private _sZoom = _this select 0;
    	switch (_sZoom) do {
    		case "ULTRA WIDE":
    		{
    			[missionNamespace getVariable "cam1", 0.46599999] remoteExec ["camSetFov", 0];
    		};
    		case "WIDE":
    		{
    			[missionNamespace getVariable "cam1", 0.2] remoteExec ["camSetFov", 0];
    		};
    		case "MEDIUM":
    		{
    			[missionNamespace getVariable "cam1", 0.1] remoteExec ["camSetFov", 0];
    		};
    		case "NARROW":
    		{
    			[missionNamespace getVariable "cam1", 0.02] remoteExec ["camSetFov", 0];
    		};
    		case "NARROWER":
    		{
    			[missionNamespace getVariable "cam1", 0.01] remoteExec ["camSetFov", 0];
    		};
    	};
    };
    
    fnc_selectMode = {
    	private _sMode = _this select 0;
    	switch (_sMode) do {
    		case "DTV":
    		{
    			["uavrtt1", [0]] remoteExec ["setPiPEffect", 0];
    		};
    		case "NV":
    		{
    			["uavrtt1", [1]] remoteExec ["setPiPEffect", 0];
    		};
    		case "WHOT":
    		{
    			["uavrtt1", [2]] remoteExec ["setPiPEffect", 0];
    		};
    		case "BHOT":
    		{
    			["uavrtt1", [7]] remoteExec ["setPiPEffect", 0];
    		};
    	};
    };
    
    
    {
    	private _actionTitle = format ["Select Zoom - %1",_x];
    	[_monitor, [
    		_actionTitle,
    		{
    			private _Value = _this select 3 select 0;
    			[_Value] call fnc_selectZoom;
    		},
    		[_x],3.3,true,false,"","",8
    	]] remoteExec ["addAction", 2];
    } forEach ["ULTRA WIDE", "WIDE", "MEDIUM", "NARROW", "NARROWER"];
    
    {
    	private _actionTitle = format ["Select Mode - %1",_x];
    	[_monitor, [
    		_actionTitle,
    		{
    			private _Value = _this select 3 select 0;
    			[_Value] call fnc_selectMode;
    		},
    		[_x],3.3,true,false,"","",8
    	]] remoteExec ["addAction", 2];
    } forEach ["DTV", "NV", "WHOT", "BHOT"];
    
    missionNamespace setVariable ["liveFeedUAV1done", true];
    
    addMissionEventHandler ["Draw3D", {
        _dir = 
            (MQ_1 selectionPosition "laser_start") 
                vectorFromTo 
            (MQ_1 selectionPosition "laser_end");
        cam1 setVectorDirAndUp [
            _dir, 
            _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
        ];
    }];

     

    But fnc_selectZoom stopped working in preview.
    I don't get an error, but camSetFov doesn't seem to recognize cam1.
    What should I do?


  7. Hello. I am making a PiP script that runs on a dedicated server.
    It works as intended in the preview, but not in multiplayer.
    Below is the code:

     

    Spoiler
    
    /*-----------------------------------------------------------------------------------
    Script: liveFeedUAV
    Description:
    	UAVのカメラフィードバックをモニターオブジェクトに行う。
    Parameters:
    	_monitor	- <OBJECT> フィードバック再生とaddActionを行うオブジェクト
    Return:
    	Nothing
    Examples:
    	(in your monitor init)
    	nul = [this] execVM "scripts\liveFeedUAV1.sqf";
    	(in init.sqf)
    	[missionNamespace, "arsenalClosed", {
    		[yourMonitor] execVM "scripts\liveFeedUAV1.sqf";
    	}] call BIS_fnc_addScriptedEventHandler;
    Author:
    	ribera1945eBP
    -----------------------------------------------------------------------------------*/
    if (!isServer) exitWith {};
    
    params ["_monitor"];
    
    if (isNull _monitor) exitWith {};
    sleep 1;
    
    if (missionNamespace getVariable ["liveFeedUAV1done", false]) exitWith {
    	// cam1 cameraEffect ["TERMINATE", "BACK"];
    	// camDestroy cam1;
    	
    	cam1 = "camera" camCreate [0,0,0];
    	cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
    	cam1 camSetFov 0.46599999;
    	"uavrtt1" setPiPEffect [0];
    	cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
    };
    
    _monitor setObjectTextureGlobal [0, "#(argb,512,512,1)r2t(uavrtt1,1)"];
    cam1 = objNull;
    missionNamespace setVariable ["cam1", cam1];
    
    cam1 = "camera" camCreate [0,0,0];
    cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
    cam1 camSetFov 0.46599999;
    "uavrtt1" setPiPEffect [0];
    
    cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
    
    fnc_selectZoom = {
    	private _sZoom = _this select 0;
    	switch (_sZoom) do {
    		case "ULTRA WIDE":
    		{
    			cam1 camSetFov 0.46599999;
    		};
    		case "WIDE":
    		{
    			cam1 camSetFov 0.2;
    		};
    		case "MEDIUM":
    		{
    			cam1 camSetFov 0.1;
    		};
    		case "NARROW":
    		{
    			cam1 camSetFov 0.02;
    		};
    		case "NARROWER":
    		{
    			cam1 camSetFov 0.01;
    		};
    	};
    };
    
    fnc_selectMode = {
    	private _sMode = _this select 0;
    	switch (_sMode) do {
    		case "DTV":
    		{
    			["uavrtt1", [0]] remoteExec ["setPiPEffect", 0];
    		};
    		case "NV":
    		{
    			["uavrtt1", [1]] remoteExec ["setPiPEffect", 0];
    		};
    		case "WHOT":
    		{
    			["uavrtt1", [2]] remoteExec ["setPiPEffect", 0];
    		};
    		case "BHOT":
    		{
    			["uavrtt1", [7]] remoteExec ["setPiPEffect", 0];
    		};
    	};
    };
    
    
    {
    	private _actionTitle = format ["Select Zoom - %1",_x];
    	[_monitor, [
    		_actionTitle,
    		{
    			private _Value = _this select 3 select 0;
    			[_Value] call fnc_selectZoom;
    		},
    		[_x],3.3,true,false,"","",8
    	]] remoteExec ["addAction", 0];
    } forEach ["ULTRA WIDE", "WIDE", "MEDIUM", "NARROW", "NARROWER"];
    
    {
    	private _actionTitle = format ["Select Mode - %1",_x];
    	[_monitor, [
    		_actionTitle,
    		{
    			private _Value = _this select 3 select 0;
    			[_Value] call fnc_selectMode;
    		},
    		[_x],3.3,true,false,"","",8
    	]] remoteExec ["addAction", 0];
    } forEach ["DTV", "NV", "WHOT", "BHOT"];
    
    missionNamespace setVariable ["liveFeedUAV1done", true];
    
    addMissionEventHandler ["Draw3D", {
        _dir = 
            (MQ_1 selectionPosition "laser_start") 
                vectorFromTo 
            (MQ_1 selectionPosition "laser_end");
        cam1 setVectorDirAndUp [
            _dir, 
            _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
        ];
    }];

     

    I have implemented zoom and PiPEffect change functions using addAction, but changes to the monitor are not synchronized in multiplayer.

     

    Thanks.

     


  8. I gave up on how to execute code inside an event handler.

    Instead, I succeeded in calling liveFeedUAV1.sqf from init.sqf with pierremgi's code.

    But another problem arose. I limited the code with exitWith to avoid multiple execution of all the code in liveFeedUAV1.sqf, but cameraEffect and camCreate are not working with the following syntax.

    if (missionNamespace getVariable ["liveFeedUAV1done", false] isEqualTo true) exitWith {
    	cam1 cameraEffect ["TERMINATE", "BACK"];
    	camDestroy cam1;
    	
    	cam1 = "camera" camCreate [0,0,0];
    	cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
    	cam1 camSetFov 0.46599999;
    	"uavrtt1" setPiPEffect [0];
    	cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
    };

    I think the if statement is correct as it works when I run hint in the syntax.
    Maybe I overlook something?

     

    Thanks.


  9. After the screen goes black, run the following code on the server to restore the monitor.

    	isNil {
    		cam1 cameraEffect ["TERMINATE", "BACK"];
    		camDestroy cam1;
    
    		cam1 = "camera" camCreate [0,0,0];
    		cam1 cameraEffect ["INTERNAL", "BACK", "uavrtt1"];
    		cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
    	};

    Is it possible for the event handler to not recognize the variable name?


  10. I ran it globally with init.sqf, but it had no effect.

    I also tried the following syntax to regenerate cam1 but it didn't work.

    //PIP arsenal proof
    [missionNamespace, "arsenalClosed", {
    	isNil {
    		cam1 cameraEffect ["TERMINATE", "BACK"];
    		camDestroy cam1;
    
    		cam1 = "camera" camCreate [0,0,0];
    		cam1 cameraEffect ["INTERNAL", "BACK", "uavrtt1"];
    		cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
    	};
    }] call BIS_fnc_addScriptedEventHandler;

     


  11. Spoiler
    
    /*-----------------------------------------------------------------------------------
    Script: liveFeedUAV
    Description:
    	UAVのカメラフィードバックをモニターオブジェクトに行う。
    Parameters:
    	_monitor	- <OBJECT> フィードバック再生とaddActionを行うオブジェクト
    Return:
    	Nothing
    Examples:
    	nul = [this] execVM "scripts\liveFeedUAV1.sqf";
    Author:
    	ribera1945eBP
    -----------------------------------------------------------------------------------*/
    if (!isServer) exitWith {};
    
    params ["_monitor"];
    
    if (isNull _monitor) exitWith {};
    
    _monitor setObjectTextureGlobal [0, "#(argb,512,512,1)r2t(uavrtt1,1)"];
    
    cam1 = "camera" camCreate [0,0,0];
    cam1 cameraEffect ["Internal", "Back", "uavrtt1"];
    
    cam1 attachTo [MQ_1, [0,0,0], "PiP0_pos"];
    
    fnc_selectZoom = {
    	private _sZoom = _this select 0;
    	switch (_sZoom) do {
    		case "ULTRA WIDE":
    		{
    			cam1 camSetFov 0.46599999;
    		};
    		case "WIDE":
    		{
    			cam1 camSetFov 0.2;
    		};
    		case "MEDIUM":
    		{
    			cam1 camSetFov 0.1;
    		};
    		case "NARROW":
    		{
    			cam1 camSetFov 0.02;
    		};
    		case "NARROWER":
    		{
    			cam1 camSetFov 0.01;
    		};
    	};
    };
    
    fnc_selectMode = {
    	private _sMode = _this select 0;
    	switch (_sMode) do {
    		case "DTV":
    		{
    			"uavrtt1" setPiPEffect [0];;
    		};
    		case "NV":
    		{
    			"uavrtt1" setPiPEffect [1];
    		};
    		case "WHOT":
    		{
    			"uavrtt1" setPiPEffect [2];
    		};
    		case "BHOT":
    		{
    			"uavrtt1" setPiPEffect [7];
    		};
    	};
    };
    
    {
    	private _actionTitle = format ["Select Zoom - %1",_x];
    	_monitor addAction [
    		_actionTitle,
    		{
    			private _Value = _this select 3 select 0;
    			[_Value] call fnc_selectZoom;
    		},
    		[_x],3.3,true,false,"","",8
    	];
    } forEach ["ULTRA WIDE", "WIDE", "MEDIUM", "NARROW", "NARROWER"];
    
    {
    	private _actionTitle = format ["Select Mode - %1",_x];
    	_monitor addAction [
    		_actionTitle,
    		{
    			private _Value = _this select 3 select 0;
    			[_Value] call fnc_selectMode;
    		},
    		[_x],3.3,true,false,"","",8
    	];
    } forEach ["DTV", "NV", "WHOT", "BHOT"];
    
    addMissionEventHandler ["Draw3D", {
        _dir = 
            (MQ_1 selectionPosition "laser_start") 
                vectorFromTo 
            (MQ_1 selectionPosition "laser_end");
        cam1 setVectorDirAndUp [
            _dir, 
            _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
        ];
    }];

     

    Its code


  12. if (!isServer) exitWith {};
    
    params [["_display", objNull], ["_feeder", objNull]];
    
    _display setObjectTextureGlobal [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
    
    cam = "camera" camCreate [0,0,0];
    cam cameraEffect ["Internal", "Back", "uavrtt"];
    
    cam attachTo [_feeder, [0,0,0], "PiP0_pos"];
    cam camSetFov 0.7;
    "uavrtt" setPiPEffect [0];
    
    addMissionEventHandler ["Draw3D", {
        _dir = 
            (_feeder selectionPosition "PiP0_pos") 
                vectorFromTo 
            (_feeder selectionPosition "PiP0_dir");
        cam setVectorDirAndUp [
            _dir, 
            _dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
        ];
    }];

    http://killzonekid.com/arma-scripting-tutorials-uav-r2t-and-pip/

    I read KK's blog and made a live feed script, but the turret vector is not reflected with the following error:

     

    '..eder selectionPosition "PiP0_dir");

    cam |#|setVectorDirAndUp [

    _dir,

    _dir vectorCr...'

    Error 0 elements provided, 3 expected

    The UAV thinks there is a problem with the code as it gives the same error when using a vanilla one.

×