OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: GRFoxhound on 01 Apr 2007, 13:43:01
-
Hi all
I am stuck on something here. I am using a script to create random objects. I am attaching a trigger to those objects to see if they are still alive (not present).
In the triggerstatements I have set a script to execute on those objects if they are not alive (not present). However, I cant get it to work. If I use [this] exec ""GRF_iedcreator\ied_desroyed.sqs" the script will execute over a complete different unit which is also on my map� ???
If I give the created object a name, check the name and change "this" into the name of the object it wont work since when I am creating 10 objects the trigger will work on the last created object.
Here is part of the script of what I am trying: _test_object = selected out of an array
GRF_name = "GRF"
_i = 0
#loop
_i = _i + 1
_object = createvehicle [_test_object,[_PosX, _PosY, _PosZ],[],0,"NONE"]
_object setDir random 360
_gamble = random 100
?_gamble < 0 : goto "skip"
_trigg = createTrigger ["EmptyDetector", [_PosX, _PosY, _PosZ]]
_trigg setTriggerActivation ["WEST", "PRESENT", false]
_trigg setTriggerArea [_radius, _radius, 0, false]
_trigg setTriggerStatements ["this", "[thislist select 0] exec ""GRF_creator\test.sqs""", ""]
GRF_name = GRF_name+format ["%1",_i]
_object� setVehicleVarName format ["%1",GRF_name]
player sidechat format ["name object should get = %1",GRF_name]
GRF_test_name = vehicleVarName _object
player sidechat format ["name added to the object =%1",GRF_test_name]
_trigg2 = createTrigger ["EmptyDetector", [_PosX, _PosY, _PosZ]]
_trigg2 triggerAttachVehicle [GRF_ied]
_trigg2 setTriggerArea [_radius, _radius, 0, false]
_trigg2 setTriggerActivation ["VEHICLE", "NOT PRESENT", false]
_trigg2 setTriggerStatements ["this", "player sidechat ""created trigger works, how about the script""; [this] exec ""GRF_creator\test_desroyed.sqs""", ""]
goto "loop"
As explained above, if I change _trigg2 setTriggerStatements ["this", "player sidechat ""created trigger works, how about the script""; [this] exec ""GRF_creator\test_desroyed.sqs""", ""] into _trigg2 setTriggerStatements ["this", "player sidechat ""created trigger works, how about the script""; [GRF_test_name] exec ""GRF_creator\test_desroyed.sqs""", ""]
it always returns on the last created object, even though the name of each object created is different each time.
I hope someone knows how I can check if my created object is not alive anymore and than execute a script on it.
I cant use on ongoing looping script, it must be done with a trigger that executes when the attached object is not present.
Thanks again for the help� :good:
-
If you've given the created object a name, you could add an event handler after its creation that will run a script when the object is not alive, thus saving lag on having too many triggers and potentially solving your problem:
OBJECT addEventHandler ["killed",{_this exec "OBJECTKilled.sqs"}]
-
Thats indeed a very smart idea, however, am I correct in remembering the EV "killed" is only local? The script I made is only executed on the server.
Sorry, my mistake. I should have mentioned this in my start post :-[
-
it must be done with a trigger that executes when the attached object is not present.
this is technically a trigger :D ....after the _object is created add:
_object exec "check.sqs"Then use check.sqs to execute your command...
_obj = _this
@!(alive _obj)
~5
deletevehicle _obj
exit;
Not sure if this helps - but it's what i would do ;)
-
it must be done with a trigger that executes when the attached object is not present.
this is technically a trigger :D ....after the _object is created add:
_object exec "check.sqs"Then use check.sqs to execute your command...
_obj = _this
@!(alive _obj)
~5
deletevehicle _obj
exit;
Not sure if this helps - but it's what i would do� ;)
Thanks for the help mych appreciated.
But I really dont want to run check scripts, cause there could be running a lot in the end.
I did do some work on the "eventhandler" did some simple tests and it seems to be working correct.
I do some good testing later soon you will see the script ;)
Thanks for all the help and suggestions :)