Home   Help Search Login Register  

Author Topic: Ofp Gone Beserk (I need help)  (Read 776 times)

0 Members and 1 Guest are viewing this topic.

Chris330

  • Guest
Ofp Gone Beserk (I need help)
« on: 01 Sep 2004, 11:31:37 »
Have a look at this. I assigned a letter to be a number with the intention of incrementing it later. I have used this same convention on test scripts to ake sure it could be done. It will not however work with one mission I am using. how can ofp allow it to work one time and not another!!!!!!!!

Here's the code, the area I mean highlighted in bold:

_n = 0
trans1 lockwp true

#jumpout
_unit = units alpha select _n
?_unit == player : DisableUserInput true
unassignvehicle _unit
_unit action ["EJECT"]
?_unit == player: DisableUserInput false
_n = _n + 1
incount = "_x in trans1" count units alpha
?incount == 0 : goto "withdraw"
goto "jumpout"

#withdraw
trans1 lockwp false
trans1 flyinheight 100
trans1 commandmove getpos base

#loop1
?arrived1 : goto "land"
goto "loop1"

#land
trans1 land "LAND"

It keeps coming back saying zero divisor, yet I have used the exact same method for scripting other things with NO PROBLEMS!!!! WTF is going on ???

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Ofp Gone Beserk (I need help)
« Reply #1 on: 01 Sep 2004, 11:35:43 »
I presume alpha has been correctly defined as the  name of a group?
« Last Edit: 01 Sep 2004, 11:35:54 by THobson »

Chris330

  • Guest
Re:Ofp Gone Beserk (I need help)
« Reply #2 on: 01 Sep 2004, 11:59:57 »
Sure has m8 this has got me well stumped! :o

Chris330

  • Guest
Re:Ofp Gone Beserk (I need help)
« Reply #3 on: 01 Sep 2004, 12:08:14 »
I think it's the eject command is screwing up something. Maybe because the first guy to go is the leader. I'll try typing it out for all people in the chopper *sigh*.

Unnamed

  • Guest
Re:Ofp Gone Beserk (I need help)
« Reply #4 on: 01 Sep 2004, 12:13:13 »
The zero divisor error usually means your trying to access an array or array element that is not there, try changing the highlighted line to:

Code: [Select]
_unit = (units alpha) select _n

Chris330

  • Guest
Re:Ofp Gone Beserk (I need help)
« Reply #5 on: 01 Sep 2004, 13:21:54 »
This script eventually cured it. Althoough why I don't know. Helis are dodgy things in ofp >:(

trans1 flyinheight 5
trans1 lockwp true
#loop
_z = getpos trans1 select 2
?_z > 6 : goto "loop"


_units = units alpha
_i = 0


#Here
(_units select _i) action ["EJECT",trans1]
unassignvehicle (_units select _i)
_i=_i+1
~1
_incount = "_x in trans1" count units alpha
?_incount == 0 : goto "finish"
goto "here"

#finish
trans1 lockwp false
trans1 flyinheight 100
?arrived1 : goto "exit"
goto "finish"

#exit
trans1 land "LAND"
exit

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Ofp Gone Beserk (I need help)
« Reply #6 on: 01 Sep 2004, 16:08:34 »
I have not had much time to look through your scripts.  But could this be the problem:

If and array has N elements the index of the array will run from 0 to N-1  So if you attempt to access element N you will be looking beyond the scope of the array and so get an error?

Chris330

  • Guest
Re:Ofp Gone Beserk (I need help)
« Reply #7 on: 01 Sep 2004, 18:30:20 »
Could well be!! I'll have look at that thankyou ;o]

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Ofp Gone Beserk (I need help)
« Reply #8 on: 01 Sep 2004, 20:03:54 »
Incidentally this is how I eject a group (I could not post it earlier as I was at work)
Code: [Select]
; EjectAlpha
; called by [] exec "EjectAlpha.sqs"

_group = units alpha
_count = count _group
_interval = 0.75

_i=0

@atdropzone

#loop

_unit= _group select _i
_unit action ["eject",chopper1]
unAssignVehicle _unit

_i=_i+1
if (_i >= _count) then {exit}

~_interval

goto "loop"

Note atdropzone is a boolean that is set true when the chopper gets to where I want the drop.

Chris330

  • Guest
Re:Ofp Gone Beserk (I need help)
« Reply #9 on: 01 Sep 2004, 23:18:06 »
A big thankyou to THobson  ;) I used your way of writing scripts to make another one which involved one group being split into two vehicles, and them not being able to move until both cars are full. It worked nearly first time!! Nice one mate. I think the original issue was definitely something not being happy with me just using the

xxxx units alpha

throughout my scripts. Giving the units alpha an assigned value like _group for example works far better. here's my other script  :D

_i = 0
_j = 4
_group = units alpha
"_x lockwp true" foreach units alpha

#groupa
_unit = _group select _i
? _unit == leader alpha : goto "drivera"
_unit assignascargo jeep1
_i = _i + 1
?(_i == 4) : goto "groupb"
goto "groupa"

#drivera
_unit assignasdriver jeep1
_i = _i + 1
goto "groupa"


#groupb
_unit = _group select _j
?(_j == 4) : goto "driverb"
_unit assignascargo jeep2
_j = _j + 1
?(_j > 6) : goto "close"
goto "groupb"

#driverb
_unit assignasdriver jeep2
_j = _j + 1
goto "groupb"

#close
_count1 = "_x in jeep1" count units alpha
_count2 = "_x in jeep2" count units alpha
?(_count1 + _count2) == 7 : goto "end"
goto "close"

#end
"_x lockwp false" foreach units alpha
exit




« Last Edit: 01 Sep 2004, 23:18:22 by Chris330 »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Ofp Gone Beserk (I need help)
« Reply #10 on: 01 Sep 2004, 23:21:12 »
Glad I could help