slothstronaut 10 Posted June 19, 2016 I'd like to block players from opening a crate that another player is currently accessing. I had thought to set a variable on the container (inUse or something) on the ContainerOpened event, which was reset on ContainerClosed, then have anyone attempting to open the container check against that variable. The logic, I think, is sound. I just don't know how to prevent bringing up the container dialog. Any assistance would be fantastic! Share this post Link to post Share on other sites
killzone_kid 1326 Posted June 19, 2016 https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#InventoryOpened Share this post Link to post Share on other sites
serena 150 Posted June 19, 2016 Fn_IsRestrictedBoxForPlayerAccess = { // implement this function to return true if player restricted to access given box, otherwise false params ["_unt", "_box"]; false}; player addEventHandler ["InventoryOpened", Fn_IsRestrictedBoxForPlayerAccess]; UPD: Fixed handler code Share this post Link to post Share on other sites
serena 150 Posted June 19, 2016 For example: player setVariable ["AccessLevel", 1]; box001 setVariable ["AccessLevel", 0]; // accessible by player box002 setVariable ["AccessLevel", 1]; // accessible by player box003 setVariable ["AccessLevel", 2]; // not accessible by player Fn_IsRestrictedBoxForPlayerAccess = { params ["_unt", "_box"]; _unt getVariable ["AccessLevel", 0] < _box getVariable ["AccessLevel", 0]}; 1 Share this post Link to post Share on other sites
killzone_kid 1326 Posted June 19, 2016 Fn_IsRestrictedBoxForPlayerAccess = { // implement this function to return true if player restricted to access given box, otherwise false params ["_unt", "_box"]; false}; player addEventHandler ["InventoryOpened", { if (_this call Fn_IsRestrictedBoxForPlayerAccess) then { _this spawn { waitUntil {not isNull (findDisplay 602)}; (findDisplay 602) closeDisplay 2}}}]; closeDisplay? I know there are many ways to make life difficult in Arma, but why not make life easy and return true to override the opening? 1 Share this post Link to post Share on other sites
serena 150 Posted June 19, 2016 closeDisplay? I know there are many ways to make life difficult in Arma, but why not make life easy and return true to override the opening? Then just: player addEventHandler ["InventoryOpened", Fn_IsRestrictedBoxForPlayerAccess]; Share this post Link to post Share on other sites
slothstronaut 10 Posted June 19, 2016 Thanks for the code example serena and the documentation link killzone_kid! The example you've given is close to what I have now but on ContainerOpened. I am guessing that doesn't make sense as the event is for the container, not the player, whereas the opposite is true for InventoryOpened. I'll adjust my script today and see how I go. Share this post Link to post Share on other sites