Jump to content

Recommended Posts

Original post:
"Is there any way to make backpacks accessable only when they are on ground or by other players using 'Open Backpack' action? The goal is to make player drop the backpack to get access in its inventory and so make them more realistic."

UPDATE 15th Sept. -18:

An addon version made!
Script provided by @pierremgi

PBO provided by @HazJ
Download: https://hazjohnson.com/ArmA/@realisticBackpacks.zip

  • Addon is now signed with key and bikey.
     
  • Like 3

Share this post


Link to post
Share on other sites

Should be doable, take a look into InventoryOpened event . it should allow overriding the opening of backpack.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Yes. You will also need to disable certain controls for backpack click in the Inventory UI as well.

Share this post


Link to post
Share on other sites

Just to throw some fuel on, how about keeping any ammo in a player's backpack out of their ammo pool?

  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, Harzach said:

Just to throw some fuel on, how about keeping any ammo in a player's backpack out of their ammo pool?

A good idea but what about items, etc...?

  • Like 1

Share this post


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

A good idea but what about items, etc...?

Well, ultimately it should be everything, but configurable - for example, soldiers would likely be using a remote handset for their radio.

Share this post


Link to post
Share on other sites

It isn't perfect but it is a good start.

https://hazjohnson.com/ArmA/backpackContents.VR.zip

player setVariable ["backpackContents", [], true];
player action ["Gear", player];
player addEventHandler ["InventoryClosed",
{
	params ["_unit", "_container"];
	systemChat format [":: Backpack contents :: %1", backpackItems _unit]; // debugging
	if (unitBackpack _unit isEqualTo "") exitWith
	{
		player setVariable ["backpackContents", [], true];
	};
	player setVariable ["backpackContents", +(backpackItems _unit), true];
	{
		_unit removeItemFromBackpack _x;
	} forEach backpackItems _unit;
	systemChat format [":: Backpack contents :: %1", player getVariable "backpackContents"]; // debugging
}];
player addEventHandler ["InventoryOpened",
{
	params ["_unit", "_container"];
	// no need for canAddItemToBackpack as if added in first place there should be room
	// you will need edit EH or add another for when another player adds / removes something from your backpack
	{
		_unit addItemToBackpack _x;
	} forEach (player getVariable "backpackContents");
}];

 

  • Like 5

Share this post


Link to post
Share on other sites

Wow! That was fast! Nice! Also very nice idea from @Harzach. As he suggested all items that are in the backpack should stay untouched if the backpack is on someones back and only way to use the items would be moving them to uniform or vest by dropping the backpack and taking them out or with other players help.

Share this post


Link to post
Share on other sites

Still a couple of things to do as I mentioned above. I am assuming you are new to scripting? When and if I get chance, I'll make the additional changes.

Share this post


Link to post
Share on other sites

@HazJ Yes im pretty new to scripting and im still figuring shit out. Also i tested the script on one of my missionfiles but it didnt work correctly.

Share this post


Link to post
Share on other sites

@FLying-FINN

Did you test it in the demo mission? You may not work right out of the box when moving. Either that, or you did it wrong.

player action ["Gear", player];

This starts everything off. I should of made it close the gear again right after but just did this for quick test. When I get around to it, I'll finish it all off.

Share this post


Link to post
Share on other sites

@FLying-FINN

Hmm. Odd. Did you copy it all correctly? I have it in initPlayerLocal.sqf though init.sqf should be fine too - See example mission DL above.

Share this post


Link to post
Share on other sites

Hey dudes!

I was looking for something along this lines.

@HazJ , tried your code / mission and it works as it is and as an init.sqf in a made up test scenario, removing the debugging lines and the open inventory at mission start.

 

21 hours ago, HazJ said:

Still a couple of things to do as I mentioned above.

 

I found these so far:

- When moving not full magazines in the backpack and closing the inventory said mags refill.

- When moving weapons with attachments in the backpack and closing the inventory said weapon lose all attachments and magazine.

- Content in the backpack becomes visible when moving something from/to inventory.

- A.I. can't access the content of player's backpack and said content will be lost if you move stuff in (depending how much though)

 

Anyway...just wanna say that the code works.

Bye!

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the list. I was aware of general issues coming up. I wasn't planning on writing it all, only something to get started on. However, seeing as most of you seem interested. When I get chance, I will finish it up. Can't promise any ETA though.

  • Like 1

Share this post


Link to post
Share on other sites

 

I wrote the following script, disabling the view of backpack content and preventing any add of item inside it (for the player himself). This doesn't lock the backpack for others (subject treated in other topic).

The only remaining issue so far is when you drag an item an drop it outside of the inventory display >> backpack is filled up to max with chemlight. If you close/reopen the inventory, the situation is back to normal.

 

So, the code:


 

player addEventHandler ["InventoryOpened", {  
  [] spawn {  
    waitUntil {!(isNull findDisplay 602)};
    
    {(findDisplay 602 displayCtrl _x) ctrlAddEventHandler ["lbdrag", {
      if (backpack player != "") then {
        player setVariable ['bpkMess',if (count backpackItems player >0) then {+(getUnitLoadout player) select 5 select 1} else {[]}];
        for '_i' from 0 to 100 do {
          if !(player canAddItemToBackpack ["Chemlight_yellow", _i]) exitWith {
            player setVariable ["fillBag",_i-1];
            (backpackContainer player) additemCargo (["Chemlight_yellow", _i-1])
          };
        };
      }
    }];
    } forEach [632,633,638,640];
    {
      _x ctrlAddEventHandler ["lbDrop", {
        if (!isNil {player getVariable "bpkMess"}) then {
          clearAllItemsFromBackpack player;
          {
            if (count _x == 3) then {
              (backpackContainer player) AddMagazineAmmoCargo _x
            } else {
              (backpackContainer player) additemCargoGlobal _x
            }
          } forEach (player getVariable ["bpkMess",[]]);
          player setVariable ["bpkMess",nil];
          player setVariable ["fillBag",nil]
      }
      }]
    } forEach (allControls findDisplay 602);

    (findDisplay 602 displayCtrl 6191) ctrlAddEventHandler ["MouseButtonClick", {
      if ((_this select 1) == 0) then {
        (findDisplay 602 displayCtrl 619) ctrlShow false}
    }];
    (findDisplay 602 displayCtrl 6191) ctrlAddEventHandler ["MouseButtonDblClick", {
      if ((_this select 1) == 0) then {
      (findDisplay 602 displayCtrl 619) ctrlShow false}
    }];

    {(findDisplay 602 displayCtrl _x) ctrlAddEventHandler ["MouseButtonClick", {
      if (backpack player != "" && (_this select 1) == 1) then {

        player setVariable ["bpkMess",if (count backpackItems player >0) then {+(getUnitLoadout player) select 5 select 1} else {[]}];
        for "_i" from 0 to 100 do {
          if !(player canAddItemToBackpack ["Chemlight_yellow", _i]) exitWith {
            player setVariable ["fillBag",_i-1];
            (backpackContainer player) additemCargo (["Chemlight_yellow", _i-1])
          };
        };
      }
    }];
    } forEach [632,640];
  };  
}];

player addEventHandler ["InventoryClosed", {
  if (!isNil {player getvariable "bpkMess"} && backpack player != "") then {
    for "_i" from 1 to (player getVariable ["fillBag",0]) do {
      player removeItemFromBackpack "Chemlight_yellow";
      };
      player setVariable ["bpkMess",nil];
      player setVariable ["fillBag",nil]
    };
}];

 

Thanks for feedback. Not sure I can do better.

Imho, there are some missing simple commands for controls, like "ctrlLock" (then it goes red and disabled) or even "ctrlClassObject" returning the class name of the selected object.

I tried with ctData, ctText, ctValue,.. ctrlEnable, ctrlSetBackGroundColor...

If someone more skilled could implement something smarter than temporary filling the backpack with chemlights, you're welcome.

 

  • Like 3
  • Thanks 2

Share this post


Link to post
Share on other sites

I've been wanting this since ArmA 3 came out. ArmA 2 style backpacks!! Just want to follow this thread. 

  • Like 1

Share this post


Link to post
Share on other sites

Yeah I always found it highly unrealistic backpack ammo is counted in the ammo pool.

 

great idea

Share this post


Link to post
Share on other sites
16 hours ago, Crielaard said:

Yeah I always found it highly unrealistic backpack ammo is counted in the ammo pool.

 

great idea

You're right somewhere! The problem is how/when the backpack content can be accessed.

I explain. In my script, you can't access to backpack in inventory but if you are using your weapons, all the mags, backpack included, are available. That's not realistic.

The only workaround is to empty the backpack . That helps with the backpack inventory (empty!) but... you need to recover the backpack content when you drop it, what ever the container/ground could be.

 

I'm still working on that.

  • Like 2

Share this post


Link to post
Share on other sites

I still plan to finish my version as well. Just been busy this weekend.

 

EDIT: Never mind. Just saw @pierremgi's version above so he can take over with his version. No point both doing the same thing.

Share this post


Link to post
Share on other sites

Would it be possible, technically speaking, to make a module for ACE that removes the backpack entirely from your inventory? Like you don't get any option to use the items inside of it, they don't count in your mag count and you have to drop it to access gear? I'm just curious if anyone here would know since you're fairly knowledgeable when it comes to the quirks of ArmA. 

Share this post


Link to post
Share on other sites
1 hour ago, Spatsiba said:

Would it be possible, technically speaking, to make a module for ACE that removes the backpack entirely from your inventory? Like you don't get any option to use the items inside of it, they don't count in your mag count and you have to drop it to access gear? I'm just curious if anyone here would know since you're fairly knowledgeable when it comes to the quirks of ArmA. 

I don't think so. You need to keep a backpack, even emtied, because you want to drop it somewhere (in a crate or on ground), just to manage its content.

Now, the difficulty is to display its content when editor is opened and this backpack is not on your back... and manage all possibilities, for example when you change for some other backpack.

Fiu ! (boring) as we say at Tahiti.

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

I don't think so. You need to keep a backpack, even emtied, because you want to drop it somewhere (in a crate or on ground), just to manage its content.

Now, the difficulty is to display its content when editor is opened and this backpack is not on your back... and manage all possibilities, for example when you change for some other backpack.

Fiu ! (boring) as we say at Tahiti.

So, it wouldn't be possible to edit the gear menu to remove the backpack itself and add an ace interaction to drop/pickup/open bags? Then find a way to not count the mags etc if they're in your bag. I'm thinking engine limitations rather than how boring it sounds. Because it sounds like some really boring work. 

Share this post


Link to post
Share on other sites

I'm not fond of ACE. Perhaps someone will answer about this specific point.

  • Like 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

×