Jump to content
Sign in to follow this  
hoz

Deleting dead bodies

Recommended Posts

Ok I got my script deleting the dead bodies finally. Big catch is you need to know their names or stuff them into an array which is what I did. I will eventually sink the dead bodies and then delete but for now the dudes just disappear after death.

Now when I run my script I get an error. Error zero divisor. How can i get rid of this error? It always happens on the second kill. Can anyone point out where I am going wrong?

Edit: The bold section is the line i get the error on.

?(!local Server): Exit

unitslist = [u1,u2,u3,u4]

_d=(count unitslist)

#searchloop

_noarray= count unitslist

? _noarray==0 :goto "end"

_unit = unitslist select _x

?(!alive _unit) : goto "deleteunit"

_x=_x+1

? _x == _d : _x = 0

goto "searchloop"

#deleteunit

unitslist = (unitslist-[_unit])

deletevehicle _unit

~.01

goto "searchloop"

#end

hint "ending"

exit

Share this post


Link to post
Share on other sites

Yes that probably was your only problem. Well actually no... </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">#searchloop

.

.

.

goto "searchloop"<span id='postcolor'>

You need a ~0.01 in there if possible.

EDIT: (If you have 1.85+)

I have just dealt with the problem of deleting dead men so I can suggest you use addEventHandler of type "killed" on every soldier. Make it call a script where you remove the handler and delete the soldier. I believe that is much less CPU intensive.

Share this post


Link to post
Share on other sites

I tried the eventhandlers, but i haven't got a handle on them yet smile.gif

I tried replacing

? _x == _d : _x = 0

with

? _x == _d : _d=(count unitslist)-1

Is that what you ment? That just gets me to the error quicker.

I added the ~.01 but didn't make a difference.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?(!local Server): Exit

unitslist = [u1,u2,u3,u4]

_d=(count unitslist)-1

_x=0

#searchloop

~0.1

_noarray= count unitslist

? _noarray==0 :goto "end"

_unit = unitslist select _x

?(!alive _unit) : goto "deleteunit"

_x=_x+1

? _x == _d : _x = 0

goto "searchloop"

#deleteunit

unitslist = (unitslist-[_unit])

deletevehicle _unit

~.01

goto "searchloop"

#end

hint "ending"

exit <span id='postcolor'>

Share this post


Link to post
Share on other sites

Ok I tried that and now I am getting the error less frequent but I still get it.

Hoz

Edit: I am getting the error on the 3rd kill now oppose to the second kill before.

Share this post


Link to post
Share on other sites

How is it In this case ?

init.sqs

unitList=[]; ;unit added in game

remove.sqs

#start

_unitCnt=count unitList;

_unitIndex=0;

?(_unitCnt==0):goto "done";

#removeUnitLoop

_unit=unitList select _unitIndex;

?((getDammage _unit)!=1):_unitIndex=_unitIndex+1;goto "nextUnit";

unitList=unitList-[_unit];

deleteVehicle _unit;

_unitCnt=_unitCnt-1;

_unitIndex=0;

#nextUnit

?(_unitIndex<_unitCnt):goto "removeUnitLoop";

#done

~120

goto "start"

It`s not remove about 10 or 20 percent of dead bodies . (Vehicles are removed unexceptionally )

How should I change this ?

     Thanks.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×