Home   Help Search Login Register  

Author Topic: repeated trigger should NOT be activated by same unit.  (Read 2992 times)

0 Members and 1 Guest are viewing this topic.

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: repeated trigger should NOT be activated by same unit.
« Reply #15 on: 26 Aug 2006, 22:58:27 »
Well..........my brain is cooking. Spend 2 days to get this to work but it just wont.

Code: [Select]
{if ((typeOf _x) == "MAN" and _x == vehicle _x) then {_list = _list + [ _x] }} forEach  list _trigger
Doesnt work, _list returns nothing so
Code: [Select]
_unit = _list select _i
doesnt make sense since its empty. So I can not tell the _unit to do something.

It all has to do with
Code: [Select]
{if ((typeOf _x) == "MAN"
Since thats never true. Foreach makes it check an array but its cant see the "TANK", "MAN", "CAR" array, it can only see its class, so its always "not equal" and so it doesnt update _list.
I can make the script check all units if I make it
Code: [Select]
_list = list _trigger
But than still, I cant make "typeof" to see if its armor, car or man.

The only solution I see for me is I have to add "typeof" for every class I have in my mission and redirect it to the correct script section for each unit I get out of my _list.

Right?

Sorry if people start to think this is becomming annoying, but I just cant figure it out anymore other than adding "typeof" for each class I have in my script.


Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: repeated trigger should NOT be activated by same unit.
« Reply #16 on: 27 Aug 2006, 16:50:12 »
Not a problem m8. No one minds helping someone who is trying hard himself. Just realised I misused typeOf which only returns exact type of unit, not parent class types. Try the corrected code below which uses countType instead. I know this works cause I actually tested it! :)

mancheck.sqs
Code: [Select]
_trigger = _this select 0
#mainloop
;make list
_list = []
{if (("MAN" countType [_x]) > 0 and _x == vehicle _x) then {_list = _list + [ _x] }} forEach  list _trigger
;execute code for each item in list
_i = 0
#actionloop
_unit = _list select _i
; ... your code goes here to act on _unit ...
_i = _i + 1
if (_i < (count _list)) then {goto "actionloop"}
;small pause maybe?
~2
goto "mainloop"

carcheck.sqs
Code: [Select]
_trigger = _this select 0
#mainloop
;make list
_list = []
{if ("CAR" countType [_x]) > 0) then {_list = _list + [ _x] }} forEach  list _trigger
;execute code for each item in list
_i = 0
#actionloop
_unit = _list select _i
; ... your code goes here to act on _unit ...
_i = _i + 1
if (_i < (count _list)) then {goto "actionloop"}
;small pause maybe?
~2
goto "mainloop"
urp!

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: repeated trigger should NOT be activated by same unit.
« Reply #17 on: 27 Aug 2006, 22:33:59 »
 :clap:

Thank you very much Mr.Peanut. This works just perfectly sweet. I learned a lot of good stuff with this topic!!
I already said it but I should say it again:

This is a great place, thank you all for the time to help me.   :good: