Home   Help Search Login Register  

Author Topic: magazines in array  (Read 516 times)

0 Members and 1 Guest are viewing this topic.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
magazines in array
« on: 29 Aug 2004, 21:11:36 »
Heya,

I use the magazine command to get an array of a units equipment, fine, it works and I get an array. However, how do I check the number of, i.e, M16 magazines from that array? I've tried:

_mags = magazines _unit
_mags2 = "M16" count _mags

but _mags2 returns 0, and I have 4 mags in equipment. I've also tried without qoutationmarks and other stuff but that gives error messages or it returns that scalar boot array things.

Cheers!

:beat: *Gets Shot* :beat:

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:magazines in array
« Reply #1 on: 29 Aug 2004, 21:16:10 »
i think ur code is wrong :P

its more like

"if (_X == ""m16"") then {_mags2 = _mags2+1}" foreach _mags

or somin like dat ;)

check nd den finish dat :P

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:magazines in array
« Reply #2 on: 29 Aug 2004, 21:26:20 »
I did some twirking with that line but they all ended up returning scalar bool array or I got an error message.

:beat: *Gets Shot* :beat:

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:magazines in array
« Reply #3 on: 29 Aug 2004, 21:42:11 »
I wonder if the typeof command will work for this?



Planck
I know a little about a lot, and a lot about a little.

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:magazines in array
« Reply #4 on: 29 Aug 2004, 21:48:29 »
Or, maybe:

_mags2 = "M16" CountType _mags

?

Unnamed

  • Guest
Re:magazines in array
« Reply #5 on: 29 Aug 2004, 22:33:48 »
Quote
I did some twirking with that line but they all ended up returning scalar bool array or I got an error message.

Did you define _mags2 outside the {} brackets? If you dont, _mags2 is only available within the If then {}.

Code: [Select]
_mags2=0
{if (_X == "m16") then {_mags2 = _mags2+1}} foreach _mags

I can never remember the exact syntax for the count command way, but something like this should work:

Code: [Select]
{_x=="M16"} Count _Mags
And what the hell, you could probably do it this way to, if you really wanted:

Code: [Select]
_MagCount=(Count _Mags)-Count (_Mags-["M16"])

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:magazines in array
« Reply #6 on: 30 Aug 2004, 16:30:51 »
D'oh! :P Cheers!

:beat: *Gets Locked* :beat: