OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Gogs on 22 May 2005, 00:53:00
-
Word up crew. Working on a few missions involving aircraft. I wan't to use the eventhandler "fired" to trigger a radio call of "Fox One" or "Fox Two", depending on the weapon. Currently using a script that detects the shell/missile in flight, but it isn't 100% reliable, and relys on using the nearestobject command, every 0.01 seconds, which isn't going to be good on low end machines. I know how to add the event handler, but I'm not sure of the syntax for using one of the returned values to determine which script to run. I thought of something like this.......
aircraft addEventHandler ["fired",{if (this select 4) == "shell/missilename" then (exec "myscript.sqs}]
But OFP doesn't like it or anything I can think of. Anyone know how to write it? Thanks in advance.
-
You have the right idea, but your syntax is wrong:
aircraft addEventHandler ["fired",{if ((this select 4) == "shell/missilename") then {exec "myscript.sqs"}}]
Always triple-check and make sure you have a closing parenthesis for each opening one.
-
Oh yeah, that wasn't coppied and pasted from the mission editor, thats just what I wrote here. Now, I coppied and pasted yours, and I think I'm getting warmer, but now I get
if ((this select 3) == "shell/missilename") then {exec "myscript.sqs"} error select : type object, expected array
So I'm not sure that what I'm doing isn't fundamentally wrong somewhere. Here is the arguments for the "Fired" event handler....
"Fired" string:weapon,string:muzzle,string:mode,string:ammo
Here is my full line of code....
this addEventHandler ["fired",{if ((this select 4) == "FLKAW_AIM9L") then {exec "fox2.sqs"}}]
Where "FLKAW_AIM9L" is the name of my ammo. Any clues anybody? I still think its a syntax thingy...
-
hmmmmmm......should it be _this select 4 instead of this select 4 ?
Planck
-
Hehe, buy that man a beer! :D
Thankyou, problem solved. Watch out for the mission in the Falklands MOD, its coming along nicely!