Jump to content

[Scripting Help] Restrictions to vehicles.


S.N.A.F.U.
 Share

Recommended Posts

Hey guys, Noobie question of the week....

 

I am doing a script up to restrict some vehicles to certain members of our group. I am using an .SQF as follows

 

this addEventHandler ["GetIn", {
	_veh = _this select 0;
	_pos = _this select 1;
	_unit = _this select 2;
	
	if (isPlayer _unit) then {
		if (_pos == "driver") then {
			if ((getPlayerUID _unit) != MasterUIDlist) then {
				_fuel = fuel _veh;
				_veh setFuel 0;
				_veh vehicleChat format["%1 - You Cannot operate this vehicle",(name _unit)];
				sleep 1;
				_unit action ["getOut", _veh];
				_veh setFuel _fuel;
			} else {
				_veh vehicleChat format["Welcome %1",(name _unit)];
			};
		};
	};
}];

My question is, what's the proper syntax to add pos == "Gunner" in as well.

 

Any help would be appreciated :)

Link to comment
Share on other sites

if (_pos == "driver" || _pos == "gunner") then { /* awesomeness here */ };

:P

LOL Rarek.. :)

 

I ended taking a different tack & banning the vehicles unless an authorised member was in the vehicle..

 

Vehicle init..

 

Veh = [this, 360, 120, 0, false, false, "this addEventHandler ['GetIn', {_this execVM 'Hcheck.sqf'}];"] execVM "vehicle.sqf"; this addEventHandler ["GetIn", {_this execVM "Hcheck.sqf"}];

Note to self, I should put in the mark_unit too...

 

& Boot.sqf

 

//if (isServer) exitWith {};

waitUntil {(getPlayerUID player) != ""};

_masterUIDArray = ["1112223334444", "444333222111", "1818181818181818"];
_vehicle = _this select 0;
_seat = _this select 1;
_player = _this select 2;
_nameCheck = false;
_startFuel = fuel _vehicle;

//sleep 0.1;

//if (!(local _vehicle) || !(_player == player)) exitWith {hint str _player};

sleep 0.1;
_vehicle setFuel 0;
_vehicle vehicleChat format["Welcome %1!", name _player];

//Debug
//hint format ["%1 got in %2 seat of %3", name _player, _seat, typeOf _vehicle];
//hint str toArray name _player;

if (!(_player in _vehicle))  exitWith {_vehicle setFuel _startFuel;};

_name = toArray name _player;


	if (getPlayerUID _player in _masterUIDArray) then {
	_vehicle vehicleChat "Hardcore member!";
	_nameCheck = true;
	}
	else {
	_vehicle vehicleChat "You are not a registered member";
	};


sleep 1.0;
if (!(_player in _vehicle))  exitWith {_vehicle setFuel _startFuel;};

if (_nameCheck) then {
       _vehicle vehicleChat format ["Engine Unlocked %1!", name _player];
} else {
       _vehicle vehicleChat "or your identity could not be verified.";
       moveOut _player;
};
sleep 2.0;
_vehicle setFuel _startFuel;

It's a bit clunky, but it works... Thanks again for your help :)

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
 Share

  • Forum Statistics

    11k
    Total Topics
    66.1k
    Total Posts
×
×
  • Create New...