Vandeanson 1676 Posted August 28, 2019 Hi all, I encountered a problem with "displayAddEventHandler" (dAEH )and "displayRemoveAllEventHandlers". In below spoiler, I add a dAEH to the player. When I press Shift+F, the variable VA_MenueOpen is set to true, which is a condition to show some Holdactions. Spoiler //initplayerlocal.sqf waituntil {!isnull (finddisplay 46)}; VA_BandAnimadda = findDisplay 46 displayAddEventHandler ["KeyDown", {params ["_displayorcontrol", "_key", "_shift", "_ctrl", "_alt"]; if ((_this select 1) == 0x21 && (_this select 2)) then {systemchat "button pressed"; if (!(player getvariable ['VA_MenueOpen',false])) then {player setvariable ["VA_MenueOpen",true,true];} else {player setvariable ["VA_MenueOpen",false,true];}; } } ]; So pressing Shift+F will either "open" or "close" the addactions that have this condition. The dAEH returns 2 at this stage, btw. so far so good. The problem is, that when I restart the SP mission with below code something gets messed up and I don't understand what is happening. The dAEH returns 5 after restart. When I press Shift + F, the EH gets triggered twice, hence the dAEH from before the restart is still there. - > So my question is, why does the dAEH persist through a restart? It seems that I have a basic missunderstanding how "displayAddEventHandler" works. -> And how could I avoid that this happens? How can I remove that specific dAEH? (findDisplay 46) displayRemoveEventHandler ["KeyDown", VA_BandAnimadda]; in line 1 of initlocal.sqf returns an error as VA_BandAnimadda is unknown. I used (findDisplay 46) displayRemoveAllEventHandlers "KeyDown"; in the initplayerlocal.sqf, line 1, but that obviously interferes with other mods. Reading the below, i understand that I tried the scripted command version of the application. "Maybe Class defined events" would be better? I just do not understand the respective guide there. https://community.bistudio.com/wiki/User_Interface_Event_Handlers#Scope EDIT: the issue does not happen on MP respawn, the code is not called inonplayerrespawn.sqf. Thanks for any help as always. cheers vd 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted August 28, 2019 Hello there Vandeanson ! This is what i'm using in my scripts , ex : addMissionEventHandler ["Loaded", { params ["_saveType"]; If(_saveType isEqualto "continue") then{ [] execVM "GF_Earplugs\GF_Earplugs.sqf"; }; }]; [] execVM "GF_Earplugs\GF_Earplugs.sqf"; 1 Share this post Link to post Share on other sites
Vandeanson 1676 Posted August 28, 2019 Thanks George, I read up on that missioneventhandler, and I am not sure what to do with it to solve my problem tbh=( Even if i get to recognize what type of game i am loading, I am currently still unable to remove that one specific dAEH. But maybe I dont get your solution yet=) cheers vd 1 Share this post Link to post Share on other sites
Vandeanson 1676 Posted August 29, 2019 Aah, you load it via the mission EH, not via init. I ll try that 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted August 29, 2019 12 hours ago, Vandeanson said: via init First run this in your init and the next load will be with the addMissionEventHandler ["Loaded" Share this post Link to post Share on other sites