pliskin124 4 Posted May 16, 2022 Thanks for reading my thread! I am trying to create a script that will disable a players Escape button options while they are serving jail time for friendly fire, then re-enable it once the cell door opens. This is to prevent them just respawning and circumventing their punishment. I have searched through the forums and cannot find an option that actually works. I do not want to disable all of the players input so they can look out the window and communicate with others should they wish to see them. Here is the current script which teleports the player to the jail cell and makes them sit for 5 minutes following their killing of a friendly unit: playMusic "gameIntro"; titleText ["Court Martial!","BLACK OUT",3]; player setPos (getPos Cell1); Jail1 animate ["door_2_rot",0]; removeAllWeapons player; removeAllItems player; removeAllAssignedItems player; removeVest player; removeBackpack player; removeHeadgear player; removeGoggles player; removeUniform player; player forceAddUniform "U_C_WorkerCoveralls"; titleText ["You must serve 5 minutes in jail","BLACK IN",4]; sleep 300; enableSerialization; if (!alive player) then {((findDisplay 49) displayctrl 104) ctrlShow true;}; titleText ["Jail Time Served","WHITE IN",4]; Jail1 animate ["door_2_rot",1]; player addRating 2000; Any assistance would be appreciated. Share this post Link to post Share on other sites
pliskin124 4 Posted May 16, 2022 0 = [] spawn { waitUntil {!isNull findDisplay 46}; findDisplay 46 displayAddEventHandler ["keyDown",{ params ["_ctrl","_key"]; private _h = false; if (_key == 156) then {_h = true}; _h }] }; Managed to dig around and find a solution for disabling the key... However I need to re-enable the escape key once the timer is up. Suggestions? Share this post Link to post Share on other sites
sarogahtyp 1108 Posted May 16, 2022 not tested now but I used something like this in the past to suppress pause menu: interrupt_EH_index = ( [ missionNamespace, "OnGameInterrupt", { _this # 0 closeDisplay 2; }] call BIS_fnc_addScriptedEventHandler ); here the code to allow it: [ missionNamespace, "OnGameInterrupt", interrupt_EH_index ] call BIS_fnc_removeScriptedEventHandler; 2 Share this post Link to post Share on other sites
pliskin124 4 Posted May 16, 2022 Yeah I came across one of your old posts in the past but it didn't seem to work. The one above seems to be working I just can't for the life of me figure out how to re-enable the escape key Share this post Link to post Share on other sites
dreadedentity 278 Posted May 17, 2022 6 hours ago, pliskin124 said: However I need to re-enable the escape key once the timer is up. Suggestions? displayAddEventHandler returns the id number or -1 if it fails, store that into a variable then use displayRemoveEventHandler to delete it: (findDisplay 46) displayRemoveEventHandler ["KeyDown", _id]; Share this post Link to post Share on other sites
sarogahtyp 1108 Posted May 17, 2022 5 hours ago, pliskin124 said: Yeah I came across one of your old posts in the past but it didn't seem to work. idk what you think what you tested but this works flawlessly in debug console: [] spawn { interrupt_EH_index = [ missionNamespace, "OnGameInterrupt", { _this # 0 closeDisplay 2; } ] call BIS_fnc_addScriptedEventHandler; hint "menu allowed in 6"; sleep 2; hint "menu allowed in 4"; sleep 2; hint "menu alowed in 2"; sleep 2; [ missionNamespace, "OnGameInterrupt", interrupt_EH_index ] call BIS_fnc_removeScriptedEventHandler; hint "menu allowed now"; }; Share this post Link to post Share on other sites
dreadedentity 278 Posted May 17, 2022 I did some digging in the config and I found that the pause menu is display ID 49 and it's name in the config is "RscDisplayInterrupt". The following works in debug console: ((findDisplay 49) displayCtrl 2) ctrlEnable false; //Disable "CONTINUE" button But when I tried putting more code around it to make it automatic, it stopped working. It seems SQF gets paused as well when the Interrupt menu opens Share this post Link to post Share on other sites
Larrow 2820 Posted May 17, 2022 16 hours ago, pliskin124 said: I am trying to create a script that will disable a players Escape button options while they are serving jail time for friendly fire, then re-enable it once the cell door opens. This is to prevent them just respawning and circumventing their punishment. What are your current respawn settings? Depending on this will determine if any of the following settings are available. respawnButton setPlayerRespawnTime Share this post Link to post Share on other sites
pliskin124 4 Posted May 17, 2022 Figured it out. Full script for anyone interested in a friendly fire script. Credit to pierremgi for assisting in DM's! Create a ME Guard House from CUP with the jail cell, name it Jail 1, create an invisible helper object in the cell name it Cell1 Trigger Condition: (rating player) < -1000 On Activation: nul = ExecVM "FriendlyFire.sqf"; titleText ["Court Martial!","BLACK OUT",3]; player setPos (getPos Cell1); player setVariable ["inJail", true]; [] spawn { waitUntil {!isNull findDisplay 46}; findDisplay 46 displayAddEventHandler ["keyDown",{ params ["_ctrl","_key"]; if (!(player getVariable ["inJail",TRUE])) then {findDisplay 46 displayRemoveEventHandler ["keyDown",_thisEventHandler]}; private _h = false; if (_key == 1) then {_h = true}; _h }] }; Jail1 animate ["door_2_rot",0]; removeAllWeapons player; removeAllItems player; removeAllAssignedItems player; removeVest player; removeBackpack player; removeHeadgear player; removeGoggles player; removeUniform player; player forceAddUniform "U_C_WorkerCoveralls"; titleText ["You must serve 2 minutes in jail","BLACK IN",4]; sleep 120; player setVariable ["inJail", false]; titleText ["Jail Time Served","WHITE IN",4]; Jail1 animate ["door_2_rot",1]; player addRating 2000; Share this post Link to post Share on other sites