Liberty Bull   23 Posted July 30, 2021 *** Edit*** Solved, this was a bug resulting from a mod. 🙄  In my mission I have a detection script that shows whether you are hidden or in danger whenever the player is crouched/proned. Works flawlessly except when saving and reloading. After reloading, when you crouch the indicator pops up for half of a second and then disappears, along with a little vignette that also pops and disappears on the edges of the screen kind of like the effect when the player is tired. Every time I try crouching again, the indicator pops and disappears. So I know the trigger is still firing, and the effect is still displaying the hidden text, but then breaks?  I have a trigger set to repeat with condition to detect if player is not standing as well as if no enemys knowsabout the player. In activation I have it run my script "textdetectionhidden.sqf" with the following code: txtDetectionALayer = "txtDetectionA" call BIS_fnc_rscLayer; _texta = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ffb742' shadow='2'>[HIDDEN]</t>", textDetectionA]; [_texta, 0.0,-0.25,/*durata*/ 300,/* fade in?*/ 0,0,txtDetectionALayer] spawn BIS_fnc_dynamicText;  Now when the player is spotted, I have another trigger, similar condition but with an enemy knowsabout player >= 1,, with activation running the script "textdetectiondanger.sqf" txtDetectionALayer = "txtDetectionA" call BIS_fnc_rscLayer; _texta = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ff432D' shadow='2'>[DANGER]</t>"]; [_texta, 0.0,-0.25,/*durata*/ .5,/* fade in?*/ .5,0,txtDetectionALayer] spawn BIS_fnc_dynamicText;   I have looked in to save game not storing the state of trigger, but this is not a loop, but a trigger that activates on certain conditions, and as we see, it does still fire after a save game but is broken. I also have another gui function that displays the name of the player's cursortarget, similarly using a trigger and calling scripts but that doesn't break. I thought maybe this is because for that nametag script I wrote a function, but last night I tried turning my detection scripts into functions but it still seemed to break while the nametag did not. Share this post Link to post Share on other sites
Liberty Bull   23 Posted July 30, 2021 So as a weird developement, when the player dies the indicator starts working normally in his death scene. When an AI saw me, the "DANGER" indicator flickered and disappeared like the usual bug im trying to squash, but as soon as the AI killed me, the danger indicator re-appeared and stayed on screen. Share this post Link to post Share on other sites
Smart Games   76 Posted July 30, 2021 As simple as that:  create the file "initPlayerLocal.sqf" in your mission folder and put this code in it: while {alive player} do { private _text = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ffb742' shadow='2'>%1</t>", stance player]; [_text, 0,0,5,0,0, "layer" call BIS_fnc_rscLayer] spawn BIS_fnc_dynamicText; sleep .5; };  or the simpler version:  put this code in your players init: [] spawn { while {alive player} do { private _text = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ffb742' shadow='2'>%1</t>", stance player]; [_text, 0,0,5,0,0, "layer" call BIS_fnc_rscLayer] spawn BIS_fnc_dynamicText; sleep .5; }; };  remove your triggers.  Edit: looks like I didn't read well. Yeah, that`s not the solution your looking for, sorry! ^^ Share this post Link to post Share on other sites
Liberty Bull   23 Posted July 30, 2021 Strange, putting your code in fixed my stealth indicator by somehow absorbing the bug, so the new text from your code indicating players stance begins blinking while my stealth indicator is okay. Share this post Link to post Share on other sites
Smart Games   76 Posted July 30, 2021 2 minutes ago, Liberty Bull said: Strange, putting your code in fixed my stealth indicator by somehow absorbing the bug, so the new text from your code indicating players stance begins blinking while my stealth indicator is okay. nothing should be "blinking". Where do you put the code in? Remove the triggers when using my code! Share this post Link to post Share on other sites
Liberty Bull   23 Posted July 30, 2021 My original problem is that my stealth indicator blinks on reloading a save. I placed the code into my initplayerlocal.sqf.  Here is a video of the issue. Note that prior to adding the code you gave, it was my [HIDDEN] stealth indicator that would be "blinking". I'm either doing something wrong or theres an arma bug, probnably the former as I am inexperienced with scripting. sleep 5; moduleName_keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", "if ((_this select 1) == 20 && var_vatsstop) then {var_vatson = [] execVM 'vats.sqf'};"]; moduleName_keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", "if ((_this select 1) == 20 && !var_vatsstop) then {var_vatsoff = [] execVM 'vatsstop.sqf'};"]; while {alive player} do { private _text = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ffb742' shadow='2'>%1</t>", stance player]; [_text, 0,0,5,0,0, "layer" call BIS_fnc_rscLayer] spawn BIS_fnc_dynamicText; sleep .5; }; [] spawn { _adjustLight = { CHBN_adjustBrightness = CHBN_adjustBrightness max 0 min 1; _brightness = if (CHBN_adjustBrightness > 0) then {200 * abs (1 - (2 ^ CHBN_adjustBrightness))} else {0}; CHBN_light setLightAttenuation [10e10,(30000 / (_brightness max 10e-10)),4.31918e-005,4.31918e-005]; CHBN_light setLightAmbient CHBN_adjustColor; }; waitUntil {time > 0}; if (missionNamespace getVariable ["CHBN_running",false]) exitWith {systemChat ""}; CHBN_running = true; CHBN_adjustBrightness = missionNamespace getVariable ["CHBN_adjustBrightness",1]; // edit the level of brightness here, set to 1, can be 0.1 to however high you want it CHBN_adjustColor = missionNamespace getVariable ["CHBN_adjustColor",[0.5,0.7,1]]; if (!isNil "CHBN_light") then {deleteVehicle CHBN_light}; CHBN_light = "#lightpoint" createVehicleLocal [0,0,0]; CHBN_light setLightBrightness 1; CHBN_light setLightDayLight false; call _adjustLight; for "_i" from 0 to 1 step 0 do { _adjustBrightness = CHBN_adjustBrightness; _adjustColor = CHBN_adjustColor; waitUntil {!(_adjustBrightness isEqualTo CHBN_adjustBrightness) || !(_adjustColor isEqualTo CHBN_adjustColor)}; call _adjustLight; }; };  Share this post Link to post Share on other sites
Smart Games   76 Posted July 30, 2021 Whatever... that should be the solution you are looking for:  [] spawn { while {alive player} do { _knowledge = east knowsAbout player; _stance = stance player; if (_stance == "CROUCH" || _stance == "PRONE") then { if (_knowledge > 0) then { private _text = parseText "<t align = 'center' valign = 'top' size='0.6' color='#ffb742' shadow='2'>[DANGER]</t>"; [_text, 0,0,1,0,0, "layer" call BIS_fnc_rscLayer] spawn BIS_fnc_dynamicText; } else { private _text = parseText "<t align = 'center' valign = 'top' size='0.6' color='#ffb742' shadow='2'>[HIDDEN]</t>"; [_text, 0,0,1,0,0, "layer" call BIS_fnc_rscLayer] spawn BIS_fnc_dynamicText; }; } else { ["", 0,0,1,0,0, "layer" call BIS_fnc_rscLayer] spawn BIS_fnc_dynamicText; }; sleep .5; }; };  1) Remove your triggers! 2) Put the code above in your players init 3) modify the code: _knowledge = east knowsAbout player; the side can be changed to west, east, civilian, independent Share this post Link to post Share on other sites
Smart Games   76 Posted July 30, 2021 The problem is (most likely), that some loops are conflicting with each other.  Loop A says: hide the text Loop B says: show the text   Share this post Link to post Share on other sites
Liberty Bull   23 Posted July 30, 2021 You are probably right, and honestly over the month it took to develop this mission I have learned things to the point where the earlier functions I made are alot sloppier than later efforts. This detection script is an example of one of the first things I did, and later functions didn't use triggers, so you are probably right. I am going to convert it over to script like you said and see how it goes. Share this post Link to post Share on other sites
Smart Games   76 Posted July 30, 2021 Double check everything. There must no be any more triggers or scripts that call BIS_fnc_dynamicText.  4 minutes ago, Liberty Bull said: I am going to convert it over to script like you said and see how it goes. Let me know if it's working for you! Share this post Link to post Share on other sites
Liberty Bull   23 Posted July 30, 2021 Okay, I'll have to figure out something because I have a few functions that call BIS_fnc_dynamicText, this stealth indicator, a nametag function that displays the cursortarget's name while within 4 meters to them, and custom task notifications that say various things such as quests being added, completed, updated, etc. Share this post Link to post Share on other sites
Smart Games   76 Posted July 30, 2021 Just now, Liberty Bull said: Okay, I'll have to figure out something because I have a few functions that call BIS_fnc_dynamicText, this stealth indicator, a nametag function that displays the cursortarget's name while within 4 meters to them, and custom task notifications that say various things such as quests being added, completed, updated, etc. All of them are going to conflict with each other at some point. Looks like you have to rewrite some of your code and add some exceptions.  The easiest way to solve the problem would be to add all of them into one loop.   Share this post Link to post Share on other sites
Liberty Bull   23 Posted July 30, 2021 Just now, Smart Games said: All of them are going to conflict with each other at some point. Looks like you have to rewrite some of your code and add some exceptions.  The easiest way to solve the problem would be to add all of them into one loop.    That's what I figured. For most of the functions, they have the %1 and I would tell the function what to type so I only had different functions to have the text be formatted differently. Share this post Link to post Share on other sites
Smart Games   76 Posted July 30, 2021 Should you have a problem with this, you can simply write to me, I'll be happy to help you! Share this post Link to post Share on other sites
Liberty Bull   23 Posted July 30, 2021 (edited) I appreciate it! I actually did a dumb thing and for simplicity sake of my initial post kind of fibbed about the original function. For me I wanted there to also be a "caution" phase and arma's knowsabbout wasnt giving me the results, so I figured out a way to get it to work, rather than simple "knowsabout". Looking at your code, it definitely would have simplified things.  Here is my attempt at converting my triggers to code:  [] spawn { while {alive player} do { if (side player == resistance) then { var_dangerUnits = []; { if (side _x isEqualTo east || side _x isEqualTo west) then { if (_x knowsAbout player >= 1.50) then { if (((_x getHideFrom player) distanceSqr player) < 200) then { var_dangerUnits pushback _x; }; }; }; } forEach allUnits; var_cautiousUnits = []; { if (side _x isEqualTo east || side _x isEqualTo west) then { if (_x knowsAbout player >= 0.70) then { if (((_x getHideFrom player) distanceSqr player) < 2500) then { var_cautiousUnits pushback _x; }; }; }; } forEach allUnits; }; if (side player == east) then { var_dangerUnits = []; { if (side _x isEqualTo resistance || side _x isEqualTo west) then { if (_x knowsAbout player >= 1.50) then { if (((_x getHideFrom player) distanceSqr player) < 200) then { var_dangerUnits pushback _x; }; }; }; } forEach allUnits; var_cautiousUnits = []; { if (side _x isEqualTo resistance || side _x isEqualTo west) then { if (_x knowsAbout player >= 0.70) then { if (((_x getHideFrom player) distanceSqr player) < 2500) then { var_cautiousUnits pushback _x; }; }; }; } forEach allUnits; }; if (side player == west) then { var_dangerUnits = []; { if (side _x isEqualTo east || side _x isEqualTo resistance) then { if (_x knowsAbout player >= 1.50) then { if (((_x getHideFrom player) distanceSqr player) < 200) then { var_dangerUnits pushback _x; }; }; }; } forEach allUnits; var_cautiousUnits = []; { if (side _x isEqualTo east || side _x isEqualTo resistance) then { if (_x knowsAbout player >= 0.70) then { if (((_x getHideFrom player) distanceSqr player) < 2500) then { var_cautiousUnits pushback _x; }; }; }; } forEach allUnits; }; if (stance player == "CROUCH" || stance player == "PRONE") then { if (count var_cautiousUnits == 0 && count var_dangerUnits == 0) then { txtDetectionALayer = "txtDetectionA" call BIS_fnc_rscLayer; _textdetecta = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ffb742' shadow='2'>[HIDDEN]</t>"]; [_textdetecta, 0.0,-0.25,/*durata*/ 300,/* fade in?*/ 0,0,txtDetectionALayer] spawn BIS_fnc_dynamicText; }; if (count var_cautiousUnits > 0 && count var_dangerUnits == 0) then { txtDetectionALayer = "txtDetectionA" call BIS_fnc_rscLayer; _textdetecta = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ff432D' shadow='2'>[CAUTION]</t>"]; [_textdetecta, 0.0,-0.25,/*durata*/ 300,/* fade in?*/ 0,0,txtDetectionALayer] spawn BIS_fnc_dynamicText; }; if (count var_dangerUnits > 0) then { txtDetectionALayer = "txtDetectionA" call BIS_fnc_rscLayer; _textdetecta = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ff432D' shadow='2'>[DANGER]</t>"]; [_textdetecta, 0.0,-0.25,/*durata*/ 300,/* fade in?*/ 0,0,txtDetectionALayer] spawn BIS_fnc_dynamicText; }; } else { txtDetectionALayer = "txtDetectionA" call BIS_fnc_rscLayer; _textdetecta = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ffb742' shadow='2'>[DEBUG]</t>"]; [_textdetecta, 0.0,-0.25,/*durata*/ 300,/* fade in?*/ 0,0,txtDetectionALayer] spawn BIS_fnc_dynamicText; }; sleep .5; }; };  Edited July 30, 2021 by Liberty Bull updated code Share this post Link to post Share on other sites
Liberty Bull   23 Posted July 30, 2021 This was also so long because I put in a disguise system that lets the player change sides and it wouldn't return my expected behavior without checking the sides. I was hoping sideEnemy or something would be able to take its place but couldnt figure it out  ** Edit ** I fixed and updated the code in the post immediately above this one, and it works to convert my code from triggers to script, however upon reload i still get the blinking issue =/  *** Edit 2 *** As an experiment, I made sure to take all triggers/references to my detection script out, and execVMd the script after a save/reload and it is still blinking, even though it hadnt run the script even once yet. With this, I decided to make a new mission on stratis, copied over my script from the post just before this one, and on a reload it blinks, even without it having any other items able to effect it.  Even the simple script you gave me "blinks" upon a reload. It's starting to look like this is an Arma bug with BIS_fnc_dynamicText.  *** Edit 3 *** Well, today kids we learn about taking a step back and properly diagnosing. It turns out the "blinking" is caused by a mod I had running (A mod that is required by the conversion mod I am making this mission for). I had assumed that it was due to my lack of scripting knowledge i didnt even consider that a mod would cause this issue, but it seems to. Share this post Link to post Share on other sites
Smart Games   76 Posted July 30, 2021 That's a faster and shortion Option: no need to spawn it! If you spawn enemy units dynamically, make _allUnits a global Variable and update it every time you have spawned enemys! Update _allUnits every time the player changes his side. private _allUnits = allUnits select {side _x != side player && side _x != civilian}; while {alive player} do { private _danger = false; private _cautious = false; private _textdetecta = ""; private _layer = "txtDetectionA" call BIS_fnc_rscLayer; { if (_x knowsAbout player >= 1.50) then { if (((_x getHideFrom player) distanceSqr player) < 200) exitWith {_danger = true}; }; } forEach _allUnits; { if (_x knowsAbout player >= 0.70) then { if (((_x getHideFrom player) distanceSqr player) < 2500) exitWith {_cautious = true}; }; } forEach _allUnits; if (stance player == "CROUCH" || stance player == "PRONE") then { if (_cautious == false && _danger == false) then { _textdetecta = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ffb742' shadow='2'>[HIDDEN]</t>"]; }; if (_cautious == true && _danger == false) then { _textdetecta = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ff432D' shadow='2'>[CAUTION]</t>"]; }; if (_danger == true) then { _textdetecta = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ff432D' shadow='2'>[DANGER]</t>"]; }; } else { _textdetecta = parseText format ["<t align = 'center' valign = 'top' size='0.6' color='#ffb742' shadow='2'>[DEBUG]</t>"]; }; [_textdetecta, 0.0,-.25,300,0,0, _layer] spawn BIS_fnc_dynamicText; sleep .5; };  2 Share this post Link to post Share on other sites
sarogahtyp   1109 Posted July 30, 2021 (edited) @Smart Games dont use count array > 0 faster is array isNotEqualTo []  also count array == 0 faster is array isEqualTo []  also allUnits select {side _x != side player && side _x != civilian}; faster should be (but here I guess) allUnits select {side _x getFriend side player < 0.6}; U may need to add some braces but ... i m on mobile   Edit: I missed this one _cautious == true && _danger == false is the same as _cautious && not _danger  there is never a need for comparing with true or false Edited July 30, 2021 by sarogahtyp 2 Share this post Link to post Share on other sites
Smart Games   76 Posted July 30, 2021 1 minute ago, sarogahtyp said: @Smart Games dont use count array > 0 faster is array isNotEqualTo []  also count array == 0 faster is array isEqualTo []  also allUnits select {side _x != side player && side _x != civilian}; faster should be (but here I guess) allUnits select {side _x getFriend side player < 0.6}; U may need to add some braces but ... i m on mobile Updated it a few times in the meantime. I never heard of getFriend, but it seems to be useful. Share this post Link to post Share on other sites