Advertisement
secondcoming

ExileClient_object_item_construct.sqf

Mar 14th, 2016
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 7.39 KB | None | 0 0
  1. /**
  2.  * ExileClient_object_item_construct
  3.  *
  4.  * Exile Mod
  5.  * www.exilemod.com
  6.  * © 2015 Exile Mod Team
  7.  *
  8.  * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  9.  * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  10.  */
  11.  
  12. private["_itemClassName","_minimumDistanceToTraderZones","_minimumDistanceToSpawnZones","_maximumNumberOfTerritoriesPerPlayer","_numberOfTerritories"];
  13. _itemClassName = _this select 0;
  14. if !(_itemClassName in (magazines player)) exitWith {false};
  15. if( isClass(configFile >> "CfgMagazines" >> _itemClassName >> "Interactions" >> "Constructing") ) then
  16. {
  17.     if (findDisplay 602 != displayNull) then
  18.     {
  19.         (findDisplay 602) closeDisplay 2;
  20.     };
  21.     try
  22.     {
  23.         if !((vehicle player) isEqualTo player) then
  24.         {
  25.             throw "You cannot build while in a vehicle.";  
  26.         };
  27.         _minimumDistanceToTraderZones = getNumber (missionConfigFile >> "CfgTerritories" >> "minimumDistanceToTraderZones");
  28.         if ([player, _minimumDistanceToTraderZones] call ExileClient_util_world_isTraderZoneInRange) then
  29.         {
  30.             throw "You are too close to a safe zone.";
  31.         };
  32.         if (player call ExileClient_util_world_isInNonConstructionZone) then
  33.         {
  34.             throw "Building is disallowed here on this server.";
  35.         };
  36.         if (player call ExileClient_util_world_isInConcreteMixerZone) then
  37.         {
  38.             throw "You are too close to a concrete mixer zone.";
  39.         };
  40.         _minimumDistanceToSpawnZones = getNumber (missionConfigFile >> "CfgTerritories" >> "minimumDistanceToSpawnZones");
  41.         if ([player, _minimumDistanceToSpawnZones] call ExileClient_util_world_isSpawnZoneInRange) then
  42.         {
  43.             throw "You are too close to a spawn zone.";
  44.         };
  45.         ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    
  46.         // PREVENT BUILDING NEAR MILITARY
  47.  
  48.        
  49.         _cantBuildNear  = [ "Land_TentHangar_V1_F","Land_Hangar_F","Land_Airport_Tower_F","Land_Cargo_House_V1_F",
  50.                             "Land_Cargo_House_V3_F","Land_Cargo_HQ_V1_F","Land_Cargo_HQ_V2_F","Land_Cargo_HQ_V3_F",
  51.                             "Land_u_Barracks_V2_F","Land_i_Barracks_V2_F","Land_i_Barracks_V1_F","Land_Cargo_Patrol_V1_F",
  52.                             "Land_Cargo_Patrol_V2_F","Land_Cargo_Tower_V1_F","Land_Cargo_Tower_V1_No1_F","Land_Cargo_Tower_V1_No2_F",
  53.                             "Land_Cargo_Tower_V1_No3_F","Land_Cargo_Tower_V1_No4_F","Land_Cargo_Tower_V1_No5_F","Land_Cargo_Tower_V1_No6_F",
  54.                             "Land_Cargo_Tower_V1_No7_F","Land_Cargo_Tower_V2_F","Land_Cargo_Tower_V3_F","Land_MilOffices_V1_F",
  55.                             "Land_Radar_F","Land_budova4_winter","land_hlaska","Land_Vysilac_FM","land_st_vez","Land_ns_Jbad_Mil_Barracks",
  56.                             "Land_ns_Jbad_Mil_ControlTower","Land_ns_Jbad_Mil_House","land_pozorovatelna","Land_vys_budova_p1",
  57.                             "Land_Vez","Land_Mil_Barracks_i","Land_Mil_Barracks_L","Land_Mil_Barracks",
  58.                             "Land_Hlidac_budka","Land_Ss_hangar","Land_Mil_ControlTower","Land_a_stationhouse",
  59.                             "Land_Farm_WTower","Land_Mil_Guardhouse","Land_A_statue01","Land_A_Castle_Gate",
  60.                             "Land_A_Castle_Donjon","Land_A_Castle_Wall2_30","Land_A_Castle_Stairs_A",
  61.                             "Land_i_Barracks_V1_dam_F","Land_Cargo_Patrol_V3_F","Land_Radar_Small_F","Land_Dome_Big_F",
  62.                             "Land_Dome_Small_F","Land_Army_hut3_long_int","Land_Army_hut_int","Land_Army_hut2_int",
  63.                             // Additional Buildings
  64.                             "Land_Barracks_01_camo_F","Land_Barracks_01_grey_F","land_AII_last_floor","land_AII_middle_floor",
  65.                             "land_AII_upper_part","Land_Ind_IlluminantTower","Land_Misc_deerstand","Land_ns_Jbad_A_Stationhouse",
  66.                             "Land_Airport_01_controlTower_F","Land_Airport_01_terminal_F","Land_Airport_02_controlTower_F",
  67.                             "Land_Airport_02_terminal_F","Land_Cargo_House_V4_F","Land_Cargo_HQ_V4_F","Land_Cargo_Patrol_V4_F",
  68.                             "Land_Cargo_Tower_V4_F"
  69.                         ];     
  70.  
  71.         // PREVENT BUILDING NEAR ROADS
  72.         _NearRoad = (position player) nearRoads 15;
  73.         _TooNearRoads = _NearRoad select 0;
  74.         if (!isNil "_TooNearRoads") then { throw "You cannot build too close to roads"; };         
  75.        
  76.         // PREVENT BUILDING NEAR AI BASE
  77.         _AIBasepos = [0,0,0];
  78.         _MinRange = 1;
  79.        
  80.         if(worldName == 'Altis')then
  81.         {
  82.             _AIBasepos = [12571,14337,0]; // Location of AI Base Mission
  83.             _MinRange = 1250; // Min distance to AI Base
  84.             _cantBuildDist = 200; // Min distance to military buildings
  85.             _maxSafes = 5;
  86.             _nearAIBase = (getPosATL player) distance _AIBasepos;
  87.             if (_nearAIBase < _MinRange) then { throw "You cannot build near the AI base"; };                  
  88.         };
  89.         if(worldName == 'Chernarus')then
  90.         {
  91.             _AIBasepos = [3810,8887,0]; // Location of AI Base Mission
  92.             _MinRange = 1100; // Min distance to AI Base
  93.             _cantBuildDist = 200; // Min distance to military buildings
  94.             _maxSafes = 5;
  95.             _nearPVPZone = (getPosATL player) distance [1174,2516,0];
  96.             if (_nearPVPZone < 1000) then { throw "You cannot build too close to the PVP zone"; };
  97.             _nearAIBase = (getPosATL player) distance _AIBasepos;
  98.             if (_nearAIBase < _MinRange) then { throw "You cannot build near the AI base"; };                  
  99.         };
  100.         if(worldName == 'Namalsk')then
  101.         {
  102.             _AIBasepos = [3926,7523,0]; // Location of AI Base Mission
  103.             _MinRange = 750; // Min distance to AI Base
  104.             _cantBuildDist = 250; // Min distance to military buildings
  105.             _maxSafes = 5;
  106.             _nearAIBase = (getPosATL player) distance _AIBasepos;
  107.             if (_nearAIBase < _MinRange) then { throw "You cannot build near the AI base"; };                  
  108.         };
  109.         if(worldName == 'Napf')then
  110.         {
  111.             _AIBasepos = [2377,7710,0];     // Location of AI Base Mission
  112.             _MinRange = 1250;               // Min distance to AI Base
  113.             _cantBuildDist = 350;           // Min distance to military buildings
  114.             _maxSafes = 2;     
  115.             _nearAIBase = (getPosATL player) distance _AIBasepos;
  116.             if (_nearAIBase < _MinRange) then { throw "You cannot build near the AI base"; };          
  117.         };
  118.         if(worldName == 'Tanoa')then
  119.         {
  120.             _AIBasepos = [0,0,0];
  121.             _MinRange = 1;
  122.             _cantBuildDist = 200; // Min distance to military buildings
  123.             _maxSafes = 5;             
  124.         }; 
  125.    
  126.        
  127.         if ({typeOf _x in _cantBuildNear} count nearestObjects[player, _cantBuildNear, _cantBuildDist] > 0) then { throw "You cannot build within 500m of military buildings"; };
  128.  
  129.         if(_itemClassName isEqualTo "Exile_Container_Safe") then
  130.         {
  131.             //Check if _maxSafes safes in range already
  132.             _nearSafes = count (player nearObjects ["Exile_Container_Safe", 150]);
  133.             if (_nearSafes > (_maxSafes - 1)) then { throw "You cannot build more than 5 safes";  };           
  134.         };         
  135.        
  136.         ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    
  137.  
  138.        
  139.         if(_itemClassName isEqualTo "Exile_Item_Flag") then
  140.         {
  141.             if([position player, 300] call ExileClient_util_world_isTerritoryInRange) then { throw "You are too close to another territory"; };
  142.             _maximumNumberOfTerritoriesPerPlayer = getNumber (missionConfigFile >> "CfgTerritories" >> "maximumNumberOfTerritoriesPerPlayer");
  143.             _numberOfTerritories = player call ExileClient_util_territory_getNumberOfTerritories;
  144.             if (_numberOfTerritories >= _maximumNumberOfTerritoriesPerPlayer) then
  145.             {
  146.                 throw "You have reached the maximum number of territories you can own.";
  147.             };
  148.             call ExileClient_gui_setupTerritoryDialog_show;
  149.         }
  150.         else
  151.         {
  152.             [_itemClassName] call ExileClient_construction_beginNewObject;
  153.         };
  154.     }
  155.     catch
  156.     {
  157.         ["ErrorTitleAndText", ["Construction aborted!", _exception]] call ExileClient_gui_toaster_addTemplateToast;
  158.     };
  159. };
  160. true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement