Jump to content

Expanding vehicle restrictions


Recommended Posts

RE: ArmA 3 Alpha / Invade & Annex

 

After having some ongoing issues with griefers on our "realism" units public server running the latest release of Invade & Annex, we have decided to restrict the use of all of the armed vehicles and helos to unit members only.

 

To this end, I have slightly modified the code in the file 'pilotCheck.sqf', and copied and repurposed in two 'rblock*.sqf' files to add restrictions for the armed land and sea vehicles. i.e.:

 

pilotCheck.sqf: (Modified!)

_AllowPilots = ["B_Helipilot_F", "O_helipilot_F"];

while {true} do {
    waitUntil {sleep 0.5; alive player};
    if (!((typeof player) in _AllowPilots)) then {
        private "_v";
        while {alive player} do {
            waitUntil {sleep 0.5; vehicle player != player};
            _v = vehicle player;
            if (_v isKindOf "Helicopter" && !(_v isKindOf "ParachuteBase")) then {
                if (driver _v == player) then {
                    player action ["eject", _v];
                    waitUntil {sleep 0.5; vehicle player == player};
                    player action ["engineOff", _v];
                    hint "You must be a pilot to fly!";
                };
            };
        };
    } else {
        waitUntil {sleep 0.5; !alive player};
    };
};

 

rblock1.sqf: (restrict AH-9/Ka60 to unit members only)

/* Checks if the player attempting to get in pilot seat of AH9 or Ka60 helicopter is both a pilot
   and is whitelisted in the _SOAR list of player UIDs. Add more UIDs to the list as follows 
   ["UID", "nextuid", "lastuid"]
*/

_SOAR = [
"76561198089126128",
"76561198030565436"];

_AirRoles = ["B_Helipilot_F", "O_helipilot_F"];

_RestrictAir = ["B_AH9_F", "O_Ka60_F"];

while {true} do {
	waitUntil {sleep 0.5; alive player};
	if (!((getPlayerUID player) in _SOAR) && ((typeof player) in _AirRoles)) then {
		private "_v","_t";
		while {alive player} do {
			waitUntil {sleep 0.5; vehicle player != player};
			_v = vehicle player;
                        _t = typeof _v;
			if (_t in _RestrictAir) then {
				if (driver _v == player) then {
					player action ["eject", _v];
					waitUntil {sleep 0.5; vehicle player == player};
					player action ["engineOff", _v];
					hint "Authorized UNIT Pilots Only!";
				};
			};
		};
	} else {
		waitUntil {sleep 0.5; !alive player};
	};
};

 

rblock2.sqf: (restrict armed land & sea vehicles to UNIT members only)

/* Checks if the player attempting to get in driver seat of armed vehicles
   is whitelisted in the _SOAR list of player UIDs. Add more UIDs to the list as follows 
   ["UID", "nextuid", "lastuid"]
*/

_SOAR = [
"76561198089126128",
"76561198030565436"];

_RestrictLandSea = ["B_Hunter_HMG_F", "B_Hunter_RCWS_F", "B_SpeedBoat", "O_Ifrit_MG_F", "O_Ifrit_GMG_F", "O_SpeedBoat", "B_Mk6"];
      
while {true} do {
	waitUntil {sleep 0.5; alive player};
	if !((getPlayerUID player) in _SOAR) then {
		private "_v,"_t"";
		while {alive player} do {
			waitUntil {sleep 0.5; vehicle player != player};
			_v = vehicle player;
                        _t = typeof _v;
			if (_t in _RestrictLandSea) then {
				if (driver _v == player) then {
					player action ["eject", _v];
					waitUntil {sleep 0.5; vehicle player == player};
					player action ["engineOff", _v];
					hint "Authorized UNIT Drivers/Gunners Only!";
				};
			};
		};
	} else {
		waitUntil {sleep 0.5; !alive player};
	};
};

 

.. and the INIT line for units now is: (formatting is used here only for clarity)

nul = [] execVM "pilotCheck.sqf";
nul = [] execVM "rblock1.sqf";
nul = [] execVM "rblock2.sqf";
this addMPEventHandler ["mprespawn",{nul = [] execVM "pilotCheck.sqf";
                                     nul = [] execVM "rblock1.sqf";
                                     nul = [] execVM "rblock2.sqf";}];

 

Now for the questions...

 

  1. Can these checks be combined into a single check per unit somehow?
    I've tried repeatedly, but have failed miserably each time. To be honest, I can't even get my head around the necessary logic and have it come out right.
     
  2. Is there a server or client-side penalty for duplicating want are essentially very similar functions? Would this penalty be better or worse than the penalty imposed by a more elaborate if-then-else structure to combine all of these functions?
     
  3. The above system works. Should I even be worried about changing them?

Thanks for your time

Edited by DJPorterNZ
Added the NEW ticket marker & moved to correct forum.
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
  • Forum Statistics

    11.1k
    Total Topics
    66.4k
    Total Posts
×
×
  • Create New...