Advertisement
Guest User

Untitled

a guest
Apr 7th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.30 KB | None | 0 0
  1. private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script","_outputOriented","_compile","_array","_outputClass","_outputType","_key_colors","_ownerKeyId","_itemsPlayer","_hasKey","_objects","_ownerID","_i"];
  2. disableSerialization;
  3. _control = _this select 0;
  4. _button = _this select 1;
  5. _parent = findDisplay 106;
  6.  
  7. //if ((time - dayzClickTime) < 1) exitWith {};
  8. if (!DZE_SelfTransfuse && ((gearSlotData _control) == "ItemBloodBag")) exitWith {};
  9. if (_button == 1) then {
  10. //dayzClickTime = time;
  11. _group = _parent displayCtrl 6902;
  12.  
  13. _pos = ctrlPosition _group;
  14. _pos set [0,((_this select 2) + 0.48)];
  15. _pos set [1,((_this select 3) + 0.07)];
  16.  
  17. _item = gearSlotData _control;
  18.  
  19. _conf = configFile >> "cfgMagazines" >> _item;
  20. if (!isClass _conf) then {
  21. _conf = configFile >> "cfgWeapons" >> _item;
  22. };
  23. _name = getText(_conf >> "displayName");
  24.  
  25. _cfgActions = _conf >> "ItemActions";
  26. _numActions = (count _cfgActions);
  27. _height = 0;
  28.  
  29. //Populate Menu
  30. for "_i" from 0 to (_numActions - 1) do
  31. {
  32. _menu = _parent displayCtrl (1600 + _i);
  33. _menu ctrlShow true;
  34. _config = (_cfgActions select _i);
  35. _type = getText (_config >> "text");
  36. _script = getText (_config >> "script");
  37. _outputOriented = getNumber (_config >> "outputOriented") == 1;
  38. _height = _height + (0.025 * safezoneH);
  39. _compile = format["_id = '%2' %1;",_script,_item];
  40. uiNamespace setVariable ['uiControl', _control];
  41. if (_outputOriented) then {
  42. /*
  43. This flag means that the action is output oriented
  44. the output class will then be transferred to the script
  45. && the type used for the name
  46. */
  47. _array = getArray (_config >> "output");
  48. _outputClass = _array select 0;
  49. _outputType = _array select 1;
  50. _name = getText (configFile >> _outputType >> _outputClass >> "displayName");
  51. _compile = format["_id = ['%2',%3] %1;",_script,_item,_array];
  52. };
  53.  
  54. _menu ctrlSetText format[_type,_name];
  55. _menu ctrlSetEventHandler ["ButtonClick",_compile];
  56. };
  57. _itemsPlayer = items player;
  58.  
  59. _temp_keys = [];
  60. _temp_keys_names = [];
  61. // find available keys
  62. _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
  63. if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _item)) in _key_colors) then {
  64. _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _item >> "keyid");
  65. _ownerKeyName = getText(configFile >> "CfgWeapons" >> _item >> "displayName");
  66. _temp_keys_names set [_ownerKeyId,_ownerKeyName];
  67.  
  68. _objects = nearestObjects [getPos player, ["LandVehicle","Helicopter","Plane","Ship"], 50];
  69. _i = 0;
  70. {
  71. if (alive _x) then {
  72. _ownerID = _x getVariable ["CharacterID", "0"];
  73. _hasKey = (_ownerID == str(_ownerKeyId));
  74. _oldOwner = (_ownerID == dayz_playerUID);
  75.  
  76. if(_hasKey or _oldOwner) then {
  77. if(locked _x) then {
  78. //Unlock
  79. _menu = _parent displayCtrl (1600 + _numActions);
  80. _menu ctrlShow true;
  81. _text = "Unlock";
  82. _script = "[""" + _ownerID + """] execVM ""Scripts\vehicle\remote_unlock.sqf""";
  83. _height = _height + (0.025 * safezoneH);
  84. uiNamespace setVariable ['uiControl', _control];
  85. _menu ctrlSetText _text;
  86. _menu ctrlSetEventHandler ["ButtonClick",_script];
  87. } else {
  88. //Lock
  89. _menu = _parent displayCtrl (1600 + _numActions);
  90. _menu ctrlShow true;
  91. _text = "Lock";
  92. _script = "[""" + _ownerID + """] execVM ""Scripts\vehicle\remote_lock.sqf""";
  93. _height = _height + (0.025 * safezoneH);
  94. uiNamespace setVariable ['uiControl', _control];
  95. _menu ctrlSetText _text;
  96. _menu ctrlSetEventHandler ["ButtonClick",_script];
  97. };
  98. //Engine start
  99. _menu = _parent displayCtrl (1600 + _numActions + 1);
  100. _menu ctrlShow true;
  101. _text = "Engine";
  102. _script = "[""" + _ownerID + """] execVM ""Scripts\vehicle\remote_engine.sqf""";
  103. _height = _height + (0.025 * safezoneH);
  104. uiNamespace setVariable ['uiControl', _control];
  105. _menu ctrlSetText _text;
  106. _menu ctrlSetEventHandler ["ButtonClick",_script];
  107. };
  108.  
  109. _i = _i + 1;
  110. };
  111. } forEach _objects;
  112. };
  113. // BEGIN MODIFIED CODE: extra click actions
  114. {
  115. private["_classname","_text","_execute","_condition"];
  116. _classname = _x select 0;
  117. _text = _x select 1;
  118. _execute = _x select 2;
  119. _condition = _x select 3;
  120. // if the clicked item matches, then assign the script call and display text
  121. if(_item == _classname && (call compile _condition)) then {
  122. _menu = _parent displayCtrl (1600 + _numActions);
  123. _menu ctrlShow true;
  124. _height = _height + (0.025 * safezoneH);
  125. uiNamespace setVariable ['uiControl', _control];
  126. _menu ctrlSetText _text;
  127. _menu ctrlSetEventHandler ["ButtonClick",_execute];
  128. _numActions = _numActions + 1;
  129. };
  130. } forEach DZE_CLICK_ACTIONS;
  131. // END MODIFIED CODE: extra click actions
  132. _pos set [3,_height];
  133. //hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos];
  134.  
  135. _group ctrlShow true;
  136. ctrlSetFocus _group;
  137. _group ctrlSetPosition _pos;
  138. _group ctrlCommit 0;
  139. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement