Sign in to follow this  
Ambu5h

Set construction object limit, per item.

2 posts in this topic

This tiny adjustment allowes you to limit the numbers of specific items per territory.
Ive noticed EBM has some, way to huge, objects that players can build.
This allowes people to build incredibly stupid bases with over 20 militairy towers for instance.

In config.cpp CfgExileCustomCode add the following:

ExileClient_util_world_canBuildHere					 = "custom\buildlimit\ExileClient_util_world_canBuildHere.sqf";
ExileServer_object_construction_network_buildConstructionRequest	 = "custom\buildlimit\ExileServer_object_construction_network_buildConstructionRequest.sqf";


Create the following 2 files in custom\buildlimit\:

ExileClient_util_world_canBuildHere.sqf

Spoiler

/**
 * ExileClient_util_world_canBuildHere
 *
 * 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["_constructionConfigName", "_position", "_playerUID", "_result", "_requiresTerritory", "_canBePlacedOnRoad", "_allowDuplicateSnap", "_minimumDistanceToTraderZones", "_minimumDistanceToSpawnZones", "_minimumDistanceToOtherTerritories", "_maximumTerritoryRadius", "_positionObject", "_nearestFlags", "_radius", "_buildRights", "_territoryLevelConfigs", "_territoryLevelConfig", "_numberOfConstructionsAllowed"];
_constructionConfigName = _this select 0;
_constructionName = getText (configFile >> "CfgConstruction" >> _constructionConfigName >> "staticObject");
_position = _this select 1;
_playerUID = _this select 2;
_result = 0;
_requiresTerritory = getNumber (configFile >> "CfgConstruction" >> _constructionConfigName >> "requiresTerritory") isEqualTo 1;
_canBePlacedOnRoad = getNumber (configFile >> "CfgConstruction" >> _constructionConfigName >> "canBePlacedOnRoad") isEqualTo 1;
_allowDuplicateSnap = getNumber (configFile >> "CfgConstruction" >> _constructionConfigName >> "allowDuplicateSnap") isEqualTo 1;
_minimumDistanceToTraderZones = getNumber (missionConfigFile >> "CfgTerritories" >> "minimumDistanceToTraderZones");
_minimumDistanceToSpawnZones = getNumber (missionConfigFile >> "CfgTerritories" >> "minimumDistanceToSpawnZones");
_minimumDistanceToOtherTerritories = getNumber (missionConfigFile >> "CfgTerritories" >> "minimumDistanceToOtherTerritories");
_maximumTerritoryRadius = getNumber (missionConfigFile >> "CfgTerritories" >> "maximumRadius");

_maxConstructs =     [
                        [["Land_Sea_Wall_F","Land_Castle_01_tower_F","Land_Airport_Tower_F","Land_Cargo_Tower_V2_F","Land_FuelStation_Shed_F","Land_TentDome_F","Land_TentHangar_V1_F","Land_Radar_Small_F","Land_Dome_Big_F","Land_Hangar_F","Land_spp_Tower_F","Land_i_Barracks_V1_F","Land_Airport_01_hangar_F"], 1],
                        [["Land_Shed_Big_F","Land_Shed_Small_F"], 1],                                                                                                        // Metal sheds, which even tho it says "small" is not really small.
                        [["Land_i_House_Big_01_V2_F"], 1],                                                                                                                    // Big house seperately since you are always allowed to build atleast one imo
                        [["Land_i_Garage_V2_F"], 1],                                                                                                                        // Only one garage per base
                        [["Land_HelipadCivil_F"], 1],                                                                                                                        // Limit amount of helipads per base
                        [["Land_BagBunker_Large_F","Land_HBarrier_01_big_tower_green_F"], 1],                                                                                // Large bunkers
                        [["Exile_ConcreteMixer"], 1],                                                                                                                        // Only one mixer per base
                        [["Land_Atm_02_F","EBM_ATM"], 1],                                                                                                                    // Only one ATM type
                        [["Land_i_House_Small_03_V1_F"], 1],                                                                                                                // Semi large buildings
                        [["Land_TTowerSmall_1_F_Kit"], 2],                                                                                                                    // Transmission Tower
                        [["Land_i_Addon_03_V1_F","Land_i_Addon_03mid_V1_F"], 2],                                                                                            // Limit Tavern to either one of both parts or 2 of one type
                        [["Land_GH_Platform_F"], 2],                                                                                                                        // Heli platform
                        [["Land_Cargo_Patrol_V2_F","Land_Cargo_House_V2_F","Land_Research_house_V1_F","Land_Research_HQ_F"], 2],                                            // Militairy outposts
                        [["Land_Pier_small_F"], 2],                                                                                                                            // Pier
                        [["Land_LampAirport_F"], 2],                                                                                                                        // Airport lights.. way to big.
                        [["Land_HBarrierTower_F","Land_BagBunker_Small_F","Land_BagBunker_Tower_F","Land_BagBunker_01_small_green_F","Land_HBarrier_01_tower_green_F"], 3],    // Hbarrier bunkers
                        [["Land_IRMaskingCover_01_F","Land_IRMaskingCover_02_F"], 3],                                                                                        // Masking tents
                        [["Land_Cargo40_light_green_F","Land_cargo_house_slum_F","Land_Cargo20_sand_F","Land_Cargo20_military_green_F"], 4],                                 // Shipping Containers
                        [["MetalBarrel_burning_F"], 5]                                                                                                                        // Have alot of these and FPS dies becouse of the flame effect.
                    ];

try
{
    if ([_position, _minimumDistanceToTraderZones] call ExileClient_util_world_isTraderZoneInRange) then
    {
        throw 4;
    };
    if ([_position, _minimumDistanceToSpawnZones] call ExileClient_util_world_isSpawnZoneInRange) then
    {
        throw 5;
    };
    if ((AGLtoASL _position) call ExileClient_util_world_isInConcreteMixerZone) then
    {
        throw 11;
    };
    if ((AGLtoASL _position) call ExileClient_util_world_isInNonConstructionZone) then
    {
        throw 10;
    };
    if ((AGLtoASL _position) call ExileClient_util_world_isInRadiatedZone) then
    {
        throw 8;
    };
    if !(_canBePlacedOnRoad) then
    {
        if (isOnRoad [_position select 0, _position select 1, 0]) then
        {
            throw 3;
        };
    };
    if !(_allowDuplicateSnap) then
    {
        {
            _positionObject = (ASLtoAGL (getPosASL _x));
            if (_position isEqualTo _positionObject) then
            {
                throw 7;
            };
        }
        forEach (_position nearObjects ["Exile_Construction_Abstract_Static", 3]);
    };
    
    {
        _constructs = _x select 0;
        _maxnumber = _x select 1;
        
        if (_constructionName in _constructs) then
        {    
            _nearObjs = nearestObjects [_position, _constructs, _maximumTerritoryRadius];
            if (count _nearObjs >= _maxnumber) then
            { throw 69; };
        };
    }
    forEach _maxConstructs;
    
    if (_constructionConfigName isEqualTo "Flag") then
    {
        if ([_position, _minimumDistanceToOtherTerritories] call ExileClient_util_world_isTerritoryInRange) then
        {
            throw 2;
        };
    }
    else
    {
        _nearestFlags = (nearestObjects [_position, ["Exile_Construction_Flag_Static"], _maximumTerritoryRadius]);
        if !(_nearestFlags isEqualTo []) then
        {
            {
                _radius = _x getVariable ["ExileTerritorySize", -1];
                if (((AGLtoASL _position) distance (getPosASL _x)) < _radius) then
                {
                    _buildRights = _x getVariable ["ExileTerritoryBuildRights", []];
                    if (_playerUID in _buildRights) then
                    {
                        _territoryLevelConfigs = getArray (missionConfigFile >> "CfgTerritories" >> "prices");
                        _territoryLevelConfig = _territoryLevelConfigs select ((_x getVariable ["ExileTerritoryLevel", 0]) - 1);
                        _numberOfConstructionsAllowed = _territoryLevelConfig select 2;
                        if ((_x getVariable ["ExileFlagStolen", 0]) isEqualTo 1) then
                        {
                            throw 9;
                        };
                        if ((_x getVariable ["ExileTerritoryNumberOfConstructions", 0]) >= _numberOfConstructionsAllowed) then
                        {
                            throw 6;
                        };
                        throw 0;
                    };
                };
                throw 2;
            }
            forEach _nearestFlags;
        };
        if (_requiresTerritory) then
        {
            throw 1;    
        };
    };
}
catch
{
    _result = _exception;
};
_result

 

ExileServer_object_construction_network_buildConstructionRequest.sqf

Spoiler

/**
 * ExileServer_object_construction_network_buildConstructionRequest
 *
 * 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["_sessionID", "_parameters", "_objectClassName", "_objectPosition", "_playerObject", "_constructionConfig", "_canBuildHereResult", "_object"];
_sessionID = _this select 0;
_parameters = _this select 1;
_objectClassName = _parameters select 0;
_objectPosition = _parameters select 1;
try
{
    _playerObject = _sessionID call ExileServer_system_session_getPlayerObject;
    if (isNull _playerObject) then
    {
        throw "Player object is null!";
    };
    _constructionConfig = ("getText(_x >> 'previewObject') == _objectClassName" configClasses(configFile >> "CfgConstruction")) select 0;
    _canBuildHereResult = [configName _constructionConfig, (ASLtoAGL (ATLtoASL _objectPosition)), getPlayerUID _playerObject] call ExileClient_util_world_canBuildHere;
    
    switch (_canBuildHereResult) do
    {
        case 1:
        {
            throw "You are not in your territory.";
        };
        case 11:
        {
            throw "You are too close to a concrete mixer.";
        };
        case 10:
        {
            throw "Building is blocked here.";
        };
        case 2:
        {
            throw "You are inside enemy territory.";
        };
        case 8:
        {
            throw "You are in a contaminated zone.";
        };
        case 3:
        {
            throw "This cannot be placed on roads.";
        };
        case 5:
        {
            throw "You are too close to a spawn zone.";
        };
        case 4:
        {
            throw "You are too close to traders.";
        };
        case 6:
        {
            throw "Maximum number of objects reached.";
        };
        case 7:
        {
            throw "This snap location is already being used.";
        };
        case 69:
        {
            throw "You already have to many objects of this type or class.";
        };
    };
    _object = createVehicle[_objectClassName, _objectPosition, [], 0, "CAN_COLLIDE"];
    _object setPosATL _objectPosition;
    _object setVariable ["BIS_enableRandomization", false];
    _object setOwner (owner _playerObject);
    _object enableSimulationGlobal false;
    _object setVariable ["ExileOwnerUID", getPlayerUID _playerObject];
    _playerObject setVariable ["ExileConstructionObject", _object];
    [_object, _playerObject] call ExileServer_system_swapOwnershipQueue_add;
    [_sessionID, "constructionResponse", [netid _object]] call ExileServer_system_network_send_to;
}
catch
{
    [_sessionID, "toastRequest", ["ErrorTitleAndText", ["Construction aborted!", _exception]]] call ExileServer_system_network_send_to;
};
true

 

Edited by Ambu5h
  • Like 1

Share this post


Link to post
Share on other sites

so this will cap the build limit in metres or something like that? coz i hate sky bases that just ruin your server :D

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.