Home   Help Search Login Register  

Author Topic: Not more Zero Divisor Errors!  (Read 1537 times)

0 Members and 1 Guest are viewing this topic.

Offline Lone~Wolf

  • Mission Tools & Mods
  • Members
  • *
  • Vladimir Dmitri Mikhail Andreevich Stamenov
Not more Zero Divisor Errors!
« on: 25 Mar 2010, 22:13:38 »
 :weeping: :weeping: :weeping:

I am on the point of mental collapse,

I have a set of scripts that each activate one another, and each time my person dies, I get an "Error! Zero Divisor!" error.

I have done an OFPEC search and have tried every solution I have found to similar previous problems, but NONE WORK!

   Very much in dispair,
        Lone-Wolf

Code: [Select]
[a1,aresp1,cgrp0] exec "TV_IndieAmbioSymbiot_Crawler.sqs"
Code: [Select]
~1
#BEGIN
direction = preprocessfile "direction.sqf";
closesttarget = preprocessFile "closesttarget.sqf";
_c = _this select 0
_resp = _this select 1
_agrp = _this select 2
? (_agrp == nil) : goto "BEGIN"
[_c,_resp,_agrp] exec "TV_IndieAmbioSymbiot_Crawler_Health.sqs"

Code: [Select]
#START
~1
_c = _this select 0
_resp = _this select 1
_grp = _this select 2
_dcount = 0
_drand = (3+(random 3))
_c setdammage 0.7
_c addrating (-(rating _c)-10000)


#LOOP
@ ((getdammage _c > 0.85) || (getdammage _c < 0.7))
_c setdammage 0.8
_c switchmove "CivilLyingPutDownToCivilLying"
_dcount = _dcount +1
?_dcount > _drand: goto "DIE"
goto "LOOP"


#DIE
_c setdammage 1
~((random 2)+3)
"Bullet4x23" createvehicle (position _c)
deletevehicle _c
[_resp,_grp] exec "Tv_SPAWN.sqs"
exit

Code: [Select]
_obj = _this select 0
_cgroup = _this select 1
"Civilian3" createunit [(position _obj),group _cgroup,"[this] exec {TV_IndieAmBioSymbiot_Crawler.sqs}", 0.6, "corporal"];
exit

Each piece of code above corresponds to the relevant part of the next script in the sequence.

Also, if anyone sees any errors in any other part of the scripts, please let me know.
« Last Edit: 26 Mar 2010, 17:24:21 by Lone~Wolf »
Snarling creature, lurking in the background, still writing in .sqs

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Not more Zero Divisor Errors!
« Reply #1 on: 25 Mar 2010, 23:29:06 »
I can't seem to see your attachments. ???

Preliminary comment: You probably already know this, but "zero divisor" errors are often caused when the select command is used with a number greater than or equal to the number of elements in an array. E.g., the following code will probably lead to a zero divisor error:

Code: [Select]
_array = [blah1, blah2, blah3]
_thing = _array select 3
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: Not more Zero Divisor Errors!
« Reply #2 on: 26 Mar 2010, 22:27:47 »
I am also facing that same problem but mine is with the primary arguments.
[unitname,carname,damagename,timename] exec "damagecar.sqs"

_unit=_this select 0;
_car=_this select 1;
_damage=_this select 2;
_timedamage=_this select 3;
if (isNil "_damage") then {_damage=0.1};
if (isNil "_timedamage") then {_timedamage=11};
#loop
if (_timedamage ==0) then {exit};
_car setdammage getdammage _car + _damage;
_timedamage=_timedamage - 1;
~1
goto "loop"

As you can see the above script damages the car within the given time.
The problem is if you left both the damage and timedamage empty in the arguments
e.g    [player,jeep1] exec "damagecar.sqs"
An error popped out and says
"_timedamage=_this
  • select 3

error : zero divisor"
(Is there any solutions to this problem?)
Regards,
Haroon1992
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Not more Zero Divisor Errors!
« Reply #3 on: 26 Mar 2010, 23:01:38 »
The problem is if you left both the damage and timedamage empty in the arguments....

(Is there any solutions to this problem?)

Don't do that? :whistle:

Sorry, I couldn't resist. :D

First of all, isnil is an ArmA command. This is the OFP scripting board.

If your script was intended for OFP, or if ArmA scripting is similar to OFP (which it is, as far as I've heard), then I think I know your problem. The zero divisor is caused by this line:

Code: [Select]
_timedamage=_this select 3;
_this is the array of arguments passed to a script. Therefore, if you only put 2 arguments in the script, select 3 is going to cause an error. OFP often gives zero divisor errors in this situation, as I described above.
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline Lone~Wolf

  • Mission Tools & Mods
  • Members
  • *
  • Vladimir Dmitri Mikhail Andreevich Stamenov
Re: Not more Zero Divisor Errors!
« Reply #4 on: 27 Mar 2010, 12:05:29 »
Thanks for all your help guys,  :D

I worked around my problem quite easily enough, but did so without touching upon the source of the error.
In other words, I resorted to using a totally different method that did not deal with any zero-divisor errors.

Hopefully this topic will help others in combatting their arch nemesises,

THE DREADED ZERO DIVISOR  ;)
Snarling creature, lurking in the background, still writing in .sqs

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: Not more Zero Divisor Errors!
« Reply #5 on: 29 Mar 2010, 12:31:14 »
how did you solved it?
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(