OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: SgtBaker1112 on 27 Sep 2006, 02:24:44

Title: add eventhandlers to spawned units
Post by: SgtBaker1112 on 27 Sep 2006, 02:24:44
Can someone help me out here.. i am trying to add an eventhandler to spawned unit
"z_priest" createunit [getpos die1,ja,"BOBs=this"]

how would i go about adding an eventhandler killed, then exec "isdead.sqs"
Title: Re: add eventhandlers to spawned units
Post by: Mr.Peanut on 27 Sep 2006, 03:18:42
Three possibilities in order they should be executed next time...
1) Search the forums
2) Read the CreateUnit tutorial
3) Ask Mr.Peanut
Code: [Select]
"xxxx" createUnit [_pos,_grp,{BOBs=this ; this addEventHandler ["killed",{_this exec "enemykill.sqs"}]},0.5,"PRIVATE"]
If the script "enemykill.sqs" or "isdead.sqs" or whatever you call it
Code: [Select]
_this select 0 will be the dead unit.
Title: Re: add eventhandlers to spawned units
Post by: SgtBaker1112 on 27 Sep 2006, 04:28:09
1. i have searched.. i even looked some more after your reply, but i still couldn't find what i was looking for
2. I have found no createunit tutorial.. can i have a link?
3. i appreciate you trying to help me. but the code sample has given me an error Missing )
 :banghead:
Title: Re: add eventhandlers to spawned units
Post by: Planck on 27 Sep 2006, 05:46:45
Here is the  CreateUnit Tutorial (http://www.ofpec.com/forum/index.php?topic=28040.0).


Planck
Title: Re: add eventhandlers to spawned units
Post by: Mr.Peanut on 27 Sep 2006, 15:58:59
I just took a look at my code above and saw an extra double quote. I have removed it from post above. Try again.
Title: Re: add eventhandlers to spawned units
Post by: SgtBaker1112 on 28 Sep 2006, 00:27:47
thank you mr.peanut.. i now see you as a scripting god.
it worked!!!!!1
 :clap:

 :clap:
 :laugh:
 :blink:
 :)
Title: Re: add eventhandlers to spawned units
Post by: Mr.Peanut on 28 Sep 2006, 15:02:12
!Supplicate Before the Mighty Nut!
                (http://www3.ns.sympatico.ca/brendan.detracey/notworthy.gif)

actually, i am not a god, i am just good at searching the forums  ;)