Jump to content

Recommended Posts

                                                                                WEAR WHAT YOU WANT

 

Hi all,

Fed up with the cloth restriction? You can kill civilians but not wear their clothes! You want to infiltrate enemy player places but you can't wear their uniforms.

You can't count the threads about forceAddUniform with any interest in game, except for some specific action...

 

If you want to wear what you find on corpses, crates, or ground..

just add the following code for each allowed players (initPlayerLocal.sqf seems great).

Just make sure player is already defined.

 

version Mar 13th 2018 updated 21/06/18

UPDATED: new version 20/12/2019

Corrected 25/06/2020 on Larry0503 feedback for uniforms with multiple classes (present in all sides)

 

parameters:   NONE


 

fnc_otherUnif = {  
  params ["_type","_return"];  
  if (_type == 0) exitWith {  
    MGI_button = _return #1; false  
  };  
  if (_type == 1 and !isnil "MGI_button" && {MGI_button == 1}) then {  
    disableSerialization;  
    _control = _return select 0;  
    _index = _return select 1;  
    private _idc = ctrlIDC _control;  
    private _text = lbText [_idc, _index];  
    private _picture = lbPicture [_idc,_index];  
    private _uniforms = ("getText (_x >> 'displayName') == _text && getNumber (_x >> 'ItemInfo' >> 'type') == 801" configClasses (configFile >> "CfgWeapons")); 
 
    if (_uniforms isEqualType [] && {!(_uniforms isEqualTo [])}) then {  
      [_idc,_text,_picture,_index,_uniforms] spawn {  
        params ["_idc","_text","_picture","_index","_uniforms",["_selectedUnif",""],"_unifConts",["_uniformObject",objNull],"_otherItems","_g0"];  
        private _currentUnif = uniform player;  
        private _currentInvent = uniformItems player;  
        _currentInvent = (_currentInvent arrayIntersect _currentInvent) apply {private _v= _x;[_x]+[{_v isEqualTo _x} count _currentInvent]}; 
        private _selectedUnif = ((_uniforms select {toLower (gettext (_x >> "picture")) splitString "\"joinString "\" == _picture}) apply {configName _x}); 
        if (_selectedUnif isEqualTo []) exitWith {};
  
        if !(pl_container isKindOf "CAManBase") then {  
          _unifConts = (everyContainer pl_container select {getNumber (configFile >> "CfgWeapons" >> _x #0 >> 'ItemInfo' >> 'type') == 801});
          _uniformObject = objNull;
          private ["_cnt","_selectedCfg"];
          scopeName "main";
          for "_i" from 0 to count _selectedUnif -1 do {
            _cnt = 0;
            _selectedCfg = _selectedUnif #_i; 
            for "_j" from 0 to _index do {  
              if (lbText [_idc,_j] == _text) then {  
                _cnt = _cnt +1;
                _uniformObject = _unifConts select {_selectedCfg == (_x #0)} select (_cnt -1) select 1;
                if (!isnil "_uniformObject" && {!isNull _uniformObject}) then {
                  _selectedUnif = _selectedCfg;
                  breakTo "main"
                };
              };
            };
            _uniformObject = objNull;
          };  
        } else {
          _selectedUnif = _selectedUnif #0;  
          _uniformObject = uniformContainer pl_container  
        }; 
 
        if (!isNull _uniformObject && !(player isUniformAllowed _selectedUnif)) then { 
           
          private _itemsAndMags = (_uniformObject call MGI_orderItsAndMgs) params ["_selectedItems","_selectedMags"]; 
           
          if !(pl_container isKindOf "CAmanbase" or isNull pl_container) then {  
            private _its = getItemCargo pl_container; 
            private _mgs = magazinesAmmoCargo pl_container; 
            private _unifItems = _unifConts apply {_x #0}; 
            private _vestConts = (everyContainer pl_container select {getNumber (configFile >> "CfgWeapons" >> _x #0 >> 'ItemInfo' >> 'type') == 701}); 
            private _vestItems = _vestConts apply {_x #0}; 
            _otherItems = +(_its #0) - _unifItems - _vestItems; 
            _otherItems = _otherItems apply {[_x,_its #1#(_its #0 find _x)]}; 
            private _conts = _unifConts + _vestConts; 
            for '_i' from 0 to count _Conts -1 do { 
              if (_conts #_i #1 == _uniformObject) exitWith { 
                _conts deleteAt _i 
              }; 
            }; 
           
            pl_container setVariable ["MGIallContForWear",[]]; 
            { 
              private _itsAndMgs = ((_x #1) call MGI_orderItsAndMgs) params ["_its","_mgs"]; 
              (pl_container getVariable "MGIallContForWear") pushBack [_x #0,_its,_mgs]; 
            } forEach _conts; 
            _g0 = pl_container; 
            clearItemCargoGlobal _g0; 
          } else { 
            _g0 = createVehicle ['WeaponHolderSimulated_Scripted', (player modelToWorld [0,1,1]), [], 0, 'CAN_COLLIDE'] 
          }; 
 
          player forceAddUniform _selectedUnif;  
          private _unif = uniformContainer player; 
          {_unif addItemCargoGlobal [_x#0,_x#1]} count _selectedItems; 
          {_unif addMagazineAmmoCargo [_x#0,_x#2,_x#1]} count _selectedMags;  
          call {  
            if (pl_container isKindOf "CAManBase") exitWith {  
              removeUniform pl_container  
            };  
            {  
              _x params ["_cont",["_it",[]],["_mag",[]]];  
              pl_container addItemCargoGlobal [_cont,1];  
              private _createdCont = pl_container call MGI_lastCont; 
              {_createdCont addItemCargoGlobal [_x#0,_x#1]} count _it; 
              {_createdCont addMagazineAmmoCargo [_x#0,_x#2,_x#1]} count _mag;  
            } forEach (pl_container getVariable "MGIallContForWear"); 
            {_g0 addItemCargoGlobal [_x #0,_x #1]} forEach _otherItems;  
          };  
           
          _g0 addItemCargoGlobal [_currentUnif,1]; 
          _lastCont = _g0 call MGI_lastCont;  
          {_lastCont addItemCargoGlobal [_x #0,_x #1]} forEach _currentInvent;  
          if (_g0 isKindOf "WeaponHolderSimulated" && {(count itemCargo _g0 + count magazineCargo _g0 + count weaponCargo _g0 + count backpackCargo _g0) == 0}) then {  
            deleteVehicle _g0  
          };  
        };  
      }; 
    };  
  MGI_button = 0; false  
  };  
}; 
 
MGI_orderItsAndMgs = compileFinal " 
  params [['_uniformObject', objNull,[objNull]]]; 
  private _items = getItemCargo _uniformObject; 
  private _mags = magazinesAmmoCargo _uniformObject; 
  private _selectedItems = (_items #0) apply {[_x,_items #1#(_items #0 find _x)]}; 
  private _selectedMags = (_mags arrayintersect _mags) apply {private _v= _x;_x+[{_v isEqualTo _x} count _mags]}; 
  [_selectedItems,_selectedMags]; 
"; 
 
MGI_lastCont = compileFinal "  
  params [['_cont',objNull]];  
  private '_lastCont';  
   _invent = (everyContainer _cont - (everyBackpack _cont apply {[typeOf _x,_x]}));  
   if !(_invent isEqualTo []) then {  
    _lastCont = _invent select (count _invent -1) select 1;  
   } else {  
    _lastCont = _cont;  
   };  
   _lastCont  
";  
  
player addEventHandler ["InventoryOpened", {  
  params ["_unit", "_container"];  
  pl_container = _container;  
  [] spawn {  
    waitUntil {!(isNull findDisplay 602)};  
    disableSerialization;  
    {(findDisplay 602 displayCtrl _x) ctrlAddEventHandler ["MouseButtonClick", "[0,_this] call fnc_otherUnif"]} forEach [632,640];  
    {(findDisplay 602 displayCtrl _x) ctrlAddEventHandler ["LBSelChanged", "[1,_this] spawn fnc_otherUnif"]} forEach [632,640];  
  };  
}];

 

USAGE: just right click on uniform you want to wear.

NOTE: seems a long code for forcing to wear a uniform? Just feel free to optimize without downgrading a working code on crates, corpses, or ground without multiplying gears or losing items...

 

 

 

  • Like 11
  • Thanks 7

Share this post


Link to post
Share on other sites

Very nice! Someone was asking about this the other day.

  • Like 1

Share this post


Link to post
Share on other sites

can you tell me how can i rebind the key, because people can't see the items inside the uniform, thanks!

Share this post


Link to post
Share on other sites
37 minutes ago, zagr said:

can you tell me how can i rebind the key, because people can't see the items inside the uniform, thanks!

 

There is no smart EH able to check the button (+key) and return the lb selection. I mean, if you work with list box, you don't have the button/key, if you play with key binding, you don't have the selected item in listbox, or more exactly it's a lot of work to do so.

On the other hand, when you double click on an uniform (see its content for native version) , you wear it with your stuff (if sufficient room) and have the extra items in the inventory. Nothing is lost.

Share this post


Link to post
Share on other sites

Modified!

Now, just right click to the uniform as usual. Double click stays as opening sub-inventory.

Share this post


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

Modified!

Now, just right click to the uniform as usual. Double click stays as opening sub-inventory.

thanks you man, keep up a good work!

Share this post


Link to post
Share on other sites

@pierremgi:

 

congrats to this useful script!

 

 

As an avid RAVAGE player & mission builder, I'd like to use it in missions which are to be played in MP on a dedicated server, either alone with the playable slots as recruitable Ai teammates or with a group of players that come and go into a persistent game (ATM using ALiVE persistence) What would be the best way to 

Just make sure player is already defined. 

in that environment?

 

THX in advance for helpful advice

 

tourist

Share this post


Link to post
Share on other sites

THX for the fast response!

 

You mean all I have to do is put your code into an otherwise empty initPlayerLocal.sqf?  Or do I have to define the player in any way in that file? If so, how is that done best to make your script work? 

Share this post


Link to post
Share on other sites

You just have to create an initPlayerLocal.sqf under mission root, if it doesn't already exist. This is an "event" automated script which runs at any player joining game. So, working in SP or MP, you don't have to do anything else than copy/paste the code. If this sqf exists, just add the code at the end of the file. Simple.

Share this post


Link to post
Share on other sites

True words; it was simple & I got the code to work! :f:

 

Only thing troubling me is that the double click leads to me getting the outfit I do the double click on as currently worn outfit and my previously worn outfit goes flying off my character to the ground and... doubles itself!   :scratchchin:

 

Also once I lost my previous outfit's inventory completely since it wasn't transferred into the newly lootet outfit.  I had two empty copy of my previous outfit on the ground because I had tried switching back again to my original outfit and the new outfit had just that in inventory what the dead enemy had carried.  But ofc I will test some more and make a vid so you might see if I do something wrong when using your script.

Share this post


Link to post
Share on other sites

The code is modified. Always check you have the latest version (above).

  • Like 1

Share this post


Link to post
Share on other sites

Hi ! I just want to ask if possible.

Is your script behave the same way as if I place a Civilian unit (Player) in the Editor and then place Bluefor unit. Wich I link the civilian to the bluefor.

The civilian turn to bluefor, with this trick that I found on other forum ''Ravage by Haleks'' give me the possibility to wear everything from Opfor.

Is this the same result with different methode ?

Thank you in advance.

Share this post


Link to post
Share on other sites

Sure.That does the trick. Same as changing your side. You're a BLUFOR with a native civilian side. It's just another approach, with more work in Editor (loadout, group). For example, don't forget your loadout (i guess you will not start as civilian, but with some BLUFOR loadout) is not persistent after respawn.

  • Thanks 1

Share this post


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

Sure.That does the trick. Same as changing your side. You're a BLUFOR with a native civilian side. It's just another approach, with more work in Editor (loadout, group). For example, don't forget your loadout (i guess you will not start as civilian, but with some BLUFOR loadout) is not persistent after respawn.

Do I need to worry of persistence and loadout if I play SP only. Persistence i don't get it, something to do with MP I suppose.

Thank you

Share this post


Link to post
Share on other sites
2 minutes ago, MisterOth said:

Do I need to worry of persistence and loadout if I play SP only. Persistence i don't get it, something to do with MP I suppose.

Thank you

Do you respawn in SP?

Share this post


Link to post
Share on other sites
Just now, pierremgi said:

Do you respawn in SP?

Oh yes I respawn from zero. Starting from the beginning in my mission.

Share this post


Link to post
Share on other sites
On 3/10/2018 at 1:25 AM, tourist said:

True words; it was simple & I got the code to work! :f:

 

Only thing troubling me is that the double click leads to me getting the outfit I do the double click on as currently worn outfit and my previously worn outfit goes flying off my character to the ground and... doubles itself!   :scratchchin:

 

Also once I lost my previous outfit's inventory completely since it wasn't transferred into the newly lootet outfit.  I had two empty copy of my previous outfit on the ground because I had tried switching back again to my original outfit and the new outfit had just that in inventory what the dead enemy had carried.  But ofc I will test some more and make a vid so you might see if I do something wrong when using your script.

 

Experienced similar doubling effect and inventory loss when testing today.

 

For the most part though, it works fine, nice! Any way to get it to work like the vanilla game function does? (i.e. The uniforms keep their original items when switched.)

Share this post


Link to post
Share on other sites

Last Version is very similar to vanilla inventory and takes into account each items in crate and inside uniforms or vests already in crate. So, there should be no more lost items even inside equipments.

Share this post


Link to post
Share on other sites

oh by the way, strange thing happened, when someone want to take a uniform from the vehicle, the vehicle disappears after that.

Share this post


Link to post
Share on other sites
41 minutes ago, zagr said:

oh by the way, strange thing happened, when someone want to take a uniform from the vehicle, the vehicle disappears after that.

 

Thanks good to know. I will have a look at that. It's not every day you can find an uniform straight in vehicle crate!

Share this post


Link to post
Share on other sites

thanks for the update 

 

15 hours ago, zagr said:

oh by the way, strange thing happened, when someone want to take a uniform from the vehicle, the vehicle disappears after that.

 

we were using an escape mission the heli suddenly disapeared we all crashed to the ground and died mission failed that would explain why 

Share this post


Link to post
Share on other sites

Shouldn't occur anymore. Always check for the last version. Thanks for your feedback.

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

×