Jump to content

Recommended Posts

On 2/26/2018 at 8:18 PM, pierremgi said:

                                                                                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 20/03/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_"});
          _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...

 

 

How do I define each player, if they are not "defined" within the sqf?

Share this post


Link to post
Share on other sites

You don't need to do anything. Just running the script "when" the player is already "defined". I meant when the player is consistent and has an interface, not as unit in a dedicated server or headless client for example, or in lobby...

Two simple ways:

- in init.sqf, add:

waitUntil {!isNull player}; // wait for the played unit transferred on his local PC; {local player} or {getClientStateNumber > 8} should work also.

then the script

- or straight in initPlayerLocal.sqf which is an special event script, running on SP or MP, automatically, when the player is already consistent for the game.

  • Like 1

Share this post


Link to post
Share on other sites
10 minutes ago, pierremgi said:

You don't need to do anything. Just running the script "when" the player is already "defined". I meant when the player is consistent and has an interface, not as unit in a dedicated server or headless client for example, or in lobby...

Two simple ways:

- in init.sqf, add:

waitUntil {local player}; // wait for the played unit transferred on his local PC

then the script

- or straight in initPlayerLocal.sqf which is an special event script, running on SP or MP, automatically, when the player is already consistent for the game.

 

Great!

 

So if my initPlayerLocal looks like this:

 

____________________________________________________


//--- Not joining in progress? Kick client to lobby, no idea wat the fuck is happening
if(!(_this select 1)) then {
    diag_log "JIP NOT ALLOWED. WHY DID THIS HAPPEN?";
    endMission "FAIL";
};
//10000 cutText ["Please wait...","BLACK FADED",0];
0 cutRsc ["background","PLAIN",0];
enableSaving[false,false];
player allowDamage false;

call BASE_fnc_init;

onPreloadFinished {
    disableUserInput true;
    player setVariable["isReady",true,true];
    BASE_var_LastData = diag_tickTime;
    [] spawn BASE_fnc_TimeoutCheck;
    onPreloadFinished {};
};

________________________________________________

 

I can simply add that code to the bottom of this?

 

Share this post


Link to post
Share on other sites

Not supposed to be compatible with all mods. I can't guess how your inventory interface works (and I have no time for that, sorry).

Your first own lines seems to disable the user input anyway... I hope you re-enable it somewhere!

Share this post


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

Not supposed to be compatible with all mods. I can't guess what your inventory interface works (and I have no time for that, sorry).

 

I'm using:

 

https://steamcommunity.com/workshop/filedetails/?id=843770737 (RHS)

 

http://www.armaholic.com/page.php?id=26188 (RDS)

 

http://www.armaholic.com/page.php?id=27353 (LOP)

 

http://www.armaholic.com/page.php?id=26661 (TRYK)

Share this post


Link to post
Share on other sites

The RDS A2 seems to have its own preemptive action on inventory. If so, the EH "inventoryOpened" can jam each other. You'd probably have to make a choice.

Share this post


Link to post
Share on other sites
10 minutes ago, pierremgi said:

The RDS A2 seems to have its own preemptive action on inventory. If so, the EH "inventoryOpened" can jam each other. You'd probably have to make a choice.

 

I have removed RDS 2 from the mission, still won't work.

Share this post


Link to post
Share on other sites

The script works (tested again and again) on Vanilla. Did you right click on a civilian uniform, from a crate or a corpse or on even on ground? Should work. The only difference is the drag and drop,  not effective.

On the other way, as written above, there is a :

disableUserInput true;

in your lines which could be a potential problem.

So, I can't help you. If the RDS A2 is not at fault, some other lines in your scenario could be.

Share this post


Link to post
Share on other sites

This script is updated to make it compatible with most of the current mods: RHS, CUP, TRYK, WW2 MAS, R3F...  probably more.

 

Nota : some units , like red R3F or Zombies Ryan doesn't have a uniform (check in Editor loadout arsenal). these units are probably inherited from other modded units. As far as their uniforms can't appear in inventory, this script doesn't make any miracle. I suggest you edit loadout first and choose an uniform.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Awesome code @pierremgi sadly it needs tweaking to work with ExileMod though. credit for the tweaking in this goes to AeoG | El'Rabito to make it work for ExileMod but i compiled it for easy implementation. Confirmed to work with all RHS and CUP uniforms here is the link if interested. Wear What You Want.zip 

  • Like 2

Share this post


Link to post
Share on other sites

Some TRYK uniforms get duped if you try to wear them with right click.

 

14:32:20 File mpmissions\__CUR_MP.Chernarus_2035\custom\Status_Interactions\UnifU1.sqf..., line 26
14:32:20 Error in expression <able "allconts") select _i) select 1 == _uniformObject) exitWith {
(pl_container>
14:32:20   Error position: <_uniformObject) exitWith {
(pl_container>
14:32:20   Error Undefined variable in expression: _uniformobject
14:32:20 File mpmissions\__CUR_MP.Chernarus_2035\custom\Status_Interactions\UnifU1.sqf..., line 45
14:32:20 Error in expression <able "allconts") select _i) select 1 == _uniformObject) exitWith {
(pl_container>
14:32:20   Error position: <_uniformObject) exitWith {
(pl_container>
14:32:20   Error Undefined variable in expression: _uniformobject
14:32:20 File mpmissions\__CUR_MP.Chernarus_2035\custom\Status_Interactions\UnifU1.sqf..., line 45
14:32:20 Error in expression <dInvent pushback _x} foreach (itemCargo _uniformObject);
if (magazineCargo _unif>
14:32:20   Error position: <_uniformObject);
if (magazineCargo _unif>
14:32:20   Error Undefined variable in expression: _uniformobject
14:32:20 File mpmissions\__CUR_MP.Chernarus_2035\custom\Status_Interactions\UnifU1.sqf..., line 33
14:32:21 Error in expression <able "allconts") select _i) select 1 == _uniformObject) exitWith {
(pl_container>
14:32:21   Error position: <_uniformObject) exitWith {
(pl_container>

 

Share this post


Link to post
Share on other sites
3 hours ago, El' Rabito said:

Some TRYK uniforms get duped if you try to wear them with right click.
 

 

I took time to test some uniforms on Tryk ("TRYK_U_denim_jersey_blk","TRYK_HRP_UCP","TRYK_T_camo_desert_marpat_BG"). I can't reproduce that. It seems they don't need this code, anyway...

You have a UnifU1.sqf . Not mine. If you modify my code, I can't help.

Share this post


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

 

I took time to test some uniforms on Tryk ("TRYK_U_denim_jersey_blk","TRYK_HRP_UCP","TRYK_T_camo_desert_marpat_BG"). I can't reproduce that. It seems they don't need this code, anyway...

You have a UnifU1.sqf . Not mine. If you modify my code, I can't help.


I just needed to seperate the functions. (https://mega.nz/#!WThXXSpb!mr2Mwx61k-htZU_SL2sbKKiJ57WTzwVbiwTRLIcXBvU)

It works for the RHS uniforms, just TRYK Uniforms produce this error.

Share this post


Link to post
Share on other sites

I testet it without seperating the functions and its works for RHS but procudes the same error for TRYK uniforms. So it's not my "modifactions" ^^

I wore the "rhs_uniform_msv_emr" and tried to pickup the "TRYK_U_B_PCUHsW8" Uniform. It worked a few times and then it continues to error

 

38dc2e6019878bbbea0c348fdf2287c9.jpg

Share this post


Link to post
Share on other sites

I tried to swap between a mix of Arma 3 Uniforms and 3CB and RHS and no problems. But as soon as you add TRYK to the mix it errors 😥 (i used "TRYK_U_B_PCUHsW8" for testing) .
I was so happy to have this annoying Arma mechanic fixed but now it causes this duping issues ....

Share this post


Link to post
Share on other sites

I forgot you're on Exile mods . I can't reproduce that in Vanilla (even with "TRYK_U_B_PCUHsW8").

Anyway, I'll have a look at the entire code. Probably something to do for securing it.

 

 

Share this post


Link to post
Share on other sites
On 12/17/2019 at 8:49 PM, pierremgi said:

I forgot you're on Exile mods . I can't reproduce that in Vanilla (even with "TRYK_U_B_PCUHsW8").

Anyway, I'll have a look at the entire code. Probably something to do for securing it.

 

 

Ok thank you for testing, really weird. I try to find a way to exclude TRYK uniforms in your script 😬

Share this post


Link to post
Share on other sites

Totally reworked. Improved code + should work with all mods.

 

Important related note for mission makers:

NEVER EVER overload a crate. As you can set you custom equipment storage in editor, if you add so much stuff there is no left room at all, you'll experience this bug (Vanilla, no mod, no script):

https://feedback.bistudio.com/T147602

 

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

×