Jump to content
EinQuantumXo

Need help with whitelist scripts...

Recommended Posts

Hey guys, I recently started mission making again and found three of the older scripts I used before very useful for my new mission, but I won't work. I don't get any errors in the server logs but players are still able to access vehicles which should be restricted. I would appreciate any help on this:

this is the first one called pilotCheck.sqf:

_AllowPilots = ["rhsusf_army_ocp_helipilot", "rhsusf_army_ocp_helicrew"];

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!\nJoin Us @ http://fox-command.de/";
			};
		};
	};
} else {
	waitUntil {sleep 0.5; !alive player};
};
};

second called foxlock.sqf:
 

/* Checks if the player attempting to get in pilot seat 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"]
  Use with care, [FOX] EiQuantumXo
*/

_SOAR = [/* Fox Command Unit
Last Updated: Friday, 31st Aug., 2018
Updated By: [FOX] EinQuantumXo, Julien] */
"765xxxxxxxxxxx294"/* xxx*/,
"765xxxxxxxxxxx938"/* xxx*/,
"765xxxxxxxxxxx896"/* xxx */
];

_AirRoles = ["rhsusf_army_ocp_helipilot", "rhsusf_army_ocp_helicrew"];

_RestrictAir = ["B_AH9_F", "O_Ka60_F", "RHS_UH60M__MEV_d", "RHS_AH64D", "RHS_CH_47F_light"];

while {true} do {
waitUntil {sleep 0.5; alive player};
if (!((getPlayerUID player) in _SOAR) && ((typeof player) in _AirRoles)) then {
	private "_v";
	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 FOX Pilots Only!\nJoin Us @ http://fox-command.de/";
			};
		};
	};
} else {
	waitUntil {sleep 0.5; !alive player};
};
};

third called foxlock2.sqf (isn't used actively):

/* 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"]
  Use with care, [FOX] EiQuantumXo, Julien]
*/

_SOAR = [/* Fox Command Unit
Last Updated: Friday, 31st Aug., 2018
Updated By: [FOX] EinQuantumXo, Julien] */
"765xxxxxxxxxxx294"/* xxx */,
"765xxxxxxxxxxx938"/* xxx */,
"765xxxxxxxxxxx896"/* xxx */
];


_RestrictLandSea = ["B_Hunter_HMG_F", "B_Hunter_RCWS_F", "B_SpeedBoat", "O_Ifrit_MG_F", "O_Ifrit_GMG_F", "O_SpeedBoat"];

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) or (gunner _v == player)) then {
				player action ["eject", _v];
				waitUntil {sleep 0.5; vehicle player == player};
				player action ["engineOff", _v];
				hint "Authorized FOX Drivers/Gunners Only!\nJoin Us @ http://fox-command.de/";
			};
		};
	};
} else {
	waitUntil {sleep 0.5; !alive player};
};
};

I call them through the init of every playable unit with this code:
 

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

 

Thanks for reading and helping,
greetings Quantum

Share this post


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

So it should look like this, right?
pilotCheck.sqf:


_AllowPilots = ["rhsusf_army_ocp_helipilot", "rhsusf_army_ocp_helicrew"];


if (!((typeof player) in _AllowPilots)) then {
	private "_v";
		_v = vehicle player;
		if (_v isKindOf "Helicopter" && !(_v isKindOf "ParachuteBase")) then {
			if (driver _v == player) then {
				player action ["eject", _v];
				player action ["engineOff", _v];
				hint "You must be a pilot to fly!\nJoin Us @ http://fox-command.de/";
			};
		};
	};

 

foxlock.sqf:


/* Checks if the player attempting to get in pilot seat 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"]
  Use with care, [FOX] EiQuantumXo
*/

_SOAR = [/* Fox Command Unit
Last Updated: Friday, 31st Aug., 2018
Updated By: [FOX] EinQuantumXo, Julien] */
"765xxxxxxxxxxx294"/* xxx*/,
"765xxxxxxxxxxx938"/* xxx*/,
"765xxxxxxxxxxx896"/* xxx */
];

_AirRoles = ["rhsusf_army_ocp_helipilot", "rhsusf_army_ocp_helicrew"];

_RestrictAir = ["B_AH9_F", "O_Ka60_F", "RHS_UH60M__MEV_d", "RHS_AH64D", "RHS_CH_47F_light"];

if (!((getPlayerUID player) in _SOAR) && ((typeof player) in _AirRoles)) then {
	private "_v";
		_v = vehicle player;
     _t = typeof _v;
		if (_t in _RestrictAir) then {
			if (driver _v == player) then {
				player action ["eject", _v];
				player action ["engineOff", _v];
				hint "Authorized FOX Pilots Only!\nJoin Us @ http://fox-command.de/";
			};
		};
	};

 

foxlock2.sqf (isn't used actively):


/* 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"]
  Use with care, [FOX] EiQuantumXo, Julien]
*/

_SOAR = [/* Fox Command Unit
Last Updated: Friday, 31st Aug., 2018
Updated By: [FOX] EinQuantumXo, Julien] */
"765xxxxxxxxxxx294"/* xxx */,
"765xxxxxxxxxxx938"/* xxx */,
"765xxxxxxxxxxx896"/* xxx */
];


_RestrictLandSea = ["B_Hunter_HMG_F", "B_Hunter_RCWS_F", "B_SpeedBoat", "O_Ifrit_MG_F", "O_Ifrit_GMG_F", "O_SpeedBoat"];

if !((getPlayerUID player) in _SOAR) then {
	private "_v","_t";
		_v = vehicle player;
     _t = typeof _v;
		if (_t in _RestrictLandSea) then {
			if ((driver _v == player) or (gunner _v == player)) then {
				player action ["eject", _v];
				player action ["engineOff", _v];
				hint "Authorized FOX Drivers/Gunners Only!\nJoin Us @ http://fox-command.de/";
			};
		};
	};

 

the init of every playable unit with this code:


this addEventHandler ["GetInMan", {this exec "pilotCheck.sqf"; exec "foxlock.sqf"; exec "foxlock2.sqf"; }

 

 

Share this post


Link to post
Share on other sites

Why are you using exec? That is for SQS. Use execVM instead.

https://community.bistudio.com/wiki/execVM

You are missing ] as well:

this addEventHandler ["GetInMan", {this exec "pilotCheck.sqf"; exec "foxlock.sqf"; exec "foxlock2.sqf"; }

// should be:

this addEventHandler ["GetInMan", {_this execVM "pilotCheck.sqf"; _this execVM "foxlock.sqf"; _this execVM "foxlock2.sqf";}];

You need to use _this as well, as shown above.

  • Like 2

Share this post


Link to post
Share on other sites

As mentioned by @davidoss and @HazJ, the GetInMan EH is your best bet.

 

The most important thing here is, that when entering a vehicle while holding the forward key,

the GetInMan EH will fire before the player gets control over the vehicle,

so the engine won't turn on and the vehicle won't start moving.

Same goes for the vehicle GetIn EH.

 

Quick example:

player addEventhandler ["GetInMan",{moveout player}];

 

Cheers

 

  • Like 3

Share this post


Link to post
Share on other sites

Thanks to everyone, 

6 hours ago, HazJ said:

Why are you using exec? That is for SQS. Use execVM instead.

https://community.bistudio.com/wiki/execVM

You are missing ] as well:


this addEventHandler ["GetInMan", {this exec "pilotCheck.sqf"; exec "foxlock.sqf"; exec "foxlock2.sqf"; }

// should be:

this addEventHandler ["GetInMan", {_this execVM "pilotCheck.sqf"; _this execVM "foxlock.sqf"; _this execVM "foxlock2.sqf";}];

You need to use _this as well, as shown above.

@HazJ well I don't know why I used exec instead of execVM as I used it before... so thanks for your hint :)

 

@Grumpy Old Man  If I got that:

5 hours ago, Grumpy Old Man said:

 


player addEventhandler ["GetInMan",{moveout player}];

 

I could use my code inside your "moveout player" in this case I would replace this

7 hours ago, EinQuantumXo said:

player action ["eject", _v]; player action ["engineOff", _v];

with "moveout player", right?

Sry for all these basic questions, it's just to many time since my last code in A3...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×