OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: 9thInfSandman on 24 Jun 2007, 05:13:16

Title: Help with a class script
Post by: 9thInfSandman on 24 Jun 2007, 05:13:16
I'm trying to make a class script.  I want only the West pilots to be able to use air units in the script.  I know it's possible, but I don't know where to start.   I was thinking maybe something like this:

Code: [Select]
if (not (isPlayer _unit)) then
{
_dunit = (leader _unit);
};
switch (_Vehicle) do
{
case "A10":
    {
_unit = player;
if (player isKindOf "SoldierWPilot" = false) then {_handle = [_dunit,_rank7] execVM "scripts\req.sqf";_unit action ["ENGINEOFF", vehicle _unit];_unit action ["Eject",vehicle _unit]};
};




It didn't work and I don't know why, please help.

Sandman
Title: Re: Help with a class script
Post by: Mr.Peanut on 26 Jun 2007, 15:41:55
You have bugs mate!  :blink: But first...
You have not given enough details to fully solve your problem. Is the above the full script? How do you call the script? And what is req.sqf for?

Provide those details and we can get it working. Once we have got it working, you may want to consider the BAS_F (http://www.ofpec.com/forum/index.php?topic=29564.0) framework which has a component for this purpose. On ther other hand, you can learn more doing it yourself.

Awaiting the details...
Title: Re: Help with a class script
Post by: Spooner on 13 Jul 2007, 07:17:47
The code is just perplexing without explanation, I'm afraid...Oh, I thought I recognised it, it is lifted straight from Evolution (from "scripts/veccheck.sqf", in fact). It aims to push you out of a vehicle based on your Evolution rank (or the rank of your group leader) and you are presumably trying to change it so that it is limited by character model instead. The code you have there is very Evolution-specific as it limits access to the A10 for anyone who isn't at Evolution rank 7, so no wonder you are having problems!

You could do worse than to take Peanut's advice and use the BAS f framework (http://www.ballisticaddonstudios.com/content/view/73/57/) in your mission. This includes a character-type based crew limiting system, which would be easier to use than writing your own from scratch. Admittedly though, there isn't much complexity in this particular script, but BAS f is a godsend to any mission creator anyway!

e.g., if you had a plane called myA10, you could just put this in your init.sqf (Assuming you had BAS f in your mission):
Code: [Select]
myA10 addEventhandler ["GetIn", {[_this,["SoldierWPilot"]] execVM "f\common\f_isAuthorisedCrewType.sqf"}];

**EDIT**
I wasn't trying to get at you for using the Evolution code - reading and adapting other people's code is a great way to learn. If you are still learning, though, I'd stay away from the rather complex Evolution code and stick with a smaller, simpler mission.
Title: Re: Help with a class script
Post by: firecontrol on 19 Jul 2007, 08:55:44
I adapted this from Evolution as well... here's a snippet:

Create a trigger which activates when player enters driver position.
Condition --->
Code: [Select]
vehicle player != player && player == driver (vehicle player) && local (vehicle player)&& (vehicle player isKindOf "UH60MG")
NOTE: Change "UH60MG" to whatever you want non-pilots from flying


"On Activiation" should call the function, i.e. --->
Code: [Select]
whatever = [player] execVM "pilotCheck.sqf"




And the script "pilotCheck.sqf":
Code: [Select]
_unit = _this select 0;

if (!(local _unit)) exitwith {};
if (!(_unit isKindOf "soldierWPilot")) then {_unit action ["Eject",vehicle _unit]; hint "You have no idea how to fly this!"};

if (true) exitWith {};