Home   Help Search Login Register  

Author Topic: Plane script for CTI  (Read 1988 times)

0 Members and 1 Guest are viewing this topic.

Offline Floobie

  • Members
  • *
  • Gastovski... James Gastovski
Plane script for CTI
« on: 21 Aug 2008, 12:01:58 »
Hello,

How can I activate a certain trigger only for human players that are currently in a plane? (so NOT an AH-64 but an SU 25 for example)

Me and a friend got back on playing the classic MFCTI Coop missions. Then we found out that it was very frustating to spend a fortune on a couple of planes and then crashing them on attempting to take of on a hilly landscape with obstacles all over the place.

So I wrote a VTOL script to solve it. But my next problem is to inplement them in the mission. It should go like this: Player purchases plane -> gets in as pilot -> trigger detects player is in plane -> option of VTOL becomes available in action menu -> player uses VTOL -> VTOL action removed from action menu. I'm an avarage scripter and here's my script:

Code: [Select]
VTOL = true
_p = _this Select 0
_t = 0

#h
~0.001
_p setVelocity [0,0,5]
_t = _t + 1
?(_t > 350): Goto "s"
Goto "h"

#s
_p setVelocity [0,150,0]
exit

Now I just need a trigger that: adds the action ONLY when a human player is in a vehicle type of "plane" and then the trigger removes it when VTOL = true.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Plane script for CTI
« Reply #1 on: 21 Aug 2008, 19:51:18 »
You do not need a trigger. All you need is a "GETIN" eventhandler added to the plane.  The "GETIN" event script checks that the pilot is the player and then adds the VTOL action. Read the tute on event handlers in the ED.
Code: [Select]
myPlane addEventHandler ["GETIN",{_this exec "addaction_vtol.sqs"}]addaction_vtol.sqs
Code: [Select]
_unit = _this select 1
_plane = _this select 0
if (_unit != player) then {exit}
idvtol = _plane addAction ["VTOL","vtol.sqs"]
_plane addEventHandler ["GETOUT", {_this exec "removeaction_vtol.sqs"}]
removeaction_vtol.sqs
Code: [Select]
_unit = _this select 1
_plane = _this select 0
if (_unit != player) then {exit}
_plane removeAction idvtol
_plane addEventHandler ["GETIN",{_this exec "addaction_vtol.sqs"}]

Then add the following line near the top of your VTOL script:
Code: [Select]
(_this select 0) removeAction (_this select 2)I suggest you also add a line that checks if the player is the pilot, and not the gunner!
« Last Edit: 21 Aug 2008, 19:55:48 by Mr.Peanut »
urp!

Offline Floobie

  • Members
  • *
  • Gastovski... James Gastovski
Re: Plane script for CTI
« Reply #2 on: 14 Sep 2008, 16:57:10 »
I appreciate your help Mr.Peanut, but there is only one problem: The plane is spawned during the mission using CreateVehicle and I don't know how or where to add the EventHandler to the plane. I also checked out the MFCTI scripts but I couldn't find a way to add it. :dunno:

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Plane script for CTI
« Reply #3 on: 15 Sep 2008, 01:58:45 »
If you can find the script that spawns the plane and post it here, I'm sure we can make it work.
urp!