Jump to content

[WIP] Prevent Building in Cities, towns and villages (V1.0.5.1+)


Recommended Posts

I've only tested this on the latest Epoch build (1.0.5.1) with the latest Arma patch (1.63.112555)
 
Note: There are two versions of this script below, the first will check for all cities , towns and villages within a certain radius (500 meters) and prevent the player from building.  The second script lets you add the cities, towns and villages of your choice (the second script hasn't been tested yet, so it might not work, let me know if you try it and have success).  The code that I get you to copy and paste is simply my additions added to the existing 1.0.5.1 Epoch player_build.sqf script (so only follow this guide if you're using 1.0.5.1)

 

Edit: Asremix has also provided a solution to this script request here: 
 
SCRIPT 1: Works 100%
 
What this does:
It stops players from building in or near cities, towns and villages.
 
You will need: 
1. Your mission pbo and knowledge of editing and packaging it.
2. A /custom folder (or any folder you put custom scripts)
3. A copy of your Compiles.sqf already in  your custom folder.
NB: If you're using snap-build, you'll need to make the changes to your existing player_build.sqf which should already be in your custom scripts folder (this tutorial is assuming you don't though).
 
Instructions:
1. Create a file in  your custom scripts folder called player_build.sqf
2. Cut and Paste everything from here into your custom player_build.sqf
3. Open  your custom Compiles.sqf and look for the line starting:
player_build = compile preprocessFileLineNumbers ....
4. Change that entire line to:
player_build = compile preprocessFileLineNumbers "custom\player_build.sqf";
5. Repackage your mission file, upload and you're done.
 
For reference, the code blocks I added are: 

// NO building in cities or towns (if you don't mind people building in Villages, remove "NameVillage" etc)
_nearestCity = nearestLocations [getPos player, ["NameCityCapital","NameCity","NameVillage"],500];

AND 

// No building in Cities or Towns
if (count _nearestCity > 0) exitWith { DZE_ActionInProgress = false; systemChat ("You cannot build here!");};

I also added the private variable name to the private variable array. 
 
 

 

Script 2: Might not work, as I've not had time to test it yet
 

What this does: 
It stops players from building in or near a cities, towns and villages that you define in an array at the top of the player_build.sqf file.  A list of towns and cities can be found here: dayz.gamepedia.com/Towns_and_Cities
 
You will need: 
1. Your mission pbo and knowledge of editing and packaging it.
2. A /custom folder (or any folder you put custom scripts)
3. A copy of your Compiles.sqf already in  your custom folder.
NB: If you're using snap-build, you'll need to make the changes to your existing player_build.sqf which should already be in your custom scripts folder (this tutorial is assuming you don't though).
 
Instructions:
1. Create a file in  your custom scripts folder called player_build.sqf
2. Cut and Paste everything from here into your custom player_build.sqf
3. Open  your custom Compiles.sqf and look for the line starting:
player_build = compile preprocessFileLineNumbers ....
4. Change that entire line to:
player_build = compile preprocessFileLineNumbers "custom\player_build.sqf";
5. Repackage your mission file, upload and you're done.
 
For reference the code blocks I added are:  

// NO building in cities or towns (if you don't mind people building in Villages, remove "NameVillage" etc)
_ChkCities = ["Berezino","Chernogorsk","Staroye"]; // List here: dayz.gamepedia.com/Towns_and_Cities
_nearestCity = nearestLocations [getPos player, ["NameCityCapital","NameCity","NameVillage"],500];


AND 


// No building in Cities or Towns
if (_nearestCity in _ChkCities) exitWith { DZE_ActionInProgress = false; systemChat ("You cannot build here!");};

I also added the two private variable name to the private variable array

Link to comment
Share on other sites

I've only tested this on the latest Epoch build (1.0.5.1) with the latest Arma patch (1.63.112555)

 

Note: There are two versions of this script below, the first will check for all cities , towns and villages within a certain radius (500 meters) and prevent the player from building.  The second script lets you add the cities, towns and villages of your choice (the second script hasn't been tested yet, so it might not work, let me know if you try it and have success).  The code that I get you to copy and paste is simply my additions added to the existing 1.0.5.1 Epoch player_build.sqf script (so only follow this guide if you're using 1.0.5.1)

 

SCRIPT 1: Works 100%

 

 

 

Would this work if i setup my code like this?

// NO building in cities or towns (if you don't mind people building in Villages, remove "NameVillage" etc)
_nearestCity = nearestLocations [getPos player, ["NameCityCapital"],700];

_nearestCity = nearestLocations [getPos player, ["NameCity"],500];

_nearestCity = nearestLocations [getPos player, ["NameVillage"],300];

AND 

// No building in Cities or Towns
if (count _nearestCity > 0) exitWith { DZE_ActionInProgress = false; systemChat ("You cannot build here!");};
Link to comment
Share on other sites

 

Would this work if i setup my code like this?

// NO building in cities or towns (if you don't mind people building in Villages, remove "NameVillage" etc)
_nearestCity = nearestLocations [getPos player, ["NameCityCapital"],700];

_nearestCity = nearestLocations [getPos player, ["NameCity"],500];

_nearestCity = nearestLocations [getPos player, ["NameVillage"],300];

AND 

// No building in Cities or Towns
if (count _nearestCity > 0) exitWith { DZE_ActionInProgress = false; systemChat ("You cannot build here!");};

Haven't actually tried it but I believe you can do this haven't tested it though

// NO building in cities or towns (if you don't mind people building in Villages, remove "NameVillage" etc)
_nearestCity = nearestLocations [getPos player, ["NameCityCapital"],700];

_nearestCity = _nearestCity + nearestLocations [getPos player, ["NameCity"],500];

_nearestCity = _nearestCity + nearestLocations [getPos player, ["NameVillage"],300];

AND 

// No building in Cities or Towns
if (count _nearestCity > 0) exitWith { DZE_ActionInProgress = false; systemChat ("You cannot build here!");};
Link to comment
Share on other sites

 

This code from origins mod. 

_

 

Hijack my thread will you :p

 

Seriously though, can you explain to people how they'd add it to their scripts.  

I'm a little fussy when it comes to this kind of thing, I like to make it clear and concise :D

Link to comment
Share on other sites

@HellWalker. I'm not feeling great right now, so i'm going to give you a quick and dirty way of doing it.
I'll try and work on a cleaner version later... But basically, you can do this:

_nearestCapital = nearestLocations [getPos player, ["NameCityCapital"],700];
_nearestCity = nearestLocations [getPos player, ["NameCity"],500];
_nearestVillage = nearestLocations [getPos player, ["NameVillage"],300];

AND 

// No building in Cities or Towns
if (count _nearestCapital > 0) exitWith { DZE_ActionInProgress = false; systemChat ("You cannot build here!");};
if (count _nearestCity > 0) exitWith { DZE_ActionInProgress = false; systemChat ("You cannot build here!");};
if (count _nearestVillage > 0) exitWith { DZE_ActionInProgress = false; systemChat ("You cannot build here!");}; 

Don't forget to add the private variables to the private variable array at the top of the script.. They are:
_nearestVillage
 _nearestCity
_nearestCapital

Link to comment
Share on other sites

My custom script check from near objects 150 meters. And can add allow objects can build near.

 

 

Instructions:
1. Create a file in  your custom scripts folder called player_build.sqf
2. Cut and Paste everything from here into your custom player_build.sqf
3. Open  your custom Compiles.sqf and look for the line starting:
player_build = compile preprocessFileLineNumbers ....
4. Change that entire line to:
player_build = compile preprocessFileLineNumbers "custom\player_build.sqf";
5. Repackage your mission file, upload and you're done.
 
The code blocks.

//Find this

private ["...","_playerPos","_playerID","_player","_builOk","_stopGo"];

//...
//...
//...

//Next Find this 
call gear_ui_init;
closeDialog 1;


// Add this below

////////////START Check Near Objects////////////////////
_playerPos = getPosATL player;
_playerID =	getPlayerUID player;
_stopGo = false;

///////////Allow to build near this Objects.
_builOk = ["Land_Misc_deerstand"]; //Make like this  "Land_Misc_deerstand","Land_Misc_deerstand"
////////////////////////////////////
{

if (!(typeOf _x in _builOk)) then {
if ((["Land_",(typeOf _x),false] call fnc_inString)) exitWith { DZE_ActionInProgress = false; _stopGo = true;};
};
} forEach nearestObjects [_playerPos, ["House"], 150];  ///150 change this

if (_stopGo) 			exitWith { titletext ["You need to be at least 150 meters away from city.", "PLAIN DOWN"]; _stopGo = true; };
////////////END////////////////////

ysvYQWa.jpg

 

 

 

 

 

 

6U5RMOw.jpg

Link to comment
Share on other sites

Cheers Asremix.  I've added a link to your post at the top of this thread. I think between yours and mine, this is pertty much done.  People can choose which method works best for their needs and go with it.  Thanks again for your help :)

 

Edit: Sssh, don't tell anyone but I think I like your method better.  Mine was originally just to help walker with his building near cities question, but yours will also prevent players building on airfields etc, too :)

Link to comment
Share on other sites

So, just to undestand (since i am at work now and can't test it), the script from @Asremix will block player from building in any place 150m close to any object from the map? Any house, light pole, etc.. ?

///////////Allow to build near this Objects.
_builOk = ["TentStorage","TentStorageDomed","TentStorageDomed2", "VaultStorageLocked", "Hedgehog_DZ", "Sandbag1_DZ","BagFenceRound_DZ","TrapBear","Fort_RazorWire","WoodGate_DZ","Land_HBarrier1_DZ","Land_HBarrier3_DZ","Land_HBarrier5_DZ","Fence_corrugated_DZ","M240Nest_DZ","CanvasHut_DZ","ParkBench_DZ","MetalGate_DZ","OutHouse_DZ","Wooden_shed_DZ","WoodShack_DZ","StorageShed_DZ","Plastic_Pole_EP1_DZ","Generator_DZ","StickFence_DZ","LightPole_DZ","FuelPump_DZ","DesertCamoNet_DZ","ForestCamoNet_DZ","DesertLargeCamoNet_DZ","ForestLargeCamoNet_DZ","SandNest_DZ","DeerStand_DZ","MetalPanel_DZ","WorkBench_DZ","WoodFloor_DZ","WoodLargeWall_DZ","WoodLargeWallDoor_DZ","WoodLargeWallWin_DZ","WoodSmallWall_DZ","WoodSmallWallWin_DZ","WoodSmallWallDoor_DZ","LockboxStorageLocked","WoodFloorHalf_DZ","WoodFloorQuarter_DZ","WoodStairs_DZ","WoodStairsSans_DZ","WoodStairsRails_DZ","WoodSmallWallThird_DZ","WoodLadder_DZ","Land_DZE_GarageWoodDoor","Land_DZE_LargeWoodDoor","Land_DZE_WoodDoor","Land_DZE_GarageWoodDoorLocked","Land_DZE_LargeWoodDoorLocked","Land_DZE_WoodDoorLocked","CinderWallHalf_DZ","CinderWall_DZ","CinderWallDoorway_DZ","CinderWallDoor_DZ","CinderWallDoorLocked_DZ","CinderWallSmallDoorway_DZ","CinderWallDoorSmall_DZ","CinderWallDoorSmallLocked_DZ","MetalFloor_DZ","WoodRamp_DZ","GunRack_DZ","FireBarrel_DZ","WoodCrate_DZ","Scaffolding_DZ","MBG_Killhouse_1_InEditor","MBG_Killhouse_2_InEditor","MBG_Killhouse_3_InEditor","MBG_Killhouse_4_InEditor","MBG_Killhouse_5_InEditor","MBG_Killhouse_1_InEditor","MBG_Warehouse_InEditor","Land_MBG_ATC_Segment","MAP_leseni4x","MAP_leseni2x","WarfareBCamp","HeliHCivil","Land_fortified_nest_big_EP1","Land_Fire_barrel_burning","Land_CncBlock_Stripes","Land_Ind_TankSmall2_EP1","ASC_runway_YellowlightB","ASC_runway_BluelightB","Land_Campfire_burning"];

Link to comment
Share on other sites

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
  • Advertisement
  • Discord

×
×
  • Create New...