Jump to content
Sign in to follow this  
doomanchu

Limit Driver of Vehicle to Specific Unit Name

Recommended Posts

I'm wanting to limit the driver (pilot) position of a helicopter to only be used by a unit named "pilot".

If it's not "pilot" eject him and send him a message that he doesn't have permission to fly that vehicle.

Any help would be great.

Share this post


Link to post
Share on other sites

Hi...

Put in the init row of your vehicle:

nul=this spawn {while {alive _this} do { if (!isNull driver _this AND driver _this != PILOT) then {driver _this vehicleChat "You have no permission to fly this."; driver _this action ["EJECT", _this]}; sleep 2};};

;)

Share this post


Link to post
Share on other sites

An alternative would be to use an event handler, for example:

this addEventHandler ["GetIn", { if ((_this select 1 == "driver") && (_this select 2 != pilot1)) then { (_this select 2) action ["EJECT", _this select 0] }; }]

That would check if the driver is pilot1 else eject him, also it would only run when someone gets in so you dont have to keep track of lots of spawned code.

Share this post


Link to post
Share on other sites
An alternative would be to use an event handler, for example:

this addEventHandler ["GetIn", { if ((_this select 1 == "driver") && (_this select 2 != pilot1)) then { (_this select 2) action ["EJECT", _this select 0] }; }]

That would check if the driver is pilot1 else eject him, also it would only run when someone gets in so you dont have to keep track of lots of spawned code.

Could you also do this using player UID numbers?

Share this post


Link to post
Share on other sites
this addEventHandler ["GetIn", { if ((_this select 1 == "driver") && (getPlayerUID (_this select 2) != "[b]TYPEYOURPLAYERIDHERE[/b]")) then { (_this select 2) action ["EJECT", _this select 0] }; }]

Share this post


Link to post
Share on other sites
An alternative would be to use an event handler, for example:

this addEventHandler ["GetIn", { if ((_this select 1 == "driver") && (_this select 2 != pilot1)) then { (_this select 2) action ["EJECT", _this select 0] }; }]

That would check if the driver is pilot1 else eject him, also it would only run when someone gets in so you dont have to keep track of lots of spawned code.

Thank you very much. Where could I place the vehicleChat from the example above yours in the code you provided?

Also, I tried adding this to my land vehicles to allow all other units to use them except the pilot, but having "== pilot1" instead of "!= pilot1" doesn't seem to work.

this addEventHandler ["GetIn", { if ((_this select 1 == "driver") && (_this select 2 == pilot1)) then { (_this select 2) action ["EJECT", _this select 0] }; }]

Or, would it be better to try something like this:

this addEventHandler ["GetIn", { if ((_this select 1 == "driver") && (_this select 2 != west01 or _this select 2 != west02 or _this select 2 != west03 or _this select 2 != west04)) then { (_this select 2) action ["EJECT", _this select 0] }; }]

Edited by doomanchu

Share this post


Link to post
Share on other sites
Hi...

Put in the init row of your vehicle:

nul=this spawn {while {alive _this} do { if (!isNull driver _this AND driver _this != PILOT) then {driver _this vehicleChat "You have no permission to fly this."; driver _this action ["EJECT", _this]}; sleep 2};};

;)

An alternative would be to use an event handler, for example:

this addEventHandler ["GetIn", { if ((_this select 1 == "driver") && (_this select 2 != pilot1)) then { (_this select 2) action ["EJECT", _this select 0] }; }]

That would check if the driver is pilot1 else eject him, also it would only run when someone gets in so you dont have to keep track of lots of spawned code.

Neither of these worked on a dedicated server.

Share this post


Link to post
Share on other sites
Check this out: >> testmission <<

While that worked on my server, it won't work for my mission. I really need to place the script in a specific vehicle for a specific playable unit. I have various vehicles that will be drivable/flyable by specific players. Which is why I'm wanting it to work based off the unit's name. I do appreciate the effort and help thus far.

Share this post


Link to post
Share on other sites

Found this here, but not sure how to use it... any ideas?

array = _this;
_vehicle = _this select 0;
_position = _this select 1;
_man = _this select 2;

if (!(_man in [p1,p2,p3]) && _position != "cargo") then
{
hint format ["Hey %1, you asshat, only engineers can drive vehicles.",name _man];
_man action ["eject",_vehicle];
};

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  

×