Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. #define ctrlSelData(ctrl) (lbData[##ctrl,(lbCurSel ##ctrl)])
  3. /*
  4. File: fn_vehStoreAllItem.sqf
  5. Author: Killerknight
  6.  
  7. Description:
  8. stores all (max items) from selected and add it to the Vehicles inventory
  9. */
  10. private["_ctrl","_num","_totalWeight","_itemWeight","_veh_data","_inv","_index","_val"];
  11.  
  12. if(!DarfEinzahlen) exitWith {[localize "STR_NOTF_Trunk_Store_Stop",true,"fast","orange","Error"]spawn Life_fnc_msg;};
  13. if(DarfEinzahlen) then {
  14. DarfEinzahlen = false;
  15. [] spawn {
  16. sleep 1;
  17. DarfEinzahlen = true;
  18. };
  19. };
  20.  
  21. disableSerialization;
  22.  
  23. _ctrl = ctrlSelData(3503);
  24. if ((lbCurSel ((findDisplay 3500) displayCtrl 3503)) isEqualTo -1)exitWith {["Du musst zuerst etwas auswählen.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
  25. if(Life_trunk_vehicle isKindOf "House_F") then {
  26. _mWeight = 0;
  27. {_mWeight = _mWeight + ([(typeOf _x)] call Life_fnc_vehicleWeightCfg);} foreach (Life_trunk_vehicle getVariable["containers",[]]);
  28. _totalWeight = [_mWeight,(Life_trunk_vehicle getVariable["Trunk",[[],0]]) select 1];
  29. } else {
  30. _totalWeight = [Life_trunk_vehicle] call Life_fnc_vehicleWeight;
  31. };
  32. _num2 = getNumber(missionConfigFile >> "VirtualItems" >> _ctrl >> "weight");
  33. _num1 = (floor (((_totalWeight select 0) - (_totalWeight select 1)) / _num2));
  34. _num = if (_num1 <= (ITEM_VALUE(_ctrl))) then {_num1}else{(ITEM_VALUE(_ctrl))};
  35. if(_num < 1) exitWith {["Du hast kein Platz dafür.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
  36. _itemWeight = ([_ctrl] call Life_fnc_itemWeight) * _num;
  37. _veh_data = Life_trunk_vehicle getVariable ["Trunk",[[],0]];
  38. _inv = _veh_data select 0;
  39.  
  40. if(_ctrl == "goldbar" && {!(Life_trunk_vehicle isKindOf "LandVehicle" OR Life_trunk_vehicle isKindOf "House_F")}) exitWith {["Du kannst dieses Item nur in Landfahrzeuge einlagern.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
  41.  
  42. if(_ctrl == "money") then
  43. {
  44. _index = [_ctrl,_inv] call TON_fnc_index;
  45. if(Life_cash < _num) exitWith {["Du hast nicht so viel Geld zum einlagern.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
  46. if(_index == -1) then
  47. {
  48. _inv pushBack [_ctrl,_num];
  49. }
  50. else
  51. {
  52. _val = _inv select _index select 1;
  53. _inv set[_index,[_ctrl,_val + _num]];
  54. };
  55.  
  56. Life_cash = Life_cash - _num;
  57. Life_trunk_vehicle setVariable["Trunk",[_inv,(_veh_data select 1) + _itemWeight],true];
  58. [Life_trunk_vehicle] call Life_fnc_vehInventory;
  59. }
  60. else
  61. {
  62. if(((_totalWeight select 1) + _itemWeight) > (_totalWeight select 0)) exitWith {["Das Fahrzeug ist voll.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
  63.  
  64. if(!([false,_ctrl,_num] call Life_fnc_handleInv)) exitWith {["Konnte das Item nicht umlagern.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
  65. _index = [_ctrl,_inv] call TON_fnc_index;
  66. if(_index isEqualTo -1) then
  67. {
  68. _inv pushBack [_ctrl,_num];
  69. }
  70. else
  71. {
  72. _val = _inv select _index select 1;
  73. _inv set[_index,[_ctrl,_val + _num]];
  74. };
  75.  
  76. Life_trunk_vehicle setVariable["Trunk",[_inv,(_veh_data select 1) + _itemWeight],true];
  77. [Life_trunk_vehicle] call Life_fnc_vehInventory;
  78. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement