beno_83au 1369 Posted June 24, 2017 Hi, I'm trying to prevent players from force respawning when waiting for a revive (using the vanilla revive). To do this I'm trying to stop them from using the enter key or middle mouse button. I can stop the enter button, but the middle mouse button is eluding me. This is the code I'm using: _idKey = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == 28) then {true}"]; _idMouse = (findDisplay 46) displayAddEventHandler ["MouseButtonDown","if ((_this select 1) == 2) then {true}"]; Now, in testing I got a return (_this select 1) of 28 and 2 for "KeyDown" and "MouseButtonDown" respectively, but when I apply that to the EH as I have done above, only the enter key is stopped. How do I stop a player using their middle mouse button (without disabling user input)? Edit: Worked it out, relevant post/s are below but here is the solution (big credit to Larrow for a step in the right direction): #include "\a3\functions_f_mp_mark\revive\defines.inc" nul = [player] spawn { params ["_unit"]; while {true} do { private ["_actionID"]; waitUntil {lifeState _unit == "INCAPACITATED"}; _actionID = _unit getVariable [VAR_ACTION_ID_RESPAWN,-1]; [_unit,_actionID] call bis_fnc_holdActionRemove; {SET_FORCING_RESPAWN(_unit,false)}; }; }; Add this to the initPlayerLocal.sqf and the option to force respawn will not be present for an incapacitated player. Or, better yet, use this updated code from Larrow: player addEventHandler["Dammaged",{ params ["_unit", "", "_damage","","_hitPoint","_source"]; if ( alive _unit && { _damage >= 1 && { _unit getVariable ["#rev_enabled", false] && { _hitPoint == "Incapacitated" && { _unit getVariable ["#rev_state", 0] isEqualTo 2 } } } } ) then { if ( vehicle _unit isEqualTo _unit ) then { _nul = [ _unit ] spawn { params[ "_unit" ]; waitUntil{ !( _unit getVariable [ "#rev_actionID_respawn", -1 ] isEqualTo -1 ) }; _actionID = _unit getVariable [ "#rev_actionID_respawn", -1 ]; [ _unit, _actionID ] call BIS_fnc_holdActionRemove; ["",false,_unit] call BIS_fnc_reviveOnForcingRespawn; _unit setVariable ["#revF", false, true]; waitUntil{ !( lifeState _unit == "Incapacitated" ) }; _unit setVariable [ "#rev_actionID_respawn", -1 ]; }; }; }; }]; Share this post Link to post Share on other sites
das attorney 858 Posted June 24, 2017 I had problems disabling that as well. Have you tried disabling the control on the dialog? (Might be worth trying as a workaround). Share this post Link to post Share on other sites
beno_83au 1369 Posted June 25, 2017 @das attorney It may be me, but I cannot get anywhere with this. I tried using ctrlShow and ctrlEnable with IDCs from all displays that were active but I didn't get anywhere with it. Example: nul = [] spawn { private ["_arr"]; disableSerialization; _arr = []; {_arr pushBack (ctrlIDC _x)} forEach (allControls findDisplay 46); //ran through all the returns I was getting from allDisplays copyToClipboard str _arr; {ctrlShow [_x,false]} forEach _arr; {ctrlEnable [_x,false]} forEach _arr; }; I also tried to see if I got a "true" return from running dialog when the force respawn option was on screen but never did. Did you ever get anywhere with a workaround? I feel like I'm clutching at straws in the dark here lol. Share this post Link to post Share on other sites
bad benson 1733 Posted June 25, 2017 try the alternative syntax for ctrlEnable and ctrlShow. as in _ctrl ctrlEnable false; maybe accessing it through the control itself rather than the idc will help. not all controls have an idc. i think i recently used both and they worked just fine. not saying your solution will be that simple but you never know. Share this post Link to post Share on other sites
beno_83au 1369 Posted June 25, 2017 3 minutes ago, bad benson said: try the alternative syntax for ctrlEnable and ctrlShow. I'll give it a go. At the moment if I just use sleep in the displayAddEventHandler code it crashes the script (as expected) and stops the process. Not a good workaround by a long shot though. Share this post Link to post Share on other sites
bad benson 1733 Posted June 25, 2017 yea. you should definately go find the idd of the respawn dialog in the configs. unpack ui_f.pbo for that. i'll take a look later myself. gotta go in a sec though. 1 Share this post Link to post Share on other sites
beno_83au 1369 Posted June 25, 2017 Cheers for the point in the right direction. In my tired state I've been looking through any of the pbo's that I thought might hold an answer but with no luck. I'll narrow the search now!! Share this post Link to post Share on other sites
beno_83au 1369 Posted June 25, 2017 4 minutes ago, bad benson said: respawn dialog Plus, it's the revive/incapacitated dialog I'm after, and so I didn't think it'd be in the respawn dialog, so I've been looking more specifically at anything revive related and avoiding respawn (if that makes a difference). Share this post Link to post Share on other sites
bad benson 1733 Posted June 25, 2017 11 minutes ago, beno_83au said: Plus, it's the revive/incapacitated dialog I'm after, and so I didn't think it'd be in the respawn dialog, so I've been looking more specifically at anything revive related and avoiding respawn (if that makes a difference). oh. just bad reading on my part then. 2 Share this post Link to post Share on other sites
beno_83au 1369 Posted June 25, 2017 3 minutes ago, bad benson said: oh. just bad reading on my part then. ;) I wasted a decent slog browsing through respawns. Share this post Link to post Share on other sites
das attorney 858 Posted June 25, 2017 25 minutes ago, bad benson said: oh. just bad reading on my part then. Oops, I thought it was the respawn menu as well. My bad beno 1 Share this post Link to post Share on other sites
Larrow 2822 Posted June 25, 2017 On 24/06/2017 at 0:26 PM, beno_83au said: To do this I'm trying to stop them from using the enter key or middle mouse button. I can stop the enter button, but the middle mouse button is eluding me. Just remove the revives hold action rather than looking for the keys/mouse button. Untested, something like.. See revised code below Most properly not correct but should give you a good idea where to look, especially the revive defines file. Share this post Link to post Share on other sites
beno_83au 1369 Posted June 25, 2017 Beauty, I'll have look after work and see what i can do. Cheers @Larrow 1 Share this post Link to post Share on other sites
beno_83au 1369 Posted June 26, 2017 @Larrow, thanks mate!! With a little bit of fixing (a } where it shouldn't be and no { and } where they should've been) then playing around with that code, I got it (it only worked on the first time a player went incapacitated): #include "\a3\functions_f_mp_mark\revive\defines.inc" nul = [player] spawn { params ["_unit"]; while {true} do { private ["_actionID"]; waitUntil {lifeState _unit == "INCAPACITATED"}; _actionID = _unit getVariable [VAR_ACTION_ID_RESPAWN,-1]; [_unit,_actionID] call bis_fnc_holdActionRemove; {SET_FORCING_RESPAWN(_unit,false)}; }; }; Executing this in initPlayerLocal.sqf has achieved the required outcome. I'm not sure why the EH didn't pick it up a second time though so I figured a while waitUntil loop would work in it's place. @das attorney figured you'd want to have a look at this. 2 Share this post Link to post Share on other sites
das attorney 858 Posted June 27, 2017 Much obliged mate :) 1 Share this post Link to post Share on other sites
Larrow 2822 Posted June 27, 2017 12 hours ago, beno_83au said: it only worked on the first time a player went incapacitated Seems the force respawn holdAction flag is not reset on a player once they are revived/die. Revised code and made sure EH worked, put through some limited testing ( mainly non define version as I was testing from debug console in a 2 player dedicated MP environment, but define version should be good as well). Define version is likely the best to use just in case BI decided to change any of the variable names. Then the macros should still reference the correct variables. Define version Spoiler #include "\a3\functions_f_mp_mark\revive\defines.inc" player addEventHandler["Dammaged",{ params ["_unit", "", "_damage","","_hitPoint","_source"]; if ( alive _unit && { _damage >= 1 && { REVIVE_ENABLED(_unit) && { _hitPoint == "Incapacitated" && { IS_DISABLED(_unit) } } } } ) then { _nul = [ _unit ] spawn { params[ "_unit" ]; waitUntil{ !( _unit getVariable [ VAR_ACTION_ID_RESPAWN, -1 ] isEqualTo -1 ) }; _actionID = _unit getVariable [ VAR_ACTION_ID_RESPAWN, -1 ]; [ _unit, _actionID ] call bis_fnc_holdActionRemove; SET_FORCING_RESPAWN( _unit, false ); waitUntil{ !( lifeState _unit == "Incapacitated" ) }; _unit setVariable [ "#rev_actionID_respawn", -1 ]; }; }; }]; Non define version Spoiler player addEventHandler["Dammaged",{ params ["_unit", "", "_damage","","_hitPoint","_source"]; if ( alive _unit && { _damage >= 1 && { _unit getVariable ["#rev_enabled", false] && { _hitPoint == "Incapacitated" && { _unit getVariable ["#rev_state", 0] isEqualTo 2 } } } } ) then { if ( vehicle _unit isEqualTo _unit ) then { _nul = [ _unit ] spawn { params[ "_unit" ]; waitUntil{ !( _unit getVariable [ "#rev_actionID_respawn", -1 ] isEqualTo -1 ) }; _actionID = _unit getVariable [ "#rev_actionID_respawn", -1 ]; [ _unit, _actionID ] call BIS_fnc_holdActionRemove; ["",false,_unit] call BIS_fnc_reviveOnForcingRespawn; _unit setVariable ["#revF", false, true]; waitUntil{ !( lifeState _unit == "Incapacitated" ) }; _unit setVariable [ "#rev_actionID_respawn", -1 ]; }; }; }; }]; 3 Share this post Link to post Share on other sites
beno_83au 1369 Posted June 27, 2017 10 minutes ago, Larrow said: Revised code and made sure EH worked Even better. I just ran it (non-define version) through a quick 2 player editor MP test and there didn't appear to be any problems. I'll edit the OP with this. 1 Share this post Link to post Share on other sites
LSValmont 789 Posted November 13, 2018 On 26/6/2017 at 8:30 PM, Larrow said: Seems the force respawn holdAction flag is not reset on a player once they are revived/die. Revised code and made sure EH worked, put through some limited testing ( mainly non define version as I was testing from debug console in a 2 player dedicated MP environment, but define version should be good as well). Define version is likely the best to use just in case BI decided to change any of the variable names. Then the macros should still reference the correct variables. Hide contents player addEventHandler["Dammaged",{ params ["_unit", "", "_damage","","_hitPoint","_source"]; if ( alive _unit && { _damage >= 1 && { _unit getVariable ["#rev_enabled", false] && { _hitPoint == "Incapacitated" && { _unit getVariable ["#rev_state", 0] isEqualTo 2 } } } } ) then { if ( vehicle _unit isEqualTo _unit ) then { _nul = [ _unit ] spawn { params[ "_unit" ]; waitUntil{ !( _unit getVariable [ "#rev_actionID_respawn", -1 ] isEqualTo -1 ) }; _actionID = _unit getVariable [ "#rev_actionID_respawn", -1 ]; [ _unit, _actionID ] call BIS_fnc_holdActionRemove; ["",false,_unit] call BIS_fnc_reviveOnForcingRespawn; _unit setVariable ["#revF", false, true]; waitUntil{ !( lifeState _unit == "Incapacitated" ) }; _unit setVariable [ "#rev_actionID_respawn", -1 ]; }; }; }; }]; Dear Larrow, how can I actually do the opposite and make the forceRespawn holdAction to appear if _damage >= 0.91? Thanks in advanced! Share this post Link to post Share on other sites