Jump to content
Sign in to follow this  
kocrachon

Pilots only, your not allowed

Recommended Posts

So right now I am working on a persistent world where missions are randomly generated. You are given all of these assets, and you need to use them wisely or else you are SOL.

One thing I am doing is making it very restricted. Only specific classes can use specific guns (a system I got from some domination scripting) such as only AT soldiers can use javelins and what not.

Anyways, 90% of my scripts come from scripts I got form other source such as armaholic. But I cant seem to find a script that lets me restrict the class type to use specific vehicles

Such as, I want to specifically select what vehicles require a specific class. Such as I want F-35s, AVA-8s, and AH-64s (also the co pilot) to require that you be a pilot, but still allow anyone to fly the UH-60s or CH-47s.

I also want to do the same things with Tanks. Only crew can drive and gun the APC, but anyone can ride in the back.

Anyone able to help me with this? Basically it needs to say "If not a pilot, you cannot fly the AH-64, the AVA-8, or the F-35 (etc etc) or be the gunner in the AH-64 either" and etc etc etc.

EDIT:

Its also fine if its based on slot, such as "If not pilot1 or pilot2 or pilot3, then you cannot fly the F-35, and you cannot fly or gun on the AH-64"

This will also be in a dedicated server enviorment...

Edited by HavocDemon

Share this post


Link to post
Share on other sites

domination does have a vehicular restriction eg engineers are the only ones that can drive the supply truck might not be much but something you could look at and expand to suit your application maybe?

I think only engineers should be able to use the wreak chopper but should get points for putting wreaks on the wreak repair (in domination2 that is)

Share this post


Link to post
Share on other sites

I looked at it but its too hard to implement the system it uses into my system. So I need something some what from scratch I think.

Share this post


Link to post
Share on other sites

A trigger with following conditions:

expCond="typeOf player != 'USMC_Soldier_Pilot' && vehicle player isKindOf 'AIR' && !((vehicle player) isKindOf 'ParachuteBase')";
expActiv="if (player == driver vehicle player) then {player action ['eject',vehicle player]; player groupChat 'You have no permission to fly!'}";

...could be helpful i guess...

;)

Share this post


Link to post
Share on other sites
A trigger with following conditions:

expCond="typeOf player != 'USMC_Soldier_Pilot' && vehicle player isKindOf 'AIR' && !((vehicle player) isKindOf 'ParachuteBase')";
expActiv="if (player == driver vehicle player) then {player action ['eject',vehicle player]; player groupChat 'You have no permission to fly!'}";

...could be helpful i guess...

;)

That looks good but it seems that it prevents anyone but pilots from using ANY air. I just want to make it to where only pilots can fly SPECIFIC aircraft. Such as, Anyone can fly a UH-60, but only Pilots can fly a AH-64

---------- Post added at 06:54 ---------- Previous post was at 06:47 ----------

That looks good but I am hoping to find something that doesn't require being in the init field of the vehicle itself. I have stuff that spawn via different methods, and as I said, Im not very good at scripting, so making it work with that system is hard. Not to mention a wreck recovery system (which I borrowed from dom) as well as a respawn system.

---------- Post added at 07:06 ---------- Previous post was at 06:54 ----------

also Id like to mention, that this is in a dedicated server enviorment

---------- Post added at 07:17 ---------- Previous post was at 07:06 ----------

Here is something I have made so far but I cant figure out why it isn't working..

_unit = _this select 0;
_vec = _this select 1;
_Vehicle = typeOf _vec;
_dunit = _unit;
_warning = 0;
if (not (local _unit)) exitwith {};


_Eject = 
{
_unit = _this select 0;
_unit action ["ENGINEOFF", vehicle _unit];
_unit action ["Eject",vehicle _unit];
sleep 1;
_unit action ["Eject",vehicle _unit];
};


if (getdammage _vec == 0) then
{
_vec setdammage 0.01;
};
if (not (isPlayer _unit)) then
{
_dunit = (leader _unit);
};
switch (_Vehicle) do
{
   case "AH64D_EP1":
   {
if (typeOf _unit != "US_Soldier_Pilot_EP1") then {[_unit] call _Eject};
   };

Its called by this trigger

Condition | vehicle player != player and player == driver (vehicle player)
Activation | handle = [player,vehicle player] execVM "VecInit.sqf"

---------- Post added at 07:49 ---------- Previous post was at 07:17 ----------

Nevermind, Ir esolved it, my trigger wasn't set to repeat, thanks everyone for the help

Edited by HavocDemon

Share this post


Link to post
Share on other sites

I use the F2 frame work for this and it works great !

f_isAuthorisedCrew.sqf

// F2 - Authorised Crew Check
// Credits: Please see the F2 online manual (http://www.ferstaberinde.com/f2/en/)
// ====================================================================================

===================================================================================

// DECLARE VARIABLES AND FUNCTIONS

private ["_fromEH","_vehicle","_vehicleRole","_unitToCheck","_restrictedCrew","_warningMsg"];

// ====================================================================================

// SET KEY VARIABLES
// Using the arguments passed to the script, we first define some local variables.

_fromEH = _this select 0;
_vehicle = _fromEH select 0;
_vehicleRole = _fromEH select 1;
_unitToCheck = _fromEH select 2;
_restrictedCrew = _this select 1;
_warningMsg = localize "STR_f_UnauthorisedCrew_Warning";

// DEBUG
if (f_var_debugMode == 1) then
{
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _fromEH = %1",_fromEH];
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _vehicle = %1",_vehicle];
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _vehicleRole = %1",_vehicleRole];
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _unitToCheck = %1",_unitToCheck];
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _restrictedCrew = %1",_restrictedCrew];
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _warningMsg = %1",_warningMsg];
};

// ====================================================================================

// PERFORM CHECKS
// We do not need to perform all of this script on all clients simulaneously, so if
// the unit triggering the the event handler is local to another client, we exit the
// script. Unless the unit is entering as cargo, or part of the authorised crew, it
// is ejected from the vehicle with a warning message (as a hint).

if ((local _unitToCheck) && (_vehicleRole != "CARGO") && (!(_unitToCheck in _restrictedCrew))) then
{
hint format ["%1",_warningMsg];
_unitToCheck action ["getout",_vehicle];
};

// ====================================================================================

if (true) exitWith {};

init.sqf :

helicoptername addEventhandler ["GetIn", {[_this,[playername]] execVM "f_isAuthorisedCrew.sqf"}];

presume it is ok to post some F2 framework if not sorry please delete it

Share this post


Link to post
Share on other sites

i use the following script to check a players class and kick them out if they are not a match.

place following code into init.sqf

["Plane", "US_Soldier_Pilot_EP1"] execVM "vehicle_check.sqf";
["Helicopter", "US_Soldier_Pilot_EP1"] execVM "vehicle_check.sqf";
["Wheeled_APC", "US_Soldier_Crew_EP1"] execVM "vehicle_check.sqf";
["Tank", "US_Soldier_Crew_EP1"] execVM "vehicle_check.sqf";

basically defines type of vehicle and class allowed to operate it. you can also instead specify specific vehicle instead of type.

create file called vehicle_check.sqf and place the following in.

_vehicleType = _this select 0;
_crewType = _this select 1;
if (typeof player != _crewType) then {
private "_currentvehicle";
while {alive player} do {
	waituntil {vehicle player != player};
	_currentvehicle = vehicle player;
	if (_currentvehicle iskindof _vehicleType && !(_currentvehicle iskindof "ParachuteBase")) then {
		if (driver _currentvehicle == player) then {
			player action ["eject",_currentvehicle];
			waituntil {vehicle player == player};
			if (_vehicleType == "Helicopter" || _vehicleType == "Plane" ) then {
				hint format["Leave the flying of the %1s to those with the training son.",_vehicleType ];
			}else{
				hint format["Leave the driving of the %1s to the 1st Cavalry son.",_vehicleType ];
			};
		};
	};
};
};

hope that helps

Share this post


Link to post
Share on other sites

@Roy86: I've tested your version - it doesn't work for me. (tested on LAN-hosted MP mission). Is something missing?

@psvialli: the F2 framework works, but without giving out a warning message or hint when you're kicked out. UPDATE: hmm, appearantly it even kicks out pilots!

Edited by Bulldog Six

Share this post


Link to post
Share on other sites

I'd go with a "GetIn" eventhandler that does all the checking in its script. Also upon player ejection you may also want to read the vehicle's fuel status, empty it completely, and then fill it back up again. Sounds weird, but it is an effective way of shutting down a vehicle engine. The command engineOn has locality issues making it hard to use.

Share this post


Link to post
Share on other sites
I'd go with a "GetIn" eventhandler that does all the checking in its script. Also upon player ejection you may also want to read the vehicle's fuel status, empty it completely, and then fill it back up again. Sounds weird, but it is an effective way of shutting down a vehicle engine. The command engineOn has locality issues making it hard to use.

hmm.. it sounds so easy. it probably is when you understand the code, but I barely understand it yet. could you help me getting any of the above codes to work? (MP) I'd suggest modifying the F2 code, since it seems to effectively kicking players out and giving a hint message with slight modification. but it seems to kick out pilots as well so far. this is how I modified it until I realised it doesn't only kick out unauthorized units but pilots as well (I just managed to get the hint message to work. "lol" - yeah, I know.. :-/ ):

// F2 - Authorised Crew Check
// Credits: Please see the F2 online manual (http://www.ferstaberinde.com/f2/en/)

// DECLARE VARIABLES AND FUNCTIONS
// ====================================================================================

private ["_fromEH","_vehicle","_vehicleRole","_unitToCheck","_restrictedCrew","_warningMsg"];

// SET KEY VARIABLES
// ====================================================================================
// Using the arguments passed to the script, we first define some local variables.

_fromEH = _this select 0;
_vehicle = _fromEH select 0;
_vehicleRole = _fromEH select 1;
_unitToCheck = _fromEH select 2;
_restrictedCrew = _this select 1;
_warningMsg = localize "STR_f_UnauthorisedCrew_Warning";

// DEBUG
if (f_var_debugMode == 1) then
{
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _fromEH = %1",_fromEH];
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _vehicle = %1",_vehicle];
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _vehicleRole = %1",_vehicleRole];
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _unitToCheck = %1",_unitToCheck];
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _restrictedCrew = %1",_restrictedCrew];
player sideChat format ["DEBUG (f\common\f_isAuthorisedCrew.sqf): _warningMsg = %1",_warningMsg];
};

// ====================================================================================

// PERFORM CHECKS
// We do not need to perform all of this script on all clients simulaneously, so if
// the unit triggering the the event handler is local to another client, we exit the
// script. Unless the unit is entering as cargo, or part of the authorised crew, it
// is ejected from the vehicle with a warning message (as a hint).

if ((local _unitToCheck) && (_vehicleRole != "CARGO") && (!(_unitToCheck in _restrictedCrew))) then
{
hint "Leave the flying to those with the training son. (Pilots only)";
_unitToCheck action ["getout",_vehicle];
};

// ====================================================================================

if (true) exitWith {};

I believe it can be un-fueled and refueled with this (if I'm not mistaken), but I don't know exactly how to implement it:

this addeventhandler ["fuel", {(_this select > 0.1) setfuel 0}]; this addeventhandler ["fuel", {(_this select 0) setfuel 1}];

and I know the classname it should be checking for should be "US_Soldier_Pilot_EP1" or "US_Pilot_Light_EP1" (OA classnames) for aircrafts.

If you have the time and know-how could you add the ability to check armored vehicles for crewmen too? the class would be "US_Soldier_Crew_EP1" (OA classname).

I'd greatly appreciate your expertise with this CarlGustaffa! I'd do it myself if I wouldn't lack the understanding of the code so much. :-/

Share this post


Link to post
Share on other sites

something like this, code is untested btw.

place this in the vehicles init line.

_eh = this addEventHandler ["GetIn", {_this execVM "getinEH.sqf"}];

save this as getinEH.sqf and place in your mission folder:

_veh = _this select 0;
_pos = _this select 1;
_obj = _this select 2;

if (_pos == "driver" AND _obj == player) then {
if ((typeOf _obj) != [b][i]"classname_of_your_pilots_used"[/i][/b]) then {
	_fuel = fuel _veh;
	_veh setFuel 0;
	unAssignVehicle _obj;
	_obj action ["getOut", _veh];
	waitUntil {sleep 1; (fuel _veh) == 0};
	_veh setFuel _fuel;
};
};

NOTE: replace "classname_of_your_pilots_used" with the correct classname of the pilot you use in your mission:

Share this post


Link to post
Share on other sites
something like this, code is untested btw.

place this in the vehicles init line.

_eh = this addEventHandler ["GetIn", {_this execVM "getinEH.sqf"}];

save this as getinEH.sqf and place in your mission folder:

_veh = _this select 0;
_pos = _this select 1;
_obj = _this select 2;

if (_pos == "driver" AND _obj == player) then {
if ((typeOf _obj) != [b][i]"classname_of_your_pilots_used"[/i][/b]) then {
	_fuel = fuel _veh;
	_veh setFuel 0;
	unAssignVehicle _obj;
	_obj action ["getOut", _veh];
	waitUntil {sleep 1; (fuel _veh) == 0};
	_veh setFuel _fuel;
};
};

NOTE: replace "classname_of_your_pilots_used" with the correct classname of the pilot you use in your mission:

Correct me if I'm wrong, but I believe this method would stop working once the vehicle is destroyed and respawns without the previous set init lines, right?

So far I'm using the "Simple Vehicle Respawn Script v1.7 by Tophe of Östgöta Ops", which has an option to add a vehicles init line in the code to preserve it, but I noticed that as soon as a quote (") is within that additional code it breaks.

example:

veh = [this, 15, 10, 5, TRUE, FALSE, "this setDammage 0.5"] execVM "vehicle.sqf"

the code this setDammage 0.5 would be preserved.

BUT what do I do when the additional init line code I want to preserve contains another quote as in the code you provided @ "GetIn". The programm then claims it's missing a ] bracket after the first quote of "GetIn" because it believes it's the end of the code I want to preserve after a respawn. What to do then?

---------- Post added at 23:49 ---------- Previous post was at 23:37 ----------

Pretty sure Bon came up with this, but here's another method of locking down by soldier class.

it's a good code except that the engine can be still turned on as Demonized mentioned (thanks for mentioning!@Demonized). that wouldn't be too bad, but unfortunately I don't know how to add OPFOR crewmen and pilots to the code so it's got an array of acceptable units into the init.sqf code of it so OPFOR crewmen and pilots are not kicked out of their helo's and tanks.

Share this post


Link to post
Share on other sites

yes you are correct, it will automatically end when vehicle is destroyed or deleted, so you need to add it to the new respawned one.

for qoute inside quotes use double quotes:

"something, ""normally_single_quotes"", something else"

veh = [this, 15, 10, 5, TRUE, FALSE, "_eh = this addEventHandler [""GetIn"", {_this execVM ""getinEH.sqf""}];"] execVM "vehicle.sqf"

it's a good code except that the engine can be still turned on as Demonized mentioned (thanks for mentioning!@Demonized).

i think you mean CarlGustaffa but hey :)

Edited by Demonized

Share this post


Link to post
Share on other sites

Oh, absolutely right! Of course I meant CarlGustaffa!

My lack of sleep seems to take it's toll.. my apologies!

Thanks CarlGustaffa! I'll get back to you if I run into problems regarding that refueling trick.

@demonized: double quotes! lol - outstanding! thanks again, Demonized!

Share this post


Link to post
Share on other sites

This is what I use, and works fine in multiplayer. It won't work as is, as you need the rest of the domination code, but you get the idea of what it does. The engine stuff at the very bottom:

// by Xeno
#include "x_setup.sqf"
private ["_vehicle","_position","_enterer","_was_engineon"];

_enterer = _this select 2;
__notlocalexit(_enterer);

_vehicle = _this select 0;
_position = _this select 1;

_was_engineon = isEngineOn _vehicle;

_exit_it = false;
if (!_exit_it) then {
switch (true) do {
	case (typeOf _vehicle == "MtvrSupply_DES_EP1") : {
		if (!(str(_enterer) in d_is_engineer)) then {
			"Restricted access! Only engineers can enter a Salvage truck..." call XfGlobalChat;
			_exit_it = true;
		};
	};
	case (typeOf _vehicle == "ATV_US_EP1") : {
		if (!(str(_enterer) in ["delta_1","delta_2"])) then {
			"Restricted access! This ATV is reserved for the sniper team..." call XfGlobalChat;
			_exit_it = true;
		};
	};

	case (typeOf _vehicle == "LandRover_CZ_EP1") : {
		if (!(str(_enterer) in ["charlie_1","charlie_2","charlie_3","charlie_4","charlie_5"])) then {
			"Restricted access! This Landrover is reserved for the charlie weapons team..." call XfGlobalChat;
			_exit_it = true;
		};
	};
	case (typeOf _vehicle == "HMMWV_M1035_DES_EP1") : {
		if (!(str(_enterer) in ["echo_1","echo_2","echo_3"])) then {
			"Restricted access! This Utility HMMWV is reserved for the echo CSW/SF team..." call XfGlobalChat;
			_exit_it = true;
		};
	};
};
};
if (_exit_it) exitWith {
_enterer action["Eject",_vehicle];
if (!_was_engineon && isEngineOn _vehicle) then {_vehicle engineOn false};
[_vehicle] spawn {
	_vehicle = _this select 0;
	_fuel = fuel _vehicle;
	sleep 0.5;
	_vehicle setFuel 0;
	sleep 2.5;
	_vehicle setFuel _fuel;
};
};

Looking at it now, I don't think the _vehicle engineOn false is needed, as it doesn't work properly (old code leftovers), and just do the spawn.

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites

thx a lot! I used Demonized's version with 4 different scripts (1 for pilots blufor, 1 for crewmen blufor, 1 for pilots opfor and another for crewmen opfor). works good. the only way to trick out this system if for crewmen to switch seats to driver's position (i.e. from gunner or commander seat). but that doesn't work for helo's because one can't switch to the pilot seat from another position within a helo. so helo's are working excellent.

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
Sign in to follow this  

×