LeventHAN

fn_houseMenu.sqf

Jul 8th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 7.44 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3.     File: fn_houseMenu.sqf
  4.     Author: Bryan "Tonic" Boardwine
  5.     Description:
  6.     Building interaction menu
  7. */
  8. #define Btn1 37450
  9. #define Btn2 37451
  10. #define Btn3 37452
  11. #define Btn4 37453
  12. #define Btn5 37454
  13. #define Btn6 37455
  14. #define Btn7 37456
  15. #define Btn8 37457
  16. #define Title 37401
  17.  
  18. private ["_display","_curTarget","_Btn1","_Btn2","_Btn3","_Btn4","_Btn5","_Btn6","_Btn7","_Btn8"];
  19. disableSerialization;
  20. _curTarget = param [0,objNull,[objNull]];
  21. if (isNull _curTarget) exitWith {}; //Bad target
  22. _houseCfg = [(typeOf _curTarget)] call life_fnc_houseConfig;
  23. if (count _houseCfg isEqualTo 0 && playerSide isEqualTo civilian) exitWith {};
  24.  
  25. if (!dialog) then {
  26.     createDialog "pInteraction_Menu";
  27. };
  28.  
  29. _Btn1 = CONTROL(37400,Btn1);
  30. _Btn2 = CONTROL(37400,Btn2);
  31. _Btn3 = CONTROL(37400,Btn3);
  32. _Btn4 = CONTROL(37400,Btn4);
  33. _Btn5 = CONTROL(37400,Btn5);
  34. _Btn6 = CONTROL(37400,Btn6);
  35. _Btn7 = CONTROL(37400,Btn7);
  36. _Btn8 = CONTROL(37400,Btn8);
  37. {_x ctrlShow false;} forEach [_Btn1,_Btn2,_Btn3,_Btn4,_Btn5,_Btn6,_Btn7,_Btn8];
  38.  
  39. life_pInact_curTarget = _curTarget;
  40.  
  41. if (_curTarget in life_hideoutBuildings) exitWith {
  42.     closeDialog 0;
  43.     hint localize "STR_House_Hideout";
  44. };
  45.  
  46. if (_curTarget isKindOf "House_F" && playerSide isEqualTo west) exitWith {
  47.  
  48.     private _vaultHouse = [[["Altis", "Land_Research_house_V1_F"], ["Tanoa", "Land_Medevac_house_V1_F"]]] call TON_fnc_terrainSort;
  49.     private _altisArray = [16019.5,16952.9,0];
  50.     private _tanoaArray = [11074.2,11501.5,0.00137329];
  51.     private _pos = [[["Altis", _altisArray], ["Tanoa", _tanoaArray]]] call TON_fnc_terrainSort;
  52.  
  53.     if ((nearestObject [_pos,"Land_Dome_Big_F"]) isEqualTo _curTarget || (nearestObject [_pos,_vaultHouse]) isEqualTo _curTarget) then {
  54.  
  55.         _Btn1 ctrlSetText localize "STR_pInAct_Repair";
  56.         _Btn1 buttonSetAction "[life_pInact_curTarget] spawn life_fnc_repairDoor; closeDialog 0;";
  57.         _Btn1 ctrlShow true;
  58.  
  59.         _Btn2 ctrlSetText localize "STR_pInAct_CloseOpen";
  60.         _Btn2 buttonSetAction "[life_pInact_curTarget] call life_fnc_doorAnimate; closeDialog 0;";
  61.         _Btn2 ctrlShow true;
  62.  
  63.     } else {
  64.         if (!isNil {_curTarget getVariable "house_owner"}) then {
  65.             _Btn1 ctrlSetText localize "STR_House_Raid_Owner";
  66.             _Btn1 buttonSetAction "[life_pInact_curTarget] call life_fnc_copHouseOwner;";
  67.             _Btn1 ctrlShow true;
  68.  
  69.             _Btn2 ctrlSetText localize "STR_pInAct_BreakDown";
  70.             _Btn2 buttonSetAction "[life_pInact_curTarget] spawn life_fnc_copBreakDoor; closeDialog 0;";
  71.             _Btn2 ctrlShow true;
  72.  
  73.             _Btn3 ctrlSetText localize "STR_pInAct_SearchHouse";
  74.             _Btn3 buttonSetAction "[life_pInact_curTarget] spawn life_fnc_raidHouse; closeDialog 0;";
  75.             _Btn3 ctrlShow true;
  76.  
  77.             if (player distance _curTarget > 3.6) then {
  78.                 _Btn3 ctrlEnable false;
  79.             };
  80.  
  81.             _Btn4 ctrlSetText localize "STR_pInAct_LockHouse";
  82.             _Btn4 buttonSetAction "[life_pInact_curTarget] spawn life_fnc_lockupHouse; closeDialog 0;";
  83.             _Btn4 ctrlShow true;
  84.         } else {
  85.             closeDialog 0;
  86.         };
  87.     };
  88. };
  89.  
  90. if (!(_curTarget in life_vehicles) || isNil {_curTarget getVariable "house_owner"}) then {
  91.     private _isHouse = (isClass (missionConfigFile >> "Housing" >> worldName >> typeOf _curTarget));
  92.     private _buildingPurchaseString = [
  93.         "STR_pInAct_BuyGarage",
  94.         "STR_pInAct_BuyHouse"
  95.     ] select _isHouse;
  96.    
  97.     _Btn1 ctrlSetText localize _buildingPurchaseString;
  98.     _Btn1 buttonSetAction "[life_pInact_curTarget] spawn life_fnc_buyHouse; closeDialog 0";
  99.     _Btn1 ctrlShow true;
  100.  
  101.     if (!isNil {_curTarget getVariable "house_owner"}) then {
  102.         _Btn1 ctrlEnable false;
  103.     };
  104.  
  105.     if (_isHouse) then {
  106.         if (getNumber (missionConfigFile >> "Housing" >> worldName >> (typeOf _curTarget) >> "canGarage") isEqualTo 1) then {
  107.             _Btn2 ctrlSetText localize "STR_pInAct_GarageExt";
  108.             _Btn2 buttonSetAction 'hint format [localize "STR_pInAct_GarageExtNOTF",[LIFE_SETTINGS(getNumber,"houseGarage_buyPrice")] call life_fnc_numberText];';
  109.             _Btn2 ctrlShow true;
  110.         };
  111.     };
  112.  
  113. } else {
  114.     if (isClass (missionConfigFile >> "Garages" >> worldName >> (typeOf _curTarget))) then {
  115.         _Btn1 ctrlSetText localize "STR_pInAct_SellGarage";
  116.         _Btn1 buttonSetAction "[life_pInact_curTarget] spawn life_fnc_sellHouse; closeDialog 0;";
  117.         _Btn1 ctrlShow true;
  118.  
  119.         if !(((_curTarget getVariable "house_owner") select 0) isEqualTo getPlayerUID player) then {
  120.             _Btn1 ctrlEnable false;
  121.         };
  122.  
  123.         _Btn2 ctrlSetText localize "STR_pInAct_AccessGarage";
  124.         _Btn2 buttonSetAction "[life_pInact_curTarget,""Car""] spawn life_fnc_vehicleGarage; closeDialog 0;";
  125.         _Btn2 ctrlShow true;
  126.  
  127.         _Btn3 ctrlSetText localize "STR_pInAct_StoreVeh";
  128.         _Btn3 buttonSetAction "[life_pInact_curTarget,player] spawn life_fnc_storeVehicle; closeDialog 0;";
  129.         _Btn3 ctrlShow true;
  130.     } else {
  131.         _Btn1 ctrlSetText localize "STR_pInAct_SellHouse";
  132.         _Btn1 buttonSetAction "[life_pInact_curTarget] spawn life_fnc_sellHouse; closeDialog 0;";
  133.         _Btn1 ctrlShow true;
  134.  
  135.         if (((_curTarget getVariable "house_owner") select 0) != (getPlayerUID player)) then {
  136.             _Btn1 ctrlEnable false;
  137.         };
  138.  
  139.         if (_curTarget getVariable ["locked",false]) then {
  140.             _Btn2 ctrlSetText localize "STR_pInAct_UnlockStorage";
  141.         } else {
  142.             _Btn2 ctrlSetText localize "STR_pInAct_LockStorage";
  143.         };
  144.         _Btn2 buttonSetAction "[life_pInact_curTarget] call life_fnc_lockHouse; closeDialog 0;";
  145.         _Btn2 ctrlShow true;
  146.  
  147.         if (isNull (_curTarget getVariable ["lightSource",objNull])) then {
  148.             _Btn3 ctrlSetText localize "STR_pInAct_LightsOn";
  149.         } else {
  150.             _Btn3 ctrlSetText localize "STR_pInAct_LightsOff";
  151.         };
  152.         _Btn3 buttonSetAction "[life_pInact_curTarget] call life_fnc_lightHouseAction; closeDialog 0;";
  153.         _Btn3 ctrlShow true;
  154.  
  155.         if (getNumber (missionConfigFile >> "Housing" >> worldName >> (typeOf _curTarget) >> "canGarage") isEqualTo 1 && {!(_curTarget getVariable ["blacklistedGarage",false])}) then {
  156.             if (_curTarget getVariable ["garageBought",false]) then {
  157.                 _Btn4 ctrlSetText localize "STR_pInAct_SellGarage";
  158.                 _Btn4 buttonSetAction "[life_pInact_curTarget] spawn life_fnc_sellHouseGarage; closeDialog 0;";
  159.                 _Btn4 ctrlShow true;
  160.  
  161.                 if (((_curTarget getVariable "house_owner") select 0) != (getPlayerUID player)) then {
  162.                     _Btn4 ctrlEnable false;
  163.                 };
  164.  
  165.                 _Btn5 ctrlSetText localize "STR_pInAct_AccessGarage";
  166.                 _Btn5 buttonSetAction "[life_pInact_curTarget,""Car""] spawn life_fnc_vehicleGarage; closeDialog 0;";
  167.                 _Btn5 ctrlShow true;
  168.  
  169.                 _Btn6 ctrlSetText localize "STR_pInAct_StoreVeh";
  170.                 _Btn6 buttonSetAction "[life_pInact_curTarget,player] spawn life_fnc_storeVehicle; closeDialog 0;";
  171.                 _Btn6 ctrlShow true;
  172.             } else {
  173.                 _Btn5 ctrlSetText localize "STR_pInAct_BuyGarage";
  174.                 _Btn5 buttonSetAction "[life_pInact_curTarget] spawn life_fnc_buyHouseGarage; closeDialog 0;";
  175.             };
  176.  
  177.             _Btn5 ctrlShow true;
  178.  
  179.         };
  180.  
  181.     };
  182. };
Advertisement