• 0
Sign in to follow this  
Flakvest

Disabled building near military and roads - can't build a fire

Question

This is a script I'm using to prevent building near certain definable structures (mainly military) and near roads.  The problem I'm having is now I can not build a campfire and I would like to make that the exception to these rules.  Could some help me by writing an exception and tell me where in this I need to place it?  I'm a complete noob when it comes to coding and scripting.  Thank you

 

Spoiler

/**
 * ExileClient_object_item_construct
 *
 * Exile Mod
 * exile.majormittens.co.uk
 * © 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["_itemClassName","_minimumDistanceToTraderZones","_minimumDistanceToSpawnZones","_maximumNumberOfTerritoriesPerPlayer","_numberOfTerritories"];
_itemClassName = _this select 0;
if !(_itemClassName in (magazines player)) exitWith {false};
if( isClass(configFile >> "CfgMagazines" >> _itemClassName >> "Interactions" >> "Constructing") ) then
{
    if (findDisplay 602 != displayNull) then
    {
        (findDisplay 602) closeDisplay 2; 
    };
    try 
    {
        if !((vehicle player) isEqualTo player) then
        {
            throw "You cannot build while in a vehicle.";  
        };
        _minimumDistanceToTraderZones = getNumber (missionConfigFile >> "CfgTerritories" >> "minimumDistanceToTraderZones");
        if ([player, _minimumDistanceToTraderZones] call ExileClient_util_world_isTraderZoneInRange) then
        {
            throw "No building within a radius of 1200m around the Headquarter!";
        };
        if (player call ExileClient_util_world_isInNonConstructionZone) then 
        {
            throw "You can't build in this restricted military area!";
        };
        if (player call ExileClient_util_world_isInConcreteMixerZone) then 
        {
            throw "You are too close to a concrete mixer zone!";
        };
        _minimumDistanceToSpawnZones = getNumber (missionConfigFile >> "CfgTerritories" >> "minimumDistanceToSpawnZones");
        if ([player, _minimumDistanceToSpawnZones] call ExileClient_util_world_isSpawnZoneInRange) then
        {
            throw "No building within a radius of 500m around spawn zones!";
        };

       ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    
       // PREVENT BUILDING NEAR MILITARY
       ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    
        _cantBuildNear = [
            "Land_Dome_Big_F","Land_Dome_Small_F",
            "Land_Barracks_ruins_F","Land_i_Barracks_V1_F",
            "Land_i_Barracks_V1_dam_F","Land_i_Barracks_V2_F",
            "Land_i_Barracks_V2_dam_F","Land_u_Barracks_V2_F",
            "Land_Mil_Guardhouse","Land_Barrack2",
            "Land_tav_Barrack2","Land_Mil_Barracks_L",
            "Land_Airport_Tower_F","Land_Hospital_main_F",
            "Land_Hospital_side1_F","Land_Hospital_side2_F",
            "Land_MilOffices_V1_F","Land_Hangar_F","Land_Cargo_House_V1_F",
            "Land_Cargo_House_V3_F","Land_Cargo_HQ_V1_F","Land_Cargo_HQ_V2_F",
            "Land_Cargo_HQ_V3_F","Land_Cargo_Patrol_V1_F",
            "Land_Cargo_Patrol_V3_F","Land_Cargo_Tower_V1_F",
            "Land_Cargo_Tower_V1_No1_F","Land_Cargo_Tower_V1_No2_F",
            "Land_Cargo_Tower_V1_No3_F","Land_Cargo_Tower_V1_No4_F",
            "Land_Cargo_Tower_V1_No5_F","Land_Cargo_Tower_V1_No6_F",
            "Land_Cargo_Tower_V1_No7_F","Land_Cargo_Tower_V3_F",
            "Land_Radar_F","Land_Radar_Small_F_Kit",
            //"Land_Cargo_House_V2_F",
            //"Land_Cargo_Patrol_V2_F",
            //"Land_Cargo_Tower_V2_F",
            //Namalsk Buildings
            //Military
            "Land_ns_Jbad_Mil_Guardhouse_winter",
            "Land_vys_budova_p1","Land_vys_budova_p2",
            "Land_budova1_winter","Land_budova2_winter",
            "Land_budova3_winter","Land_budova4_winter",
            "land_heliport","land_vys_antena",
            "land_fuelstation_w","Land_vez",
            "land_hlaska","Land_Mil_Barracks_i","Land_Mil_Barracks_L",
            "land_st_vez","land_x_vez_tex",
            //Airfield
            "Land_ns_Jbad_Mil_House","Land_ns_Jbad_Mil_ControlTower",
            "Land_ns_Jbad_Ind_Garage01","Land_ns_Jbad_A_Stationhouse",
            "Land_ns_jbad_hangar_2","Land_Ind_Workshop01_01",
            "Land_Ind_Workshop01_02","Land_Ind_Workshop01_04",
            //OTHERS
            "land_Mi8_Crashed","Land_Shed_Ind02",
            "Land_Fuel_tank_stairs",
            // Cherno IFA3
            "Land_A_TVTower_Base","Land_Mil_House","Land_Ind_MalyKomin","Land_A_Castle_Bergfrit","Land_jbad_hangar_withdoor",
            "Land_Budova4_in","Land_Strazni_vez","Land_WW2_Mil_Barracks_L_w","Land_WW2_Mil_Barracks_w","Land_LIB_Bunker_Mg",
            "Land_I44_Bunker_R67_Left","Land_I44_Bunker_R67_Right","WW2_JNS_Fortified_Nest_Big","Land_WW2_Bunker_Gun_L",
            "Land_WW2_Bunker_Gun_R","Land_WW2_Castle_w","Land_WW2_Fortification_Trench_Bunker_Big_w","Land_Army_hut2",
            "Land_Army_hut3_long","Land_Budova3"            
        ];
       
        // PREVENT BUILDING NEAR ROADS
        _NearRoad = (position player) nearRoads 20;
        _TooNearRoads = _NearRoad select 0;
        if (!isNil "_TooNearRoads") then { throw "ROAD"; };        
       
        // PREVENT BUILDING NEAR LUMBERJACK
        _AIBasepos = [10729, 5320,0]; 
        _MinRange = 250; // Min distance to AI Base
        _cantBuildDist = 200; // Min distance to military buildings
        _maxSafes = 3;         
             
        _nearAIBase = (getPosATL player) distance _AIBasepos;
        if (_nearAIBase < _MinRange) then { throw "AIBASE"; };     
        if ({typeOf _x in _cantBuildNear} count nearestObjects[player, _cantBuildNear, _cantBuildDist] > 0) then { throw "MILITARY"; };
 
        if(_itemClassName isEqualTo "Exile_Item_SafeKit") then
        {
            //Check if _maxSafes safes in range already
            _nearSafes = count (player nearObjects ["Exile_Container_Safe", 150]);
            if (_nearSafes >= _maxSafes) then { throw "MAXSAFES";  };          
        };         
       
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    
        
        if(_itemClassName isEqualTo "Exile_Item_Flag") then 
        { 
            _maximumNumberOfTerritoriesPerPlayer = getNumber (missionConfigFile >> "CfgTerritories" >> "maximumNumberOfTerritoriesPerPlayer");
            _numberOfTerritories = player call ExileClient_util_territory_getNumberOfTerritories;
            if (_numberOfTerritories >= _maximumNumberOfTerritoriesPerPlayer) then
            {
                throw "You have reached the maximum number of territories you can own.";
            };
            call ExileClient_gui_setupTerritoryDialog_show;
        }
        else 
        {
            [_itemClassName] call ExileClient_construction_beginNewObject;
        };
    }
    catch 
    {
        switch (_exception) do
        {
            case "MILITARY":
            {
                ["ErrorTitleAndText", ["You can't build in this restricted military area!"]] call ExileClient_gui_toaster_addTemplateToast;
            };
            case "ROAD":
            {
                ["ErrorTitleAndText", ["You can't build too close to roads!"]] call ExileClient_gui_toaster_addTemplateToast;
            };
            case "AIBASE":
            { 
                ["ErrorTitleAndText", ["The Lumberjack won't let you build within 250m around his lumber camp!"]] call ExileClient_gui_toaster_addTemplateToast;
            };
            
            case "MAXSAFES":
            { 
                ["ErrorTitleAndText", ["You're not allowed to have more than 3 safes!"]] call ExileClient_gui_toaster_addTemplateToast;
            };
            default
            {
                ["ErrorTitleAndText", ["Construction aborted, soldier!", _exception]] call ExileClient_gui_toaster_addTemplateToast;
            };    
        };            
    };
};
true

 

Share this post


Link to post
Share on other sites

0 answers to this question

There have been no answers to this question yet

Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.