Jump to content

[REQUEST] Invulnerable bases when offline


Recommended Posts

Is there anyone who might know if it's possible to create a script that detects when a certain playerID is online and then makes structures inside the range of their associated plot pole vulnerable or DZE_GodModeBase no longer take effect?

It's hard running a PVP server which has some of the military vehicles added in when people really only attack other players bases when they're offline (bunch of damned cowards!), I'd like to make it so a players base is essentially only vulnerable when the player is online to defend it, assuming they're around, meaning if you really wanted to attack someones base, you'd have to wait until they're online, then either wait until they leave it to break in or just assault it as soon as you see them login. But regardless it would take more planning than just waiting until they log out to blow it away and raid it.

Link to comment
Share on other sites

private ["_owners","_name","_ownerOnline","_baseOwner","_admin"];

//List of owners
_baseOwner = "Allstar"; //Define a name for this area
_owners = ["163677830","101836870","89215878","91219206","80587142","124801158","5245250","146348806","72446278","65422790","80644550","65422790"]; //Array of owners of this area
_admin = ["","","",""];
_ownerOnline = false;
_name = name player;
// Check for Admin
if ((getPlayerUID player) in _admin) exitWith {
titleText [format ["Welcome, %1", _name], "PLAIN DOWN", 4]; // welcomes you with your name
};

// Check if the player IS one of the owners
if ((getPlayerUID player) in _owners) exitWith {
titleText [format ["Welcome, %1", _name], "PLAIN DOWN", 4]; // welcomes you with your name
};

// Check if one of the owners is online
{
diag_log format ["[Dome] Currently Processing admin with puid: %1", _x];
        if (_x call fnc_isPlayerOnline) exitWith {
            _ownerOnline = true;
diag_log format ["[Dome] base owner with puid: %1 is online", _x];
        };
} foreach _owners;

if (!_ownerOnline) exitWith {    // What happens if unauthorized players get into the dome
sleep 1;
titleText ["Approaching clan base! Do not harm this base while the owners are offline! Activity is logged! Consequences will be severe!!", "PLAIN DOWN", 4];
sleep 10;
titleText ["You have 5 seconds left to leave the Area, come back when owners are online!", "PLAIN DOWN", 3];
sleep 5;

//Disabling building and logging out for dome visitors
canbuild = false;

 player setDamage 1;
};

if (_ownerOnline) exitWith {
        canbuild = false;
		 
		titleText ["You entered a clan base!", "PLAIN DOWN", 4];
	};

And then add this function somewhere in your init.sqf (at the bottom for example)

fnc_isPlayerOnline = 
	{
		private ["_uid", "_isOnline"];
		_uid = _this;
		_isOnline = false;
		{
			if (isPlayer _x and {_uid == getPlayerUID _x}) exitWith {
				diag_log format ["[Dome] Found owner with uid = %1,", getPlayerUID _x];
				_isOnline = true;
			};
		} foreach playableUnits;
		_isOnline
	};

This is not all by me, but i don´t remember who is the initial author exactly... so to the one having created this cheers :)

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