OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Kilo11 on 01 Jun 2004, 22:38:31
-
Alright Im making a mission with a downed pilot. The whole "get there before the russians do" type. I made a very simple script allowing for when any friendly unit reaches within 25 feet from the pilot, the pilot will join that closet unit, and for some reason it wont work. Any unit that comes to the pilot....the pilot wont join !!! AHH...so tell me what is wrong with this:
;RESCUE.sqs by Hoot
_rescuer=[player,bravo]
_pilot=pilot
#check
~5
_dis=99999
{_d=_pilot distance (leader _x);if (_d<_dis) then {_dis=_d;_closest=_x}} foreach _rescuer
?_dis > 25:goto "check"
[_pilot] join _closest
exit
If anyone could jsut tell me what is wrong, and mabey make an example mission or soemthing or exact directions w/e. Help is appreciated! THANK YOU!
-=Kilo=-
-
Anyone :-(.....
-=Kilo=-
-
try changing the last line to -
[_pilot] join (leader _closest)
so that he joins the group of the closest soldier. If the rest of your syntax is correct it should work. If all the rescuers are individuals and not part of a group then I don't know whats wrong...must be syntax.
-
{_d=_pilot distance (leader _x);if (_d<_dis) then {_dis=_d;_closest=_x}} foreach _rescuer
It may just be my ignorance, but won't ; in the middle make the second and third bits just notes, not active code?
Also, _rescuer has only two elements. If you're only trying to check two distances you could do it simply and seperately.
-
Hi,
You cant initialize a variable inside an IF statement.
_closest need to be initialize before the if statement.
Just give it a value at the beginning of the script.
Cheers