Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Exile Mod
- * www.exilemod.com
- * © 2015 Exile Mod Team
- *
- * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
- * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
- */
- private["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile"];
- _unit = _this select 0;
- _selectionName = _this select 1;
- _amountOfDamage = _this select 2;
- _sourceOfDamage = _this select 3;
- _typeOfProjectile = _this select 4;
- 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];
- };
- }]
- if (isPlayer _sourceOfDamage && !(_sourceOfDamage isEqualTo player)) exitWith
- {
- _amountOfDamage = damage _unit;
- _amountOfDamage
- };
- 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];
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement