Jump to content
Sign in to follow this  
Asung

How to make a vehicle only usable by a certain unit?

Recommended Posts

Hello All,

I had a question if anyone could point me in the right direction I would be great full.

Is there a way through scripting or skilled use of editor to make it so that a certain vehicle(s) are only usable by a unit with a certain name?

For example, I want to make a mission where there are four players running on a dedicated server. Player 1,2,3 have different skills like first-aid and etc. Player 4 is named "Rogers" and I would like for him to be the only one able to operate a certain vehicle. (doesnt matter if it makes the restriction apply to all vehicles under the classname OR if it only applies to a vehicle that has a named attached to it).

Regards,

ASung

Share this post


Link to post
Share on other sites
You could adapt this code but instead of checking typeOf check for the Rogers unit.

I am a total noob at scripting and looking at that scares me =( , but I think I can deconstruct a demomission, I checked on your website but I could not find one. Is there anychance you have one?

---------- Post added at 03:12 AM ---------- Previous post was at 03:06 AM ----------

Trying to learn a bit...

Don't "//" signify notes? So what follows after the // isnt part of the script is it? I interpret the " "Helicopter" / "Tank" " portion of the script on your great website as notes for the user. How does the script know what is a helicopter or tank if what follows after // are just notes?

_

vehicleType = _this select 0; // "Helicopter" / "Tank"

_crewType = _this select 1; // "US_Soldier_Pilot_EP1"

//hint format["%1 - %2",_crewType, _vehicleType];

if (typeof player != _crewType) then {

private "_v";

while {alive player} do {

waituntil {vehicle player != player};

_v = vehicle player;

if (_v iskindof _vehicleType && !(_v iskindof "ParachuteBase")) then {

if (driver _v == player) then {

player action ["eject",_v];

waituntil {vehicle player == player};

hint "We shall leave the piloting to those with the appropriate training.";

};

};

};

};

Share this post


Link to post
Share on other sites
put this in the init line of the unit rogers

["Helicopter", "US_Soldier_Pilot_EP1"] execVM "pilotCheck.sqf";

then change "Helicopter" to the correct cfgvehicles class name from this:

http://community.bistudio.com/wiki/ArmA_2:_CfgVehicles

then change the US_Soldier_Pilot_EP1 to the classname of the rogers unit

Hey thanks for the speedy replies. I tried this with no success

In the init of the unit I put.

nul= ["vwgolf", "citizen2" execVM "pilotCheck.sqf";

My pilotcheck.sqf looks like:

vehicleType = _this select 0; // "Helicopter" / "Tank"

_crewType = _this select 1; // "US_Soldier_Pilot_EP1"

//hint format["%1 - %2",_crewType, _vehicleType];

if (typeof player != _crewType) then {

private "_v";

while {alive player} do {

waituntil {vehicle player != player};

_v = vehicle player;

if (_v iskindof _vehicleType && !(_v iskindof "ParachuteBase")) then {

if (driver _v == player) then {

player action ["eject",_v];

waituntil {vehicle player == player};

hint "We shall leave the piloting to those with the appropriate training.";

};

};

};

};

I also tried putting the following into my init.sqf

["vwgolf", "citizen2" execVM "pilotCheck.sqf";

In my test mission, any unit can drive the hatchback/vwgolf

Any thoughts? I am probably making a few facepalm.

Share this post


Link to post
Share on other sites

Remember that code is run per player, so either put it in the init field of all playable units or call it from init.sqf.

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  

×