OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Speeder on 11 Apr 2005, 18:28:05

Title: Vehicle locked to "wrong" units
Post by: Speeder on 11 Apr 2005, 18:28:05
I was kinda hoping that someone would make a script for me.

It need to do the following:

Only pilots can enter as driver/gunner in chopper

only crew can enter as driver/gunner in amored vehicles.

If a nother unit than the one defined tries to enter as driver/gunner, they should be disembarked, but the message that they are not certified to oberate the kind of vehicle.


I think the units I'm using are the ones starting with SUCH-    that is SuchSoldier   Suchcrew - or something like that..

Thanks for the help

PS: script must be MP compatible
Title: Re:Vehicle locked to "wrong" units
Post by: Terox on 11 Apr 2005, 22:22:00
add a getin eventhandler per vehicle, basically this runs a script, it questions either the unit variable name or class of unit and if it isnt a desired unit type, ejects them
Title: Re:Vehicle locked to "wrong" units
Post by: Speeder on 12 Apr 2005, 15:27:29
Could you please write it a bit more like a walkthrough...tut or something like that - I never used an eventhandler before, I know nothing about them
Title: Re:Vehicle locked to "wrong" units
Post by: Speeder on 12 Apr 2005, 16:28:26
I can't get it to work.. Tried everything exept the right thing :)

I write this in the init of MyHeli1

MyHeli1 AddEventHandler ["getin", {[] exec "allowGetIn.sqs"}]


This is my allowGetIn.sqs

_vehicle = _this select 0
_pos = _this select 1
_who = _this select 2


#tjek0
? _pos != cargo : Goto "tjekname" ELSE exit


#tjekname
?(_who) != (name pilot1) OR (_who) != (name pilot2) : Goto "Ejectplayer" ELSE exit



#Ejectplayer

(_who) action ["EJECT",_vehicle]

exit



What am I doing wrong?
Title: Re:Vehicle locked to "wrong" units
Post by: macguba on 12 Apr 2005, 16:31:51
The syntax

? : else

is not correct.   You can use

if then else

but check the syntax.   Although if then does much the same thing as ? :, the two are not interchangeable.

I am not familiar with eventhandlers and scripting in MP so this may be a redundant comment, but make sure that your script will eject the loon on all computers, not just locally.
Title: Re:Vehicle locked to "wrong" units
Post by: Planck on 12 Apr 2005, 19:36:34
Try:

MyHeli1 AddEventHandler ["getin", {_this exec "allowGetIn.sqs"}


That might work better......maybe  ;D


Planck
Title: Re:Vehicle locked to "wrong" units
Post by: Speeder on 20 Apr 2005, 09:17:22

If I want to add the eventhandler to all units on one side, could I then use this?


?side _x == east foreach Thislist : "_x addeventhandler [""killed"",{civdied = civdied + 1}]"

or what is the syntax?