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

 

parameters:   NONE


 

fnc_otherUnif = {
  params ["_type","_return"];
  if (_type == 0) exitWith {
    MGI_button = _return select 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 (count _uniforms > 0) then {
      [_idc,_text,_picture,_index,_uniforms] spawn {
        params ["_idc","_text","_picture","_index","_uniforms","_selectedUnif","_unifContClasses",["_uniformObject",objNull],["_selectedInvent",[]],"_items","_otherItems","_g0"];
        _currentUnif = uniform player;
        _currentInvent = uniformItems player;
        _selectedUnif = ((_uniforms select {toLower (gettext (_x >> "picture")) splitString "\"joinString "\" == _picture}) apply {configName _x}) select 0;

        if !(pl_container isKindOf "CAManBase") then {
          _unifContClasses = (everyContainer pl_container select { (_x select 0) select [0,2] == "U_" or ["_U_",(_x select 0)] call bis_fnc_instring or ["uniform",(_x select 0)] call bis_fnc_instring});
          _cnt = 0;
          for "_i" from 0 to _index do {
            if (lbText [_idc,_i] == _text) then {
              _cnt = _cnt +1;
              _uniformObject = _unifContClasses select {_selectedUnif == (_x select 0)} select (_cnt -1) select 1
            };
          };
        } else {
          _uniformObject = uniformContainer pl_container
        };
        _selectedInvent = [];
        {_selectedInvent pushback _x} foreach (itemCargo _uniformObject);
        if (magazineCargo _uniformObject isEqualType []) then {
          {_selectedInvent pushback _x} foreach (magazineCargo _uniformObject);
        };
        if !(pl_container isKindOf "CAmanbase") then {
          _items = +itemCargo pl_container;
          _unifItems = _unifContClasses apply {_x select 0};
          _vestContClasses = (everyContainer pl_container select { (_x select 0) select [0,2] == "V_"});
          _vestItems = _vestContClasses apply {_x select 0};
          _otherItems = +_items - _unifItems - _vestItems;
          pl_container setVariable ["allconts",_unifContClasses+_vestContClasses];
          for "_i" from 0 to count (_unifContClasses+_vestContClasses) -1 do {
            if (((pl_container getVariable "allconts") select _i) select 1 == _uniformObject) exitWith {
              (pl_container getVariable "allconts") deleteAt _i
            };
          };
          pl_container setVariable ["allconts", +(pl_container getVariable "allconts") apply {[_x select 0, itemCargo (_x select 1), magazineCargo (_x select 1)]}];
          _g0 = pl_container;
          clearItemCargoGlobal _g0;
        } else {
          _g0 = createVehicle ["WeaponHolderSimulated_Scripted", (player modelToWorld [0,1,1]), [], 0, "CAN_COLLIDE"]
        };
        player forceAddUniform _selectedUnif;
        {player addItemToUniform _x} forEach _selectedInvent;
        call {
          if (pl_container isKindOf "CAManBase") exitWith {
            removeUniform pl_container
          };
          {
            _x params ["_cont",["_it",[]],["_mag",[]]];
            pl_container addItemCargoGlobal [_cont,1];
            _createdCont = pl_container call MGI_lastCont;
            {_createdCont addItemCargoGlobal [_x,1];true} count _it;
            {_createdCont addMagazineCargoGlobal [_x,1];true} count _mag;
          } forEach (pl_container getVariable ["allconts",[]]);
          {_g0 addItemCargoGlobal [_x,1]} forEach _otherItems;
        };
        _g0 addItemCargoGlobal [_currentUnif,1];
        _lastCont = _g0 call MGI_lastCont;
        {_lastCont addItemCargoGlobal [_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_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 7
  • Thanks 6

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

×