Jump to content

Recommended Posts

1 hour ago, moosemilker said:

Hi. Cool script! There are a few mods that try to solve the "wear all uniforms" problem (all built or derived from Haleks's 2015 script), but I don't want a mod, since all clients need the mod loaded. Hence the script method is best for dedicated servers that don't want to force the client to load mods.

 

While trying to add "this script" to the bottom of initPlayerLocal.sqf ('player' is initialized), of the co10 Escape mpmission (specifically this mpmission 'co10_Escape_BIS_NATO_vs_CSAT.Tanoa'), the client gets really bad frames. Has anyone tried to add this script to co10 Escape missions? I am running a dedicated server with 'co10_Escape_BIS_NATO_vs_CSAT.Tanoa' mp mission. I usually get 70-90 FPS without this script. When I add it, FPS drops to 10-25 FPS.

 

Thanks for reading.

 

-Aaron

 

 

 

 

Nothing runs if the inventory is not opened (just waiting for an EH). So FPS drop when inventory is opened? 

I can't reproduce that on your mission. Tested.

Share this post


Link to post
Share on other sites

First of all, nice Script.

 

I found a Uniform where your Script does not work: "U_BG_Guerilla2_3"

I guess this problem appears on some other uniforms too

 

The Problem is, that in that case _selectedUnif will be filled with three different classnames.
You select the first one by default. _uniformObject will be undefined and the code crashes in line 39 bc of !isNull _uniformObject

To fix it i iterate over _selectedUnif and exit if _uniformObject is not nil

 

I have changed the following part to fix it, starting with line 21

private _selectedUnif = ((_uniforms select {toLower (gettext (_x >> "picture")) splitString "\"joinString "\" == _picture}) apply {configName _x}); 
if (_selectedUnif isEqualTo []) exitWith {}; 

if !(pl_container isKindOf "CAManBase") then {
  private _unifClass = "";
  {
    _unifClass = _x;
    _unifConts = (everyContainer pl_container select {getNumber (configFile >> "CfgWeapons" >> _x #0 >> 'ItemInfo' >> 'type') == 801});  
    _cnt = 0; 

    for "_i" from 0 to _index do {  
      if (lbText [_idc,_i] == _text) then {  
        _cnt = _cnt +1;  
        _uniformObject = _unifConts select {_unifClass == (_x #0)} select (_cnt -1) select 1  
      };  
    };  

    if (!isNil "_uniformObject") exitWith {_unifClass = _x;};
  } forEach _selectedUnif;
  _selectedUnif = _unifClass;
} else {  
  _selectedUnif = _selectedUnif #0;
  _uniformObject = uniformContainer pl_container  
}; 

 

And everything, with the changes i made

Spoiler

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 {
          private _unifClass = "";
          {
            _unifClass = _x;
            _unifConts = (everyContainer pl_container select {getNumber (configFile >> "CfgWeapons" >> _x #0 >> 'ItemInfo' >> 'type') == 801});  
            _cnt = 0; 
   
            for "_i" from 0 to _index do {  
              if (lbText [_idc,_i] == _text) then {  
                _cnt = _cnt +1;  
                _uniformObject = _unifConts select {_unifClass == (_x #0)} select (_cnt -1) select 1  
              };  
            };  
  
            if (!isNil "_uniformObject") exitWith {_unifClass = _x;};
          } forEach _selectedUnif;
          _selectedUnif = _unifClass;
        } 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];  
  };  
}];

 

 

I fixed it in my implementation and updated your original with the fix - i hope i got everything, had no time for testing

  • Like 1

Share this post


Link to post
Share on other sites

 @Larry0503   Thanks for your feedback and the time spent to make it work. That helped me to grasp the issue. Front page corrected.

  • 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

×