chops 111 Posted July 30, 2007 Hi, I'm trying to create a script where a flare is created at a certain height (on the way down), after an artillery shell having been fired... this AddEventHandler ["fired",{_this exec "scripts\flare.sqs"}] calls... "flare.sqs" Quote[/b] ]_firer = _this select 0 _ammo = _this select 4 _shell = nearestObject [_firer, _ammo] ~5 @ (getpos _shell select 2 <=100) player sidechat "Flares" flare1 = "F_40mm_White" createvehicle getpos _shell deletevehicle _shell flare1 setVelocity [0, 0, 1] _firer removeEventHandler ["fired",0] exit It's for an artillery script I'm working on, it just doesn't seem to work I get the "Flares sidechat five seconds after firing, so I guess the problem lies with detecting the heigt of the shell. The shell itself is also not being deleted. I originally wrote this for OFP and it worked fine. Anyhelp would be greatly appreciated! Thanks. Share this post Link to post Share on other sites
dmarkwick 261 Posted August 15, 2007 Try getting the positional info of the flare when it activates and putting it up on the screen. See if it's where you think it's supposed to be. Share this post Link to post Share on other sites
InqWiper 0 Posted August 15, 2007 I think that the problem might be that it takes so long for the script to execute that the shell is further than 50 meters away from _firer when the script gets to that point and therefore the shell is not caught with nearestobject. Try catching the shell in the eventhandler first and then use the shell to exec the script: this addeventhandler ["Fired",{nearestobject [_this select 0,_this select 4] exec "scripts\flare.sqs"}] -edit Oh, and you might want to delete the shell before you create the flare in its position so they dont collide. Share this post Link to post Share on other sites
DBO_ 0 Posted August 15, 2007 hi, same as inqwiper says but also i notice in arma its not enough to createvehicle anymore ,you must also after creating use setpos ,because new collision detection dosent like 2 things same place at same time when creating , so you sometimes have to use setpos in this case i sugeest you septos the flare .2 of a meter above where shell is .so same as your sqs but add underneath created _flare <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> flare1 = "F_40mm_White" createvehicle getpos _shell _shellx = getpos _shell select 0 _shelly = getpos _shell select 1 _shellz = getpos _shell select 2 _shell setpos [_shellx,_shelly,_shellz+.3] also reduce your ~5 to a 1.5 this way you will avoid the first instance of shell < 100 and easily catch the second instance because shell will be alive.where as with ~5 it is most likely shell has long since died before your script even creates the flare. Share this post Link to post Share on other sites
chops 111 Posted August 18, 2007 Thanks a lot for your help gents. But I haven't had any success yet. @Inqwiper With <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">his addeventhandler ["Fired",{nearestobject [_this select 0,_this select 4] exec "scripts\flare.sqs"}] what should I start the script with? @ofp2, the shell is airbourne for about 60 seconds, no prob catching the second instance of _shell < 100. Also if Quote[/b] ]flare1 = "F_40mm_White" createvehicle getpos _shell is still there, it's still being created at the same spot, no? I'm not sure that's the problem though as I have tried creating flares at the same pos as aircraft without problems.Thanks again fellas! Edit: Nevermind! It all works now! Share this post Link to post Share on other sites
DBO_ 0 Posted August 18, 2007 glad you got it working chops. what i was saying is that sometimes the engine will not create things in the same place which is occupied by something else, only sometimes its very unpredictable , i guess just a small price for new collision detection. also it will not create at the pos select 2 sometimes and the object created is just on the ground . so i always make sure by setting pos again with x,y,z co-ords. Share this post Link to post Share on other sites