Jump to content
diwako

[Release] Lock backpack (ACE Compatible)

Recommended Posts

General

Adds the ability to players to lock their backpacks. CBA is required and this script has support for ACE interaction menu and ACE medical.

 

https://i.imgur.com/tlF8zXS.png

 

Features

Locks carried backpack for anyone that is not the carrier.
Backpack lock is removed once the backpack is dropped.
(ACE medical only) Others can open the backpack if the carrier is knocked out.

 

Requirements

The only additional requirement is CBA for this script to work properly.

 

Installation and configuration

This is a mission script, you need to implement it into your mission. First copy paste the scripts folder into your mission then implement the missing additions in your description.ext. That is it.
The included mission is just an example!

 

License

Copyright 2018 diwako

This work (diwako_lockbackpack or the like) uses the license Arma Public License Share Alike (APL-SA)

https://www.bohemia.net/community/licenses/arma-public-license-share-alike

 

Download

https://github.com/diwako/lockBackpack/releases/

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Why the CBA requirement for vanilla? Something like can be done very easily using an event handler. Thanks for sharing with the community. Good work.

  • Like 2

Share this post


Link to post
Share on other sites
7 hours ago, HazJ said:

Why the CBA requirement for vanilla? Something like can be done very easily using an event handler. Thanks for sharing with the community. Good work.

I intended this for a pull request for ACE originally. Until I found some older question topic on GitHub which made it look like that such a feature is not wanted as it was originally in AGM and has been replaced with the zip sound when someone else opens your backpack.

Hence why this script uses CBA extended eventhandlers and CBA specific events for changes in the players inventory to remove the lock once the unit drops the backpack. In the end I do play with ACE, so I just made CBA a requirement.

Share this post


Link to post
Share on other sites
1 minute ago, diwako said:

I intended this for a pull request for ACE originally. Until I found some older question topic on GitHub which made it look like that such a feature is not wanted as it was originally in AGM and has been replaced with the zip sound when someone else opens your backpack.

Hence why this script uses CBA extended eventhandlers and CBA specific events for changes in the players inventory to remove the lock once the unit drops the backpack. In the end I do play with ACE, so I just made CBA a requirement.

I looked over it very quickly on your GitHub. Why all that instead of an simple EH with conditions? Does it do something else/more that I am missing?

Share this post


Link to post
Share on other sites
4 minutes ago, HazJ said:

I looked over it very quickly on your GitHub. Why all that instead of an simple EH with conditions? Does it do something else/more that I am missing?

In terms of the Inventory Open EH the only difference that I am seeing is that the Extended EH applies to all units and the vanilla to only the one you assign it to. They seem the same otherwise.

For the EH part, yes it can be replaced with the vanilla EH, it might just not work on remote controlled units then. All that remains is the code part which removes the lock on backpack drop. Mostly can be handles with inventory closed EH easily, unless in special cases the backpack gets removed without opening and closes your inventory. E.G. scripts and small menus such as the ACE interaction one which you can access on a captive or knocked out unit. But then this is just for resetting the flag on the player that they wish that no one opens their backpack.

  • Like 1

Share this post


Link to post
Share on other sites
18 minutes ago, diwako said:

In terms of the Inventory Open EH the only difference that I am seeing is that the Extended EH applies to all units and the vanilla to only the one you assign it to. They seem the same otherwise.

For the EH part, yes it can be replaced with the vanilla EH, it might just not work on remote controlled units then. All that remains is the code part which removes the lock on backpack drop. Mostly can be handles with inventory closed EH easily, unless in special cases the backpack gets removed without opening and closes your inventory. E.G. scripts and small menus such as the ACE interaction one which you can access on a captive or knocked out unit. But then this is just for resetting the flag on the player that they wish that no one opens their backpack.

Isn't the lock is virtual and attached to the player and not the backpack? I guess you didn't it some other way. Anyway, good work. Suggestion: I think it will be more beneficial if you made it into it's own addon. It would also make sense as the way you coded it.

Share this post


Link to post
Share on other sites
11 minutes ago, HazJ said:

Isn't the lock is virtual and attached to the player and not the backpack? I guess you didn't it some other way. Anyway, good work. Suggestion: I think it will be more beneficial if you made it into it's own addon. It would also make sense as the way you coded it.

Heh, it is kinda funny, all my addons start like some small mission script and then I just pack them into an addon after a few weeks.

  • Like 1

Share this post


Link to post
Share on other sites
28 minutes ago, TheBigOne_014 said:

@diwako are you going to put this on Steam workshop!?

At some point, yes I just need to make some fitting icons for the ace interaction and then I just pack it up. Currently at low priority as I am working hard on some missions for my group.

  • Like 1

Share this post


Link to post
Share on other sites

Here is a little code for those you want something for vanilla ARMA (no mod required, JIP compatible):

 

in init.sqf:


 

if (isServer) then {bpkList = []; publicVariable "bpkList"};
MGI_lock_action = {
  player addAction ["<t color='#00ff00'>lock backpack</t>", {
    params ["_plyr","","_id"];
    call {
      if (isNil {_plyr getVariable "lockedBpk"}) exitWith {
        _plyr setVariable ["lockedBpk",true,true];
        _bpk = backpackContainer _plyr;
        bpkList pushBack _bpk;
        publicVariable "bpkList";
        _plyr setUserActionText [_id, "<t color='#ff0000'>unlock backpack</t>"];
        hintSilent "backpack is locked";
      };
      if (!isNil {_plyr getVariable "lockedBpk"}) exitWith {
        _plyr setVariable ["lockedBpk",nil,true];
        _plyr setUserActionText [_id, "<t color='#00ff00'>lock backpack</t>"];
        hintSilent "backpack is unlocked";
        _bpk = backpackContainer _plyr;
        bpkList = bpkList -[_bpk];
        publicVariable "bpkList";
      };
    };
  }]
};
waituntil {!isNull player};
call MGI_lock_action;
player addEventHandler ["respawn",{call MGI_lock_action}];
0 = [] spawn {
  while {true} do {
    {
      _x setVariable ["JIPtreated",true];
      _x addEventHandler ["InventoryOpened", {
        params ["_unit","_container"];
        if (_container in bpkList) then {
          [] spawn {
            waitUntil {!(isNull findDisplay 602)};
            findDisplay 602 closeDisplay 1;
          }
        }  
      }]
    } forEach (allPlayers select {isnil {_x getVariable "JIPtreated"}});
    sleep 2;
  }
};

This doesn't lock the backpack for the owner. This feature is treated in an other post.

Have fun.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
17 hours ago, pierremgi said:

This feature is treated in an other post.

 

Thank you very much Pierre !

 

Have you open a topic for this?

If yes , i would like to add your link in my topic:

Thanks !

Share this post


Link to post
Share on other sites
6 hours ago, GEORGE FLOROS GR said:

 

Thank you very much Pierre !

 

Have you open a topic for this?

If yes , i would like to add your link in my topic:

Thanks !

No, sorry, I didn't remember this topic. You're right,It's certainly a better place; I don't know if my solution is ACE compatible. Probably not due to addAction menu. To be continued in your topic.

 

By the way, I was focused on JIP from init.sqf but it's possible to avoid the loop while true, placing the code

in initPlayerLocal.sqf:
 

MGI_lock_action = {
  player addAction ["<t color='#00ff00'>lock backpack</t>", {
  params ["_plyr","","_id"];
  call {
    if (isNil {_plyr getVariable "lockedBpk"}) exitWith {
      _plyr setVariable ["lockedBpk",true,true];
      _bpk = backpackContainer _plyr;
      bpkList pushBack _bpk;
      publicVariable "bpkList";
      _plyr setUserActionText [_id, "<t color='#ff0000'>unlock backpack</t>"];
      hintSilent "backpack is locked"; };
    if (!isNil {_plyr getVariable "lockedBpk"}) exitWith {
      _plyr setVariable ["lockedBpk",nil,true];
      _plyr setUserActionText [_id, "<t color='#00ff00'>lock backpack</t>"];
      hintSilent "backpack is unlocked";
      _bpk = backpackContainer _plyr;
      bpkList = bpkList -[_bpk];
      publicVariable "bpkList";
    };
  };
  }]
};
call MGI_lock_action;
player addEventHandler ["respawn",{call MGI_lock_action}];
player addEventHandler ["InventoryOpened", {
  params ["_unit","_container"];
  if (_container in bpkList) then {
    [] spawn { 
      waitUntil {!(isNull findDisplay 602)};
      findDisplay 602 closeDisplay 1;
    }
  }
}];

 

and in initserver.sqf:
 

bpkList = [];
publicVariable "bpkList";

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×