Jump to content

[Release] Restrict building near defined areas


BigEgg

Recommended Posts

So you currently have a rule that states you can not build within a certain distance of Military barracks etc..... Although making it a rule is easy, making it impossible is almost easier. No deleting bases or having to constantly be on the look out.

 

You will need:

Notepad++ (or a software of your choice)

init.sqf

player_build.sqf (can be found in your snap build folder)

 

 

Instructions:

 

Step one: 

 

Open up your init.sqf and add this to the very bottom:

 

ServerIllegalRadius = 500;
 
ServerNoBuildList = [ "Land_Mil_ControlTower",
"Land_SS_hangar",
"Land_Mil_Barracks_i",
"Land_Mil_Barracks",
"Land_budova4_in",
"HeliHEmpty" ];

Step two:

 

At the top of player_build.sqf add these to the end of the Private line:

"_posrad","_cntrad"

Step three:

 

Find this line in player_build.sqf:

if(!canbuild) then { _cancel = true; _reason = "Cannot build in a city."; };

Under it add:

 

_posrad = [player] call FNC_GetPos;
_cntrad = count (nearestObjects [_posrad, ServerNoBuildList, ServerIllegalRadius]);

 
if (_cntrad > 0) then {
_cancel = true;
_reason = format["- Building is restricted %1m near Trader Cities and Millitary Loot Areas", ServerIllegalRadius];
};
 
Hope it helps :)
Link to comment
Share on other sites

if like me, you have 2 different areas you don't allow building, you can just do this : 

 

init.sqf

ServerIllegalRadius = 500;
ServerIllegalRadius2 = 850;
ServerNoBuildList = [ "Land_Mil_ControlTower","Land_SS_hangar","Land_Mil_Barracks_i","Land_Mil_Barracks","Land_budova4_in"]; //Military
ServerNoBuildList2 = ["HeliHEmpty"];//Traders

Top of player_build.sqf

"_posrad","_cntrad","_cntrad2"

Find this in player_build.sqf : 

if(!canbuild) then { _cancel = true; _reason = "Cannot build in a city."; };

Put this under it : 

_posrad = [player] call FNC_GetPos;
_cntrad = count (nearestObjects [_posrad, ServerNoBuildList, ServerIllegalRadius]);
_cntrad2 = count (nearestObjects [_posrad, ServerNoBuildList2, ServerIllegalRadius2]);

 
if (_cntrad > 0) then {
_cancel = true;
_reason = format["- Building is restricted %1m near military areas", ServerIllegalRadius];
};
if (_cntrad2 > 0) then {
_cancel = true;
_reason = format["- Building is restricted %1m near trader cities", ServerIllegalRadius2];
};

Cheers for the brilliant idea BigEgg. 

Link to comment
Share on other sites

Works fantastic, thanks again BigEgg!

 

SUGGESTION: Add an area in the script for custom locations, like a blacklist.

 

I haven't tested this yet but add this to your init.sqf:

BlackZones = [[zonestary,100]];

Add this to player build where you added my other code:

if (BuildingBlacklist) then { 
_cancel = true; 
_reason = "- You are within a restricted building zone";
};

Then add this above initialized = true in your compiles.sqf:

{
private ["_pos", "_radius", "_trigger"];
_pos = _x select 0;
_radius = _x select 1;
_trigger = createTrigger ["EmptyDetector", _pos];
_trigger setTriggerArea [_radius, _radius, 0, false];
_trigger setTriggerActivation ["ANY", "PRESENT", true];
_trigger setTriggerType "SWITCH";
_trigger setTriggerStatements ["(vehicle player) in thisList", "BuildingBlacklist = true;", "BuildingBlackList = false;"];
true 
} count BlackZones;

Define the zones you want in the mission.sqm and then add them to the blacklist in your init.

 

Hope it helps :)

Link to comment
Share on other sites

  • 2 weeks later...

Works fantastic for me on my Napf server because I am not using Plot For Life. However, on my test server that I am using Plot For life on, it doesn't work.

 

My player_build.sqf is located in my A Plot For Life \ Action folder with other files including one called modular_build.sqf. In the compiles.sqf that comes with aP4L, is this first call : 

player_build =				compile preprocessFileLineNumbers "Custom\A_Plot_for_Life\Action\modular_build.sqf";

Then further down, player_build is called again like this

	} else {
		player_build =				compile preprocessFileLineNumbers "Custom\A_Plot_for_Life\Action\player_build.sqf";
	}; 

I have made the edit to the player_build.sqf as mentioned, but it still lets me place a pole down within 500m of a HeliHEmpty.

 

I did a Notepad++ search for all instances of :

if(!canbuild) then { _cancel = true; _reason = "Cannot build in a city."; };

and only the one came back, in player_build.sqf, where I have made the edit. Would I have to put this edit in modular_build.sqf and if so, where abouts?

Link to comment
Share on other sites

latest p4l version does not use player_build.sqf

 

you can use either

player_build_publish.sqf   (will check for can not build when u press space)

or 

player_build_plotCheck.sqf  (will check for can not build when u click mouse to build)

 

obs:

the line you tried to seach will be in player_build_publish.sqf except is not formated exactly the same way

Link to comment
Share on other sites

Is there an easy way to not allowed building near any Land_House or something like that? Don't want that my players can build near any town, city or loot place like small houses.

Tried Land_*, Land_House* but didn't work

You could try this but IDK if it is what you are looking for.

ServerNoBuildList = [
"Land_HouseV_1I4",
"Land_kulna", 
"Land_Ind_Workshop01_01", 
"Land_Ind_Garage01", 
"Land_Ind_Workshop01_02",
"Land_Ind_Workshop01_04", 
"Land_Ind_Workshop01_L", 
"Land_Hangar_2", 
"LAND_Ctirglav:",
"LAND_spital", 
"Land_hut06", 
"Land_stodola_old_open", 
"Land_A_FuelStation_Build",
"Land_A_GeneralStore_01a", 
"Land_A_GeneralStore_01", 
"Land_Farm_Cowshed_a", 
"Land_Farm_Cowshed_b", 
"Land_Farm_Cowshed_c", 
"Land_stodola_open", 
"Land_Barn_W_01", 
"land_r_housev2_04", 
"Land_Hlidac_budka", 
"Land_HouseV2_02_Interier", 
"Land_a_stationhouse", 
"Land_Mil_ControlTower", 
"Land_SS_hangar", 
"Land_A_Pub_01", 
"Land_HouseB_Tenement",
"land_a_hospital", 
"Land_Panelak", 
"Land_Panelak2",
"Land_Shed_Ind02", 
"Land_Shed_wooden", 
"Land_HouseBlock_A1_1", 
"Land_Shed_W01", 
"Land_HouseV_1I1", 
"Land_Tovarna2", 
"Land_rail_station_big", 
"Land_Ind_Vysypka", 
"Land_A_MunicipalOffice",
"Land_A_Office01", 
"Land_A_Office02", 
"land_barn_metal",
"Land_A_BuildingWIP",
"Land_Church_01", 
"Land_Church_03", 
"Land_Mil_Barracks_i", 
"MAP_Mil_Barracks_i", 
"Land_A_TVTower_Base", 
"land_mil_house", 
"Land_Misc_Cargo1Ao", 
"Land_Misc_Cargo1Bo",
"Land_ruin_01", 
"Land_wagon_box", 
"Land_HouseV2_04_interier", 
"Land_HouseV2_01A", 
"Land_KBud", 
"Land_A_Castle_Bergfrit", 
"Land_A_Castle_Stairs_A", 
"Land_A_Castle_Gate", 
"Land_Mil_Barracks", 
"MAP_Mil_Barracks", 
"Land_Mil_Barracks_L",
"Land_Barn_W_02", 
"Land_sara_domek_zluty", 
"Land_Rail_House_01", 
"Land_HouseV_2I", 
"Land_Misc_deerstand",
"Camp", 
"CampEast",
"CampEast_EP1", 
"MASH", 
"USMC_WarfareBFieldhHospital", 
"Land_HouseV_2L", 
"Land_HouseV_2T1",
"Land_houseV_2T2",
"Land_HouseBlock_B3", 
"Land_HouseBlock_B4",
"Land_HouseBlock_B5", 
"Land_HouseBlock_B6", 
"Land_HouseV2_01B", 
"land_housev_1l2", 
"land_misc_powerstation", 
"land_housev_3i3", 
"land_mil_guardhouse",
"Land_Ind_FuelStation_Build_EP1", 
"Land_ibr_FuelStation_Build",
"Land_Mil_ControlTower_EP1", 
"Land_Mil_hangar_EP1", 
"Land_Mil_Guardhouse_EP1", 
"Land_Mil_Repair_center_EP1",
"Land_Ind_PowerStation_EP1", 
"land_repair_center", 
"Land_Ind_TankBig", 
"Land_Ind_Coltan_Main_EP1", 
"Land_A_Mosque_big_hq_EP1", 
"Land_A_Mosque_big_addon_EP1", 
"Land_A_Mosque_big_wall_EP1", 
"Land_A_Mosque_small_1_EP1", 
"Land_A_Mosque_small_2_EP1", 
"Land_Mil_Barracks_i_EP1", 
"MAP_Mil_Barracks_i_EP1", 
"Land_fortified_nest_big_EP1", 
"Land_Mil_House_EP1",
"Land_Misc_Cargo1Bo_EP1", 
"Land_Mil_Barracks_EP1", 
"Land_Mil_Barracks_L_EP1", 
"Land_vez",
"Land_Ind_Oil_Pump_EP1", 
"Land_IndPipe2_bigL_L_EP1", 
"Land_Barrack2", 
"Land_House_C_1_EP1", 
"Land_House_C_2_EP1",
"Land_House_C_3_EP1", 
"Land_House_C_4_EP1", 
"Land_House_C_5_EP1", 
"Land_House_C_5_V2_EP1", 
"land_panelak3", 
"Land_House_C_5_V3_EP1",
"Land_House_C_5_V1_EP1", 
"Land_House_K_6_EP1",
"Land_House_C_9_EP1", 
"Land_House_C_10_EP1",
"Land_House_C_11_EP1",
"Land_House_C_12_EP1",
"Land_House_K_3_EP1", 
"Land_House_K_7_EP1",
"Land_House_L_7_EP1", 
"Land_House_L_6_EP1", 
"Land_House_K_8_EP1",
"Land_House_K_5_EP1", 
"Land_House_K_1_EP1",
"Land_House_L_1_EP1", 
"Land_House_L_3_EP1", 
"Land_House_L_4_EP1",
"Land_House_L_9_EP1", 
"LAND_ibr_bank", 
"Land_House_L_8_EP1", 
"Land_ibrhotel", 
"Land_MBG_Shanty_BIG", 
"land_mbg_apartments_big_04", 
"land_mbg_killhouse_4", 
"land_mbg_ger_estate_2", 
"land_mbg_ger_rhus_1", 
"land_mbg_garage_single_b",
"Land_dum_istan3_hromada2", 
"Land_budova4_in", 
"land_army_hut_int", 
"Land_army_hut3_long_int", 
"land_army_hut2_int", 
"land_ibr_hangar", 
"land_ind_pec_03", 
"land_ind_pec_03a", 
"Land_MBG_Police_Station", 
"Land_dum_mesto_in",
"Land_tovarna1", 
"Land_Ind_Garage01_EP1", 
"land_hut01",
"land_housev2_05", 
"land_hut02",
"land_hut04", 
"Land_Ind_Oil_Tower_EP1", 
"Land_ibr_terminal", 
"Land_A_Villa_EP1", 
"Land_A_Office01_EP1", 
"Land_A_Stationhouse_ep1",
"Land_ibrPanelak", 
"Land_ibrPanelak2", 
"Land_Ind_Expedice_1", 
"land_dum_istan2b", 
"Land_dum_olez_istan2", 
"Land_dum_olez_istan2_maly2", 
"land_smd_dum02", 
"land_dum_mesto", 
"land_deutshe", 
"land_stanice", 
"land_dum_mesto3_istan", 
"land_dum_istan2_03a", 
"land_nasypka", 
"Land_dum_istan3_pumpa",
"land_dum_istan3", 
"land_house_y",
"land_dum_istan4_inverse", 
"Land_duala_mini",
"Land_hut_old02", 
"land_dum_istan2_02",
"LAND_garaz_bez_tanku", 
"land_mbg_brickhouse_01", 
"land_bouda_garaz", 
"Land_majak_podesta", 
"Land_Shed_M02", 
"Land_sara_Domek_sedy",
"Land_dum_rasovna", 
"land_sara_domek_kovarna", 
"land_sara_domek_hospoda", 
"Land_leseni2x", 
"LAND_vokzal_big", 
"Land_dum_mesto2", 
"LAND_shopping_sab5",
"LAND_Zachytka", 
"LAND_hospoda", 
"LAND_Kiosk2", 
"Land_deutshe_mini", 
"LAND_shopping_sab1",
"LAND_skola", 
"LAND_konecna", 
"LAND_Tav_Panelak2", 
"LAND_Tav_panelak", 
"LAND_Tav_Panelak3", 
"LAND_Big_Panelak",
"LAND_Posta", 
"Land_GeneralStore_01a_PMC", 
"Land_ruin_01_PMC", 
"Land_Ruin_Cowshed_a_PMC", 
"Land_Ruin_Cowshed_b_PMC",
"Land_Ruin_Cowshed_c_PMC",
"Land_FuelStation_Build_PMC", 
"land_seb_vod_vez",
"land_seb_near_fac",
"land_seb_rozvodna", 
"land_seb_mine_maringotka", 
"Land_hut_old01", 
"land_st_vez", 
"Land_dulni_bs", 
"land_bunka",
"land_pozorovatelna", 
"land_panelova3", 
"land_vysoky2", 
"land_vysoky1",
"land_hotel_p2", 
"land_hotel_p1",
"land_trubice", 
"land_dlouhy1", 
"land_dlouhy2", 
"land_jzd_kr2",
"land_jzd_kr1", 
"land_jzd_stodola2", 
"land_jzd_stodola1", 
"land_jzd_silo_tes", 
"land_rozvodna", 
"land_jzd_4silka", 
"land_jzd_bezstrechy", 
"land_AII_last_floor", 
"land_AII_middle_floor", 
"land_x_skladiste_low_tex", 
"Land_budova4_winter", 
"land_domek_podhradi_1", 
"land_b_small1", 
"land_cast1", 
"land_vstup", 
"land_panelova", 
"land_garaze", 
"land_seb_bouda3", 
"Land_bouda2_vnitrek", 
"land_f_b2", 
"land_bud2", 
"land_senik", 
"land_zd_1", 
"Land_dum_ras", 
"land_kostelik_final_2122", 
"land_plynom", 
"land_seb_mine_main_opt", 
"land_seb_mine_near",
"land_x_vez_tex", 
"land_marsh1", 
"land_molovabud1", 
"land_f_b1", 
"land_seb_bouda1", 
"Land_sara_stodola", 
"land_cihlovej_dum_mini", 
"Land_hruzdum", 
"Land_cihlovej_dum_in", 
"land_sara_hasic_zbroj", 
"land_smd_hlaska", 
"land_smd_cihlovej_dum_mini", 
"land_smd_dum_istan4", 
"land_smd_dum_olez_istan2_open2", 
"land_smd_dum_olez_istan2_open", 
"land_smd_dum_olez_istan1_open", 
"land_smd_dum_istan3_hromada", 
"land_smd_army_hut2", 
"land_smd_ss_hangard_withdoor", 
"land_budova5", 
"land_smd_army_hut2_int 
"land_smd_strazni_vez", 
"land_smd_army_hut3_long_int", 
"land_smd_dum_mesto3_istan",
"Land_tav_Barrack2", 
"Land_tav_tovarna2", 
"Land_tav_Ind_Pec_03", 
"Land_Ind_Mlyn_01", 
"Land_Ind_Mlyn_03", 
"Land_Ind_SiloVelke_02", 
"Land_Ind_SiloVelke_01", 
"Land_Ind_Pec_03b", 
"Land_Ind_Expedice_3", 
"Land_tav_HouseV2_01B", 
"Land_tav_guardhouse", 
"Land_tav_houseblock_b1",
"Land_tav_houseblock_b4_in", 
"Land_tav_HouseV_2L", 
"LAND_Domek_zluty_BEZ", 
"Land_Bulding_r", 
"Land_dumruina_mini", 
"Land_statek_hl_bud", 
"LAND_HouseBlock_D1_ex1", 
"LAND_HouseBlock_D1", 
"LAND_hockej_stadion", 
"LAND_Big_Panelka", 
"LAND_small_Panelka", 
"Land_statek_brana",
"Land_Statek_kulna", 
"LAND_domek05", 
"LAND_ZalChata", 
"LAND_hotel_rivera2", 
"LAND_hotel_rivera1",
"LAND_bus_depo", 
"LAND_casino", 
"LAND_Parlament", 
"LAND_Galerie", 
"LAND_Stojan_Bus",
"LAND_dum_patrovy03", 
"LAND_Cinzak_long",
"LAND_Cinzak_corner2", 
"LAND_Cinzak_long_centr", 
"LAND_Cinzak_corner", 
"LAND_Cinzak_long_double", 
"LAND_Podloubi_double_low",
"LAND_Podloubi_End_Low_1", 
"LAND_Podloubi_End_Low_2", 
"LAND_Garaz_velka", 
"LAND_Hotel_Marcomio",
"LAND_shopping_sab2", 
"LAND_Nadrazi_sabina", 
"LAND_Autosalon", 
"LAND_Banka", 
"LAND_Bufet", 
"LAND_kanovka_budova", 
"LAND_kanovka_budova_snich",
"Land_afbarabizna", 
"Land_chilovej_dum_mini"];

 

Link to comment
Share on other sites

  • 2 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...