sizraide 4 Posted September 12, 2021 Hello, deleteAt doesn't work in this for loop I typed. I want it to work when the the player performs the hold action, the hold action will delete the variable from the array. Quote private _deadUnits = [ dead1, dead2, dead3, dead4, dead5, dead6, dead7 ]; for "_i" from 0 to (count _deadUnits) - 1 do { _chosenUnit = _deadUnits select _i; params ["_object"]; [ /* 0 object */ _chosenUnit, /* 1 action title */ "Check pulse", /* 2 idle icon */ "", /* 3 progress icon */ "", /* 4 condition to show */ "true", /* 5 condition for action */ "true", /* 6 code executed on start */ {titleText ["<t align = 'center' shadow = '2' color='#ffffff' size='1.5' font='PuristaMedium' >Checking pulse...</t>", "PLAIN DOWN", -1, true, true];}, /* 7 code executed per tick */ {}, /* 8 code executed on completion */ { _deadUnits deleteAt _i; titleText ["<t align = 'center' shadow = '2' color='#ffffff' size='1.5' font='PuristaMedium' >No pulse detected.</t>", "PLAIN DOWN", -1, true, true]; titleFadeOut 2; }, /* 9 code executed on interruption */ {}, /* 10 arguments */ [""], /* 11 action duration */ 3.5, /* 12 priority */ 0, /* 13 remove on completion */ true, /* 14 show unconscious */ false ] call bis_fnc_holdActionAdd; }; waitUntil { count _deadUnits == 0 }; hint "All identified"; Share this post Link to post Share on other sites
gc8 972 Posted September 12, 2021 you can't delete from _deadUnits because it's a local variable (And therefore doesn't exist in other scripts). but if you change it from _deadUnits to deadUnits in your code it should work because then it's a global variable 1 Share this post Link to post Share on other sites
pierremgi 4817 Posted September 12, 2021 private _deadUnits = [dead1,dead2,dead3,dead4,dead5,dead6,dead7]; { [ _x, "Check pulse", "", "", "true", "true", {titleText ["<t align = 'center' shadow = '2' color='#ffffff' size='1.5' font='PuristaMedium' >Checking pulse...</t>", "PLAIN DOWN", -1, true, true];}, {}, { titleText ["<t align = 'center' shadow = '2' color='#ffffff' size='1.5' font='PuristaMedium' >No pulse detected.</t>", "PLAIN DOWN", -1, true, true]; titleFadeOut 2; }, {}, [""], 3.5, 0, true, false ] call bis_fnc_holdActionAdd } forEach _deadUnits; NOTE: removeCompleted is set to true, you don't need to deleteAt in the _deadUnits array for this purpose. 1 Share this post Link to post Share on other sites
sizraide 4 Posted September 12, 2021 2 hours ago, pierremgi said: private _deadUnits = [dead1,dead2,dead3,dead4,dead5,dead6,dead7]; { [ _x, "Check pulse", "", "", "true", "true", {titleText ["<t align = 'center' shadow = '2' color='#ffffff' size='1.5' font='PuristaMedium' >Checking pulse...</t>", "PLAIN DOWN", -1, true, true];}, {}, { titleText ["<t align = 'center' shadow = '2' color='#ffffff' size='1.5' font='PuristaMedium' >No pulse detected.</t>", "PLAIN DOWN", -1, true, true]; titleFadeOut 2; }, {}, [""], 3.5, 0, true, false ] call bis_fnc_holdActionAdd } forEach _deadUnits; NOTE: removeCompleted is set to true, you don't need to deleteAt in the _deadUnits array for this purpose. How can I make it when the players checked all the dead units something executes? Share this post Link to post Share on other sites
pierremgi 4817 Posted September 12, 2021 You can use the global variable like gc8 wrote so the variable is workable in any other script on the PC. or use the arguments. That should looks like: private _deadUnits = [dead1,dead2,dead3,dead4,dead5,dead6,dead7]; { [ _x, "Check pulse", "", "", "true", "true", {titleText ["<t align = 'center' shadow = '2' color='#ffffff' size='1.5' font='PuristaMedium' >Checking pulse...</t>", "PLAIN DOWN", -1, true, true];}, {}, { titleText ["<t align = 'center' shadow = '2' color='#ffffff' size='1.5' font='PuristaMedium' >No pulse detected.</t>", "PLAIN DOWN", -1, true, true]; titleFadeOut 2; _deadUnits = _this #3#0; _deadUnits deleteAt (_deadUnits find _target); if (_deadUnits isEqualTo []) then {hint "all are dead!"} }, {}, [_deadUnits], 3.5, 0, true, false ] call bis_fnc_holdActionAdd } forEach _deadUnits BIKI is your friend NOTE: in MP, you will have to publicVariable the array: deadUnits Share this post Link to post Share on other sites
sizraide 4 Posted September 13, 2021 23 hours ago, pierremgi said: You can use the global variable like gc8 wrote so the variable is workable in any other script on the PC. or use the arguments. That should looks like: private _deadUnits = [dead1,dead2,dead3,dead4,dead5,dead6,dead7]; { [ _x, "Check pulse", "", "", "true", "true", {titleText ["<t align = 'center' shadow = '2' color='#ffffff' size='1.5' font='PuristaMedium' >Checking pulse...</t>", "PLAIN DOWN", -1, true, true];}, {}, { titleText ["<t align = 'center' shadow = '2' color='#ffffff' size='1.5' font='PuristaMedium' >No pulse detected.</t>", "PLAIN DOWN", -1, true, true]; titleFadeOut 2; _deadUnits = _this #3#0; _deadUnits deleteAt (_deadUnits find _target); if (_deadUnits isEqualTo []) then {hint "all are dead!"} }, {}, [_deadUnits], 3.5, 0, true, false ] call bis_fnc_holdActionAdd } forEach _deadUnits BIKI is your friend NOTE: in MP, you will have to publicVariable the array: deadUnits Appreciate it! Share this post Link to post Share on other sites