Home   Help Search Login Register  

Author Topic: createvehicle and triggerAttachVehicle  (Read 1773 times)

0 Members and 1 Guest are viewing this topic.

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
createvehicle and triggerAttachVehicle
« 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
Code: [Select]
[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:
Code: [Select]
_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
Code: [Select]
_trigg2 setTriggerStatements ["this", "player sidechat ""created trigger works, how about the script""; [this] exec ""GRF_creator\test_desroyed.sqs""", ""] into
Code: [Select]
_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:


Offline LeeHunt

  • Former Staff
  • ****
  • John 21:25
Re: createvehicle and triggerAttachVehicle
« Reply #1 on: 01 Apr 2007, 13:53:07 »
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"}]


Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: createvehicle and triggerAttachVehicle
« Reply #2 on: 01 Apr 2007, 14:11:14 »
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  :-[

Offline D_P_

  • Members
  • *
  • YAY! I'm a lama again! ...oh wait.
    • ArmaAddons
Re: createvehicle and triggerAttachVehicle
« Reply #3 on: 01 Apr 2007, 18:46:55 »
Quote
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:

Code: [Select]
_object exec "check.sqs"Then use check.sqs to execute your command...

Code: [Select]
_obj = _this

@!(alive _obj)
~5
deletevehicle _obj
exit;
Not sure if this helps - but it's what i would do  ;)

just setpos & forgetpos!

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: createvehicle and triggerAttachVehicle
« Reply #4 on: 01 Apr 2007, 20:39:27 »
Quote
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:

Code: [Select]
_object exec "check.sqs"Then use check.sqs to execute your command...

Code: [Select]
_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 :)