kahna 13 Posted June 12, 2013 I'm looking for something that can either restrict vehicle usage to unit members by Player ID or prevents access to a certain area if you're not on the white-list (vehicle bays for example). We have a public server that runs Insurgency and we like to invite the public in to play with us quasi-realism style with emphasis on teamwork (running Hunter convoys, air assaulting, marking targets for CAS, etc). The biggest problems we have are unauthorized pilots hopping into helicopters and either killing their passengers (inexperienced flyers crashing and/or AA fire because they don't know the safe routes to fly) or abandoning Heli's in the field (not a problem with low abandonment timers, but sometimes the pilot does over-watch in small operations and I don't want them to have to run back to their chopper every 2 minutes to reset the timer). I've already got a PilotCheck script ready, but I'd like unit members to have the option to fly the aircraft (if the pilot dies) which is why I'm looking for a Player ID based script. Another thing is Hunters griefing in the spawn (or people driving them off into the great blue yonder never to be seen again). I can easily stop it with barriers and such, but it gets unrealistic looking and GrenadeStop.sqf won't stop their turrets from functioning so I'd rather just have authorized drivers being able to drive them and gain access to them. If there isn't a working whitelist script out there, anything that you guys could suggest would be helpful! The goal is cut down on the need for an admin being on all of the time. Right now I'm using a combination of GrenadeStop, PilotCheck and the Insurgency TK punishment (5 min jail time, since only vehicles can deliberately kill at spawn in this manner - no more Arma 2 Grenade/Gear button accidents!). Thanks much! Share this post Link to post Share on other sites
djporternz 27 Posted June 12, 2013 We implemented a system just like this when we were running the Ahoy World Domination mission for this very reason :) I can take no credit for the original code (send that to the Ahoy World coders) or even the first modifications, but I have looked after the code for the last few iterations. We based our system on a modified pilotCheck.sqf: /* ::: ::: ::: ::: ::: ::: :+: :+: :+: :+: :+: :+: +:+ +:+ +:+ +:+ +:+ +:+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ #+# #+# #+# #+# #+# #+# ### ### ### ### ### ### | AHOY WORLD | ARMA 3 ALPHA | STRATIS DOMI VER 2.7 | Creating working missions of this complexity from scratch is difficult and time consuming, please credit [url]http://www.ahoyworld.co.uk[/url] for creating and distibuting this mission when hosting! This version of Domination was lovingly crafted by Jack Williams (Rarek) for Ahoy World! */ _AllowPilots = ["B_Helipilot_F", "O_helipilot_F", "CAF_439_Pilot"]; 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://2rbmilsim.us/"; }; }; }; } else { waitUntil {sleep 0.5; !alive player}; }; }; Our changes here simply extracted the allowed roles out into the _AllowPilots array. The rest is unchanged except for the hint message. Added to this are the files rblock.sqf and rblock2.sqf: // FILE: rblock.sqf /* 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"] Use with care, PV2 Rivers [2nd RB] */ _SOAR = [/* 2nd Ranger Battalion Last Updated: Thursday, 23rd May, 2013 Updated By: PFC Porter, David [2nd RB] */ "76561198089xxxxxx"/* PFC Porter, David [2nd RB] */, "76561198089xxxxxy"/* db */]; _AirRoles = ["B_Helipilot_F", "O_helipilot_F", "CAF_439_Pilot"]; _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"; 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 2nd RB Pilots Only!\nJoin Us @ http://2rbmilsim.us/"; }; }; }; } else { waitUntil {sleep 0.5; !alive player}; }; }; // FILE: rblock2.sqf /* 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, PV2 Rivers [2nd RB] */ _SOAR = [/* 2nd Ranger Battalion Last Updated: Thursday, 23rd May, 2013 Updated By: PFC Porter, David [2nd RB] */ "76561198089xxxxxx"/* PFC Porter, David [2nd RB] */, "76561198089xxxxxy"/* db */]; _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 2nd RB Drivers/Gunners Only!\nJoin Us @ http://2rbmilsim.us/"; }; }; }; } else { waitUntil {sleep 0.5; !alive player}; }; }; To use this code, add the following init line to any playable unit nul = [] execVM "pilotCheck.sqf"; nul = [] execVM "rblock.sqf"; nul = [] execVM "rblock2.sqf"; this addMPEventHandler ["mprespawn",{nul = [] execVM "pilotCheck.sqf"; nul = [] execVM "rblock.sqf"; nul = [] execVM "rblock2.sqf";}]; Current Restriction Rules: Only Pilots can fly! Must be in a Pilot slot in the mission. {Currently: MH-9 / Ka60_Unarmed} Only UNIT Pilots can fly CAS aircraft {Currently: AH-9 / Ka60} Any Role Assignment may drive unarmed vehicles {Currently: Hunter / Ifrit / Quadbike / Offroad / Assualtboat / Lifeboat / Rubberboat} Only UNIT Members can be Driver/Gunner in armed vehicles {Currently: Hunter HMG/GMG / Ifrit MG/GMG / Speedboat} ATM no distinction is made between BLUFOR / OPFOR roles or vehicles (i.e. Captured serviceable vehicles and helicopters can be used by units of either side if allowed by the other restrictions.) To be honest, this method feels a bit kludgy, but I haven't found a better way yet. Share this post Link to post Share on other sites
kahna 13 Posted June 13, 2013 Works great, thanks a lot Porter! I appreciate you taking the time to copy over and type all of this up. Now begins the long process of adding player ID's! Share this post Link to post Share on other sites
Andyj1 22 Posted June 13, 2013 Hi I have also been looking for a script like this so thx for the time doing this. I have a problem.. I have tested this just as you have it, and it lets me in as a pilot without changing anything. Also I am unsure of how to ad extra id's when I can get it to work. Any help much appreciated. Kindest regards :) Share this post Link to post Share on other sites
-sc- 10 Posted July 8, 2013 (edited) Did you by chance pull this from the SOTG Edit of Ahoy Worlds Invade & Annex? If so, I take credit for this modification :) the code is eerily similar to my modified pilotcheck.sqf with slight differences. Edit: If interested, I have another vehicle restriction script I wrote that uses a trigger to check when a player enters a vehicle, if that vehicle matches a defined list of classnames & UID array, it then boots them out with a hint. If they passed the check, they are greeted with a welcome hint. Also: The current modified version running on our SOTG Edit works for co-pilot seats as well (I had an issue where people could take control as co-pilot without the pilot unlocking controls, aka everyone flying stuff they should not be.) We use this in order to restrict Attack Helicopters to Members/Friends only, as every Joe schmoe jumps into them if they can. Edited July 8, 2013 by -sc- Share this post Link to post Share on other sites
kahna 13 Posted July 9, 2013 I'm currently using crewCheck by SaMatra, in one of my other threads around here, which does the job nicely. To get around the co-pilot issue I've just locked co-pilot and CAS gunner seats to pilots only. I don't really use CAS in the public maps much at this point and the Mi-48 is the only one I use which is white listed and cannot be flown from the gunner seat nor can you move up from it, so I'm good for now. But seriously, check out SaMatra's script, it's awesome for restricting vehicle slots by player class. Share this post Link to post Share on other sites
SOFTACT 10 Posted October 16, 2013 I am looking for a way to whitelist helicopters and planes on my server. This way does not seem to work :/ Share this post Link to post Share on other sites
jacmac 2 Posted October 16, 2013 I'm looking for something that can ... prevents access to a certain area if you're not on the white-list (vehicle bays for example). This is a good idea and very easy to do. For one thing, managing an area trigger is a whole lot less processing than having each player check every half second if they are in a vehicle. Another way to do this would be addEventHandler, where non-whitelisted players get an event handler at JIP or mission start to boot them from non-qualified vehicles if they get in the driver or pilot/co-pilot position. Players that are authorized simply don't get the event handler in the first place. I should add that I hate these type of servers where access is restricted, but I understand why admins do it. Share this post Link to post Share on other sites
SOFTACT 10 Posted October 16, 2013 This is a good idea and very easy to do. For one thing, managing an area trigger is a whole lot less processing than having each player check every half second if they are in a vehicle. Another way to do this would be addEventHandler, where non-whitelisted players get an event handler at JIP or mission start to boot them from non-qualified vehicles if they get in the driver or pilot/co-pilot position. Players that are authorized simply don't get the event handler in the first place.I should add that I hate these type of servers where access is restricted, but I understand why admins do it. Could you link me anywhere that i could get this? Share this post Link to post Share on other sites
jacmac 2 Posted October 16, 2013 here is a very authoritarian, yet zen like example. You can, of course, adjust the logic to permit some vehicle type if you want to be less restrictive. //Assuming WhiteListArray contains a list of player names that are allowed to enter vehicles if (isPlayer and !(WhiteListArray find (name vehicle player)) { player addEventHandler ["GetOut", { if ((vehicle player) != player and alive player) { player action ["eject", vehicle player]; }; hint "You aren't authorized to be outside of yourself unless you are dead."; }]; }; Share this post Link to post Share on other sites
SOFTACT 10 Posted October 16, 2013 here is a very authoritarian, yet zen like example. You can, of course, adjust the logic to permit some vehicle type if you want to be less restrictive. //Assuming WhiteListArray contains a list of player names that are allowed to enter vehicles if (isPlayer and !(WhiteListArray find (name vehicle player)) { player addEventHandler ["GetOut", { if ((vehicle player) != player and alive player) { player action ["eject", vehicle player]; }; hint "You aren't authorized to be outside of yourself unless you are dead."; }]; }; Could you go in more depth? Sorry kinda new. Trying to whitelist a Helicopter Share this post Link to post Share on other sites
jacmac 2 Posted October 17, 2013 OK, I got home and tested the idea out and this works. It's heavy handed, but it will give you an idea on how to deal with the situation. You would need to manage the variable WhiteListArray as a public variable and make sure that the player got the variable before adding the event handlers to the vehicles in an MP mission. This means something like WhiteListArray = []; waituntil {WhiteListArray != []}; You need a server side script that publicVariable's WhiteListArray on player connected. The downside I can see is having to manage users in a static mission file; who wants to do that? You can also use player UIDs with 'getPlayerUID player' instead of 'name vehicle player' which is probably slightly better in making it difficult to bypass. Create an init.sqf file for a test mission and add this code: waitUntil {!isNull player}; WhiteListArray = []; sleep 1; systemChat name vehicle player; //Assuming WhiteListArray contains a list of player names that are allowed to enter vehicles { if (WhiteListArray find (name vehicle player) == -1) then { _x addEventHandler ["GetIn", { if (((vehicle player) != player) and (alive player)) then { player action ["eject", vehicle player]; }; hint "You aren't authorized."; }]; }; } foreach entities "AllVehicles"; Then try: waitUntil {!isNull player}; WhiteListArray = ["Your playername"]; sleep 1; systemChat name vehicle player; //Assuming WhiteListArray contains a list of player names that are allowed to enter vehicles { if (WhiteListArray find (name vehicle player) == -1) then { _x addEventHandler ["GetIn", { if (((vehicle player) != player) and (alive player)) then { player action ["eject", vehicle player]; }; hint "You aren't authorized."; }]; }; } foreach entities "AllVehicles"; Share this post Link to post Share on other sites
SOFTACT 10 Posted October 17, 2013 OK, I got home and tested the idea out and this works. It's heavy handed, but it will give you an idea on how to deal with the situation. You would need to manage the variable WhiteListArray as a public variable and make sure that the player got the variable before adding the event handlers to the vehicles in an MP mission. This means something like WhiteListArray = []; waituntil {WhiteListArray != []}; You need a server side script that publicVariable's WhiteListArray on player connected. The downside I can see is having to manage users in a static mission file; who wants to do that? You can also use player UIDs with 'getPlayerUID player' instead of 'name vehicle player' which is probably slightly better in making it difficult to bypass. Create an init.sqf file for a test mission and add this code: waitUntil {!isNull player}; WhiteListArray = []; sleep 1; systemChat name vehicle player; //Assuming WhiteListArray contains a list of player names that are allowed to enter vehicles { if (WhiteListArray find (name vehicle player) == -1) then { _x addEventHandler ["GetIn", { if (((vehicle player) != player) and (alive player)) then { player action ["eject", vehicle player]; }; hint "You aren't authorized."; }]; }; } foreach entities "AllVehicles"; Then try: waitUntil {!isNull player}; WhiteListArray = ["Your playername"]; sleep 1; systemChat name vehicle player; //Assuming WhiteListArray contains a list of player names that are allowed to enter vehicles { if (WhiteListArray find (name vehicle player) == -1) then { _x addEventHandler ["GetIn", { if (((vehicle player) != player) and (alive player)) then { player action ["eject", vehicle player]; }; hint "You aren't authorized."; }]; }; } foreach entities "AllVehicles"; How do indicate for driver and copilot for i can have others enter the chopper? Im getting it to work, just cant figure out the eventhandler thing. from what they say: Passed array: [vehicle, position, unit] Share this post Link to post Share on other sites
jacmac 2 Posted October 17, 2013 So instead of if (((vehicle player) != player) and (alive player)) then { You would do if (((vehicle player) != player) and (alive player) and ((_this select 1) != "cargo")) then { If you want players to be able to enter a vehicle in a cargo position. Keep in mind that if the game allows switching positions from cargo to pilot, then you have to handle that. You can also create different event handlers for different vehicle types. The test script I posted goes through all vehicles regardless of type, but you could create a dozen event handlers for various vehicles with different rules for each. Share this post Link to post Share on other sites
SOFTACT 10 Posted October 17, 2013 So instead of if (((vehicle player) != player) and (alive player)) then { You would do if (((vehicle player) != player) and (alive player) and ((_this select 1) != "cargo")) then { If you want players to be able to enter a vehicle in a cargo position. Keep in mind that if the game allows switching positions from cargo to pilot, then you have to handle that. You can also create different event handlers for different vehicle types. The test script I posted goes through all vehicles regardless of type, but you could create a dozen event handlers for various vehicles with different rules for each. I thank you so much for your help. So this is what i got so far: waitUntil {!isNull player}; WhiteListArray = ["LT.Bennett.k"]; sleep 1; systemChat name vehicle player; //Assuming WhiteListArray contains a list of player names that are allowed to enter vehicles { if (WhiteListArray find (name vehicle player) == -1) then { _x addEventHandler ["GetIn", { if ((_this select 1 == "driver")&&((vehicle player) != player) and (alive player)) then { player action ["eject", vehicle player]; waitUntil {sleep 0.5; vehicle player == player}; player action ["engineOff", vehicle player]; hint "You must be a pilot to fly!"; }; }]; }; } foreach entities "I_Heli_Transport_02_F" "B_Heli_Transport_01_F"; So that is for DRIVER, waitUntil {!isNull player}; WhiteListArray = ["LT.Bennett.k"]; sleep 1; systemChat name vehicle player; //Assuming WhiteListArray contains a list of player names that are allowed to enter vehicles { if (WhiteListArray find (name vehicle player) == -1) then { _x addEventHandler ["GetIn", { if ((_this select 1 == "gunner")&&((vehicle player) != player) and (alive player)) then { player action ["eject", vehicle player]; waitUntil {sleep 0.5; vehicle player == player}; player action ["engineOff", vehicle player]; hint "You must be a pilot to fly!"; }; }]; }; } foreach entities "I_Heli_Transport_02_F"B_Heli_Transport_01_F""; And thats for Gunner(co-pilot). That only problem i am having is making multi aircraft i am limiting. } foreach entities "I_Heli_Transport_02_F"B_Heli_Transport_01_F""; That right there i cant figure out, it will always block "I_Heli_Transport_02_F", but not the other one. Or do i have to have 1 for every type of vehicle? Share this post Link to post Share on other sites