Home   Help Search Login Register  

Author Topic: What's wrong with this code?  (Read 435 times)

0 Members and 1 Guest are viewing this topic.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
What's wrong with this code?
« on: 02 Sep 2004, 12:09:47 »
Error message:-

_k = _unitArray select _j# error zero division

The script then either exits or gets trapped in the loop, it certainly doesn't progress.


Code:-


_unitArray = [sn2, sn3, sn4, sn5, sn6, sn7, sn8, sn10, man2]
_i = count unitArray
_j = 0


#loop

_k = _unitArray select _j

_j=_j+1

? _j >= _i :  goto "next"

~0.01

? (("kozliceball" in magazines _k) and ("M60" in magazines _k) and ("PK" in magazines _k) and ("FALMag" in magazines _k)) : deleteVehicle _k

goto "loop"

#next

etc.
« Last Edit: 02 Sep 2004, 12:10:36 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:What's wrong with this code?
« Reply #1 on: 02 Sep 2004, 12:25:28 »
This is a part of my script, try to edit this as it works fine with me, removed some parts that you don't need:

_number = count units (group player)
_units = units (group player)
_i = 0

#loop

_name = (name (_units select _i))

_i = _i +1

? _i >= _number : goto "cont"

~.00001

goto "loop"

#cont

:beat: *Gets Shot* :beat:

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:What's wrong with this code?
« Reply #2 on: 02 Sep 2004, 13:25:54 »
Got it.   Missing " _".     Should have been

_i = count _unitArray


Thanks Armsty .. my code is essentially the same as yours.
« Last Edit: 02 Sep 2004, 13:26:51 by macguba »
Plenty of reviewed ArmA missions for you to play