Dwarfer

script Disable Building In Some Areas / Near Objects

45 posts in this topic

Hi,

Just a quick dirty way of having the ability to disable building in some location and near some objects.  This was not my original work however I have changed some things to add building and to get the messages working. I cannot remember who's work it was mildly based off so sorry for that.

create a new directroy in your mission folder something like fixes then create a file called ExileClient_object_item_construct.sqf with  the code from ExileClient_object_item_construct.sqf bellow

once you have done this open up your config.cpp and locate the CfgExileCustomCode section and add the following to it

*also now stops building in towns..

	// Disables Building in locations
	ExileClient_object_item_construct = "fixes\ExileClient_object_item_construct.sqf";

ExileClient_object_item_construct.sqf

https://github.com/Dwarfer/ExileModTweaks/blob/master/mpmissions/fixes/ExileClient_object_item_construct.sqf

 

Edited by Dwarfer
7 people like this

Share this post


Link to post
Share on other sites
Advertisement

Nicely done, much cleaner then my solution. i used same approves just in Exileclient_construction_thread.sqf

Edited by itsatrap

Share this post


Link to post
Share on other sites

Anybody know how i can add a function that checks if a object is over the road the road and denied it? because if you spawn the object not on the road but close to the road you can run on the road and build it there.. so i want that objects cant build on roads someone have an idea?

Could the following work?

 

private["_itemClassName","_cantBuildNear","_cantBuildRoad"];
_itemClassName = _this select 0;
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 "ConstructionVehicleWarning"; }
;
		if ((getPosATL player) call ExileClient_util_world_isTraderZoneNearby) then { throw "ConstructionTraderZoneWarning"; };
		if ((getPosATL player) call ExileClient_util_world_isSpawnZoneNearby) then { throw "ConstructionSpawnZoneWarning"; };

		//Stops Building In Towns
		_cnt = count nearestLocations [getPosATL player, ["NameVillage","NameCity","NameCityCapital"], 400];
		if (_cnt > 0 ) then { throw "ConstructionAbortedInformation"; };		
		
		/* PREVENT BUILDING NEAR CERTAIN TYPES OF BUILDING */
		_cantBuildNear = [
			"Land_Dome_Big_F",
			"Land_Dome_Small_F"
		];
		_cantBuildDist = 100;
		if ({typeOf _x in _cantBuildNear} count nearestObjects[player, _cantBuildNear, _cantBuildDist] > 0) then { throw "ConstructionAbortedInformation"; };
		
		/* PREVENT BUILDING ON ROADS */
		
		_cantBuildRoad = [
			"Exile_Item_CampFireKit",
			"Exile_Item_FloodLightKit",
			"Exile_Item_StorageCrateKit",
			"Exile_Item_WoodDoorwayKit",
			"Exile_Item_WoodDoorKit",
//			"Exile_Item_WoodDrawBridgeKit",
			"Exile_Item_WoodFloorKit",
			"Exile_Item_WoodFloorPortKit",
			"Exile_Item_WoodGateKit",
			"Exile_Item_WoodStairsKit",
			"Exile_Item_WoodSupportKit",
			"Exile_Item_WoodWallKit",
			"Exile_Item_WoodWallHalfKit",
			"Exile_Item_WoodWindowKit",
			"Exile_Item_WorkBenchKit",
			"Exile_Item_SafeKit",
			"Exile_Item_CamoTentKit"
		];
		
		if (isOnRoad getPosATL player) then {
		throw "ConstructionAbortedInformation"; 
		}
		else
		{
			if ( (typeOf _x in _cantBuildRoad) && _objOnRoad ) then { 
			throw "ConstructionAbortedInformation"; 
			}; 
		};
		
		if(_itemClassName isEqualTo "Exile_Item_Flag") then { throw "FLAG"; };
		[_itemClassName] call ExileClient_construction_beginNewObject;
	}
	catch 
	{
		if(_exception isEqualTo "FLAG")then
		{
			call ExileClient_gui_setupTerritoryDialog_show;
		}
		else
		{
			if(_exception isEqualTo "ConstructionAbortedInformation")then{
				[_exception,"Building Permit Denied"] call ExileClient_gui_notification_event_addNotification;
			}else{
				[_exception] call ExileClient_gui_notification_event_addNotification;
			};
		};	
	};
};
true

 

I overworked the part of "PREVENT BUILDING ON ROADS" - it would be nice if someone can take a look over it, thanks a lot.

Edited by AimRabbit

Share this post


Link to post
Share on other sites

Does this script still work? Do you need to replace "ConstructionTraderZoneWarning" etc. with the actual text you would like to appear?

Share this post


Link to post
Share on other sites

@FreakBrazil it's default like that

dude, i'm build a chernarus map.. so I build custom trades and safe since there was none...

so that its not working for me...

I add the script ExileClient_object_item_construct.sqf to block build base near to tows and its working... also close to safes...

but only like 100mts...

i wanna block a range of 1km only from safes....

 

I saw into config.cpp the setup

class CfgTerritories
{


    /**
     * Defines the minimum distance to safe zones / trader cities where players
     * cannot build territories
     */
    minimumDistanceToTraderZones = 1000;

 

 

But that its not working

Share this post


Link to post
Share on other sites
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

  • Recently Browsing   0 members

    No registered users viewing this page.