Jump to content

[Addon] Plot Management "Last Maintained" Time


BigEgg

Recommended Posts

Hello everyone,

 

While bored, I thought of something that would be of convenience to players on my server:

cau3Yjr.jpg

 

There is, however, a limitation to this original version:

  • This requires the server to have a 5 day or 10 day maintenance period. In order to be accurately shown, your maintenance script must add 0.1 damage daily to objects on your server. View the below post to understand how my maintenance scripts work:

 

Understand that I made this quite specific for my server as I know how all of my queries line up. There may be some complications on your server if, for example, you have destructible bases.

 

This addon goes through every base object and retrieves the damage of each of them, then takes the highest damaged object and rounds it. A damage of 0.9 in this case shows us that the base was maintained 9 days ago. If a destructible object is damaged, it will adjust the time based upon that object which may cause some issues. I will later update this to exclude the objects in the DZE_GodModeBaseExclude variable, regardless of whether or not the server has this option turned on.

 

Install:

 

Copy/paste the following into the if (!isDedicated) section of your compiles.sqf, being sure to correct the path:

PlotObjects = compile preprocessFileLineNumbers "PATH\plotObjects.sqf";

 

Then, create a file called "plotObjects.sqf" and paste the following in it, being sure to save it in the path that you defined above:

private ["_range","_buildables","_near","_count","_numclr","_damage","_dmg","_dmgclr","_ctrl"];
disableSerialization;

_range = DZE_PlotPole select 0;
_target = (([player] call FNC_getPos) nearEntities ["Plastic_Pole_EP1_DZ",15]) select 0;
// Also count safes, lockboxes, vanilla buildables, tents and stashes against DZE_BuildingLimit
_buildables = DZE_maintainClasses + DZE_LockableStorage + ["DZ_buildables","DZ_storage_base"];
_near = nearestObjects [_target,_buildables,_range];
_count = count(_near);

_numclr = "#FFFFFF";

if (_count / DZE_BuildingLimit * 100 < 40) then {_numclr = "#00FF00";};
if (_count / DZE_BuildingLimit * 100 > 75) then {_numclr = "#FF0000";};

_damage = 0;
{
	_dmg = damage _x;
	if (_dmg > _damage) then {_damage = _dmg};
} count _near;

_damage = round(_damage * 10);

_dmgclr = "#00FF00";
if (_damage >= 5) then {_dmgclr = "#FFFF00";};
if (_damage >= 8) then {_dmgclr = "#FF0000";};

_ctrl = findDisplay 711194 displayCtrl 7014;
_ctrl ctrlSetStructuredText parseText format["<t color='%1'>%2 / %3</t><t color='#FFFFFF'> : </t><t color='%4'>Last Maintained %5 Day(s) Ago</t>", _numclr, _count, DZE_BuildingLimit, _dmgclr, _damage];

 

You are done :) I know there will probably be some issues, so I will help out people as much as I can!

 

I am working on a version that uses extDB to store the time directly so that this script will work globally.

 

Obvious creds for making this possible go to @Zupa

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...