csj 0 Posted May 23, 2005 I am trying to set damage on all crew in vehicle for given status quo of vehicle. Anyway the code worked on player and driver _vehicle etc but I want to do the whole group session thing. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _vehicle = _this select 0 _crew = crew _vehicle _c = count _crew _i = 0 -(bla bla bla)- #loop _unit = _crew select _i _unit setdammage _VehStatus _i = _i + 1 ?_i < _c: goto "loop" goto "eslewhere" -(bla bla bla)- _unit = _crew select _i - Â gives err "Error Zero Divisor" Why is it so ? I have simular/same setup in other scripts with no problems. Share this post Link to post Share on other sites
UNN 0 Posted May 23, 2005 Zero Divsor is always down to trying to select an array element that does not exist. Try changing your script to: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _c = count _crew If (_c>0) Then {_c=_c-1} Else {goto "elsewhere"} _i = 0 It's the age old problem of combining Count with arrays that start indexing from 0. If you don't need to add a pause between each line, use the foreach command. It avoids you having to include all the counts, re-indexing and empty array checks. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vehicle = _this select 0 _crew = crew _vehicle -(bla bla bla)- {_x setdammage _VehStatus} ForEach (_crew) goto "eslewhere" -(bla bla bla)- Share this post Link to post Share on other sites
csj 0 Posted May 23, 2005 woohoo cool bananas Thanks UNN, that's another one I owe yah Share this post Link to post Share on other sites