geekm0nkey

[RELEASE] NoMo Trees

13 posts in this topic

Been a while... But here is a very simple addition. What this does is give the admins an easy way to remove trees/bushes etc from a players territory without having to modify an SQF file and upload their mission again, as it's all handled at the database level. All you have to do is edit the record for any territory and change the last field [notrees] (to be added below) to a number other than 0. Setting this number to 1, will clear all trees/bushes etc to the radius the territory is currently set for. Any number higher than 1, will clear all trees/bushes etc to that range in meters.  Easy..

Installation

1st - SQL additions to the territory table.

ALTER TABLE `territory`
ADD `notrees` tinyint NOT NULL DEFAULT '0';

2nd - Override/Overwrite [won't explain how that's done, hopefully you know how that works by now.]

ExileServer_system_territory_database_load.sqf

Spoiler

/**
 * ExileServer_system_territory_database_load
 *
 * 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["_territoryID", "_data", "_id", "_owner", "_position", "_radius", "_level", "_flagTexture", "_flagStolen", "_flagStolenBy", "_lastPayed", "_buildRights", "_moderators", "_nomotrees", "_flagObject"];
_territoryID = _this;
_data = format ["loadTerritory:%1", _territoryID] call ExileServer_system_database_query_selectSingle;
_id = _data select 0;
_owner = _data select 1;
_name = _data select 2;
_position =
[
    _data select 3,
    _data select 4,
    _data select 5
];
_radius = _data select 6;
_level = _data select 7;
_flagTexture = _data select 8;
_flagStolen = _data select 9;
_flagStolenBy = _data select 10;
_lastPayed = _data select 11;
_buildRights = _data select 12;
_moderators = _data select 13;
_nomotrees = _data select 16;
_flagObject = createVehicle ["Exile_Construction_Flag_Static",_position, [], 0, "CAN_COLLIDE"];
if (_flagStolen isEqualTo 0) then
{
    _flagObject setFlagTexture _flagTexture;
};
ExileLocations pushBack _flagObject;
_flagObject setVariable ["ExileTerritoryName", _name, true];
_flagObject setVariable ["ExileDatabaseID", _id];
_flagObject setVariable ["ExileOwnerUID", _owner, true];
_flagObject setVariable ["ExileTerritorySize", _radius, true];
_flagObject setVariable ["ExileTerritoryBuildRights", _buildRights, true];
_flagObject setVariable ["ExileTerritoryModerators", _moderators, true];
_flagObject setVariable ["ExileTerritoryLevel", _level, true];
_flagObject setVariable ["ExileTerritoryLastPayed", _lastPayed];
_flagObject call ExileServer_system_territory_maintenance_recalculateDueDate;
_flagObject setVariable ["ExileTerritoryNumberOfConstructions", _data select 15, true];
_flagObject setVariable ["ExileRadiusShown", false, true];
_flagObject setVariable ["ExileFlagStolen",_flagStolen,true];
_flagObject setVariable ["ExileFlagTexture",_flagTexture];
if (getNumber(missionConfigFile >> "CfgVirtualGarage" >> "enableVirtualGarage") isEqualTo 1) then
{
    _data = format["loadTerritoryVirtualGarage:%1", _territoryID] call ExileServer_system_database_query_selectFull;
    _flagObject setVariable ["ExileTerritoryStoredVehicles", _data, true];
};

if !(_nomotrees isEqualTo 0) then
{
    if (_nomotrees > 1) then
    {
        _terrainobjects = nearestTerrainObjects [_position, ["TREE", "SMALL TREE", "BUSH"], _nomotrees];
        {hideObjectGlobal _x} foreach _terrainobjects;
    }
    else
    {
        _terrainobjects = nearestTerrainObjects [_position, ["TREE", "SMALL TREE", "BUSH"], _radius];
        {hideObjectGlobal _x} foreach _terrainobjects;
    };
};
true

3rd - Exile.ini change. [Find the following section and replace it completely with one given below]

Spoiler

[loadTerritory]
SQL1_1 = SET @connector = ?;
SQL2_1 = SELECT id,owner_uid,name,position_x,position_y,position_z,radius,level,flag_texture,flag_stolen,flag_stolen_by_uid,last_paid_at,build_rights,moderators,deleted_at,(SELECT COUNT(*)FROM construction c WHERE c.territory_id = @connector),notrees FROM territory WHERE id = @connector
Number Of Inputs = 1
SQL1_INPUTS = 1
OUTPUT = 1,2-STRING,3-STRING,4,5,6,7,8,9-STRING,10,11-STRING,12-DateTime_ISO8601,13,14,15,16,17

That's all, by default the notrees will all be set to 0, if a player wants to clear out trees/bushes just set it to a number other than 0 as described above. A few benefits to doing things this way.. 1st, should a base be removed or deleted, the trees are put back automatically, 2nd, should you not want players to put flags inside of trees? just set the default value in the SQL to 2, and now no flags in trees.

Edited by geekm0nkey
  • Like 5

Share this post


Link to post
Share on other sites
Advertisement

Hmhm after installing and testing i saw that the database entry in the table territory is not written after building a base.

 

21:33:14 Error in expression <llExtension _query);
(_result select 1) select 0>
21:33:14   Error position: <select 0>
21:33:14   Error Generic error in expression
21:33:14 File exile_server\code\ExileServer_system_database_query_insertSingle.sqf, line 16
21:33:14 Error in expression <llExtension _query);
(_result select 1) select 0>
21:33:14   Error position: <select 0>
21:33:14   Error Generic error in expression
21:33:14 File exile_server\code\ExileServer_system_database_query_insertSingle.sqf, line 16

 

Share this post


Link to post
Share on other sites
5 hours ago, El Rabito said:

Hmhm after installing and testing i saw that the database entry in the table territory is not written after building a base.

 


21:33:14 Error in expression <llExtension _query);
(_result select 1) select 0>
21:33:14   Error position: <select 0>
21:33:14   Error Generic error in expression
21:33:14 File exile_server\code\ExileServer_system_database_query_insertSingle.sqf, line 16
21:33:14 Error in expression <llExtension _query);
(_result select 1) select 0>
21:33:14   Error position: <select 0>
21:33:14   Error Generic error in expression
21:33:14 File exile_server\code\ExileServer_system_database_query_insertSingle.sqf, line 16

 

You are correct, let me update the original post, I later determined that, the insert overwrite was not necessary as when created, the notrees field auto populates with 0 "as it should". Also the createterritory change for the INI is also no longer necessary.

Edited by geekm0nkey
  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, Brenner said:

works on extDB3?

I don't use extDB3 (never really saw the benefit) but my changes should work in any existing overwrite you have that use the extDB3 protocol.

Share this post


Link to post
Share on other sites
29 minutes ago, geekm0nkey said:

I don't use extDB3 (never really saw the benefit) but my changes should work in any existing overwrite you have that use the extDB3 protocol.

Great, definitely will try it out, this should be quite useful for building bases deep in Tanoa jungle. Thanks :)

Share this post


Link to post
Share on other sites

So im using exad for my VG and was wondering if i merged this correctly. I added "_nomotrees" into the private array, i added the _data select 16 portion, And i added the if statement under the ExileFlagTexture variable.

/**
 * ExileServer_system_territory_database_load
 *
 * 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["_territoryID","_data","_id","_owner","_position","_radius","_level","_flagTexture","_flagStolen","_flagStolenBy","_lastPayed","_buildRights","_nomotrees","_moderators","_flagObject"];
_territoryID = _this;
_data = format ["loadTerritory:%1", _territoryID] call ExileServer_system_database_query_selectSingle;
_id = _data select 0;
_owner = _data select 1;
_name = _data select 2;
_position = 
[
    _data select 3,
    _data select 4,
    _data select 5
];
_radius = _data select 6;
_level = _data select 7;
_flagTexture = _data select 8;
_flagStolen = _data select 9;
_flagStolenBy = _data select 10;
_lastPayed = _data select 11;
_buildRights = _data select 12;
_moderators = _data select 13;
_nomotrees = _data select 16;
_flagObject = createVehicle ["Exile_Construction_Flag_Static",_position, [], 0, "CAN_COLLIDE"];
if (_flagStolen isEqualTo 0) then 
{
    _flagObject setFlagTexture _flagTexture;
};
ExileLocations pushBack _flagObject;
_flagObject setVariable ["ExileTerritoryName", _name, true];
_flagObject setVariable ["ExileDatabaseID", _id];
_flagObject setVariable ["ExileOwnerUID", _owner, true];
_flagObject setVariable ["ExileTerritorySize", _radius, true];
_flagObject setVariable ["ExileTerritoryBuildRights", _buildRights, true];
_flagObject setVariable ["ExileTerritoryModerators", _moderators, true];
_flagObject setVariable ["ExileTerritoryLevel", _level, true];
_flagObject setVariable ["ExileTerritoryLastPayed", _lastPayed];
_flagObject call ExileServer_system_territory_maintenance_recalculateDueDate;
_flagObject setVariable ["ExileTerritoryNumberOfConstructions", _data select 15, true];
_flagObject setVariable ["ExileRadiusShown", false, true];
_flagObject setVariable ["ExileFlagStolen",_flagStolen,true];
_flagObject setVariable ["ExileFlagTexture",_flagTexture];
if (getNumber(missionConfigFile >> "CfgVirtualGarage" >> "enableVirtualGarage") isEqualTo 1) then
{
    _data = format["loadTerritoryVirtualGarage:%1", _territoryID] call ExileServer_system_database_query_selectFull;
    _flagObject setVariable ["ExileTerritoryStoredVehicles", _data, true];
};

if !(_nomotrees isEqualTo 0) then
{
    if (_nomotrees > 1) then
    {
        _terrainobjects = nearestTerrainObjects [_position, ["TREE", "SMALL TREE", "BUSH"], _nomotrees];
        {hideObjectGlobal _x} foreach _terrainobjects;
    }
    else
    {
        _terrainobjects = nearestTerrainObjects [_position, ["TREE", "SMALL TREE", "BUSH"], _radius];
        {hideObjectGlobal _x} foreach _terrainobjects;
    };
};

////////////////////////
/////  ExAd START  /////
////////////////////////
_vehicles = format ["loadTerritoryVehicles:%1", _territoryID] call ExileServer_system_database_query_selectFull;
_flagObject setVariable ["ExAdVGVeh", _vehicles, true];
////////////////////////
/////   ExAd END    /////
////////////////////////

true

Edited by KyleGD
  • Like 1

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.