OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: KyleSarnik on 18 Jun 2003, 02:51:03

Title: Eject script
Post by: KyleSarnik on 18 Jun 2003, 02:51:03
How do I make a script that adds an "Eject" action to a vehicle (plz don't ask why)
Title: Re:Eject script
Post by: LCD on 18 Jun 2003, 03:45:01
put in da init of da vehicle

this addaction ["Eject","eject.sqs"]

now da script wil b

eject.sqs

Code: [Select]
_man = _this select 0
_veh = _this select 1

unassignvehicle _man
[_man] ordergetin false

but da script may not eject da unit from da veh - i donno cuz i cant test it w/ ur veh :P ;)

LCD OUT
Title: Re:Eject script
Post by: KyleSarnik on 18 Jun 2003, 04:35:41
that does nothing. I need to make a script where  I can add an Eject action to the player unit. I want it to act like a real eject action. It should remove the action after he ejects or gets out or when he is on the ground (its for a chopper)
Title: Re:Eject script
Post by: LCD on 18 Jun 2003, 11:31:38
dont chopers have eject action usualy ?

LCD OUT
Title: Re:Eject script
Post by: KyleSarnik on 18 Jun 2003, 18:40:53
Yea but with DKMs Comanche you cant eject. I think this is because you can't dissembark unless the doors are open.
Title: Re:Eject script
Post by: Messiah on 18 Jun 2003, 19:59:24
make a trigger which checks for the player being in the chopper:

player in choppername

then on activation

eject = player addaction ["Eject", "eject.sqs"]

now use this script:

Code: [Select]

player action ["EJECT", choppername]
unassignvehicle player

player removeaction eject
exit

that should work
Title: Re:Eject script
Post by: KyleSarnik on 18 Jun 2003, 20:51:32
Thx messiah. Works perfectly  ;D

Now im going to try to get it to remove the eject action when the chopper is on the ground.
Title: Re:Eject script
Post by: Messiah on 18 Jun 2003, 21:07:15
make another trigger with condition:

(choppername getpos select 2 == 0)

and then onactivation:

player removeaction eject

not sure about the first line - off the top of my head, but its worth a try  :D


Title: Re:Eject script
Post by: Black_Feather on 18 Jun 2003, 22:49:16
it should be this messiah

getpos choppername select 2 <=1
Title: Re:Eject script
Post by: Messiah on 18 Jun 2003, 23:48:08
 :-[
Title: Re:Eject script
Post by: Grinning_Giant on 19 Jun 2003, 00:22:50
Why do AddActions sometimes disapear when you board a vehicle?

And then u get out and they are back again  :-\
Title: Re:Eject script
Post by: Messiah on 19 Jun 2003, 00:25:38
hmmm... ive noticed that in reverse...

if u have an addaction added to an object, and u get into a vehicle nearby with that action still in your menu, then the action will remain with you as far as ud rive the vehicle - even if u r no where near the object the action was added to...

ofp bug i think.
Title: Re:Eject script
Post by: Sui on 19 Jun 2003, 03:06:33
When a unit boards a vehicle, as far as some things go (eg. actions), the units position remains at the point where it boarded the vehicle.

This is why you have to add actions to a vehicle if you want the player to be able to use them ;)
Also, as far as OFP is concerned the player is still near the object which had the action (which presumably was back where you boarded), so the action remains in your action menu...

If you're killed while riding in a vehicle, do you sometimes notice that the death cam will focus on the position where you boarded the vehicle? It's the same sort of thing ;)
Title: Re:Eject script
Post by: Grinning_Giant on 20 Jun 2003, 12:37:19
 :D Oh, Classic...

So you just add the action to the empty vehicle?

I'm gonna give it a whirl  ::)
Title: Re:Eject script
Post by: Grinning_Giant on 20 Jun 2003, 12:57:49
Hmm, seems to work fine...

But there is no pleasing some people. lol

If I wanted to make the action appear only when the player is in the vehicle I guess I would have to use this script right?

Code: [Select]
;Init: [Jeep] exec "Action.sqs"

_Jeep = _this select 0
_Unit = Player

#Start
#Loop
?_Unit in _Jeep : Goto "Action"
~0.5
goto "Loop"

#Action
_Jeep addAction ["Hello", "hello.sqs"]  

#LoopB
?!(_Unit in _Jeep) : Goto "RemoveAction"
~0.5
goto "LoopB"

#RemoveAction
_Jeep removeAction 0

Goto "Start"


Wahoooo!! I tested it and it works perfick!!  8)  ;D  8)

Please advise me of my scripting errors, I'm still learning.

P.S. How do I use the @ command instead of using stupid Loops

Title: Re:Eject script
Post by: Sui on 20 Jun 2003, 13:29:38
Yeah... either that or use a trigger... though:

@? (Player in _Jeep) : Goto "Action"

Should be just:

@ player in _Jeep

and similarily for the next line using @
The @ will wait for the condition specified to be true before moving on to the next line. You shouldn't be using a ? in there ;)

If you wanted to use a trigger, it would look something like this:

Trigger

Radius: 0,0
Condition: none (repeatedly)
Condition Field: (vehicle player) != player
OnActivation Field: (vehicle player) = veh; veh addaction addAction ["Hello", "hello.sqs"]  
OnDeactivation Field: veh removeaction 0
Title: Re:Eject script
Post by: Grinning_Giant on 20 Jun 2003, 13:37:39
ah, hehe just noticed this reply... I edited my post

I tried afew combinations with the @ symbol and it didnt work.

I'd like to keep my scripts as small and tidy as possible, does anybody know of a good tutorial? I have used Johan Gustafsson's which taught me everything I know (almost) and Comrefs are very brief.