Home   Help Search Login Register  

Author Topic: Deleting Dead Bodies  (Read 2994 times)

0 Members and 3 Guests are viewing this topic.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Deleting Dead Bodies
« on: 23 Nov 2002, 07:14:45 »

I have been trying to delete dead bodies that I have created on the fly. I don't want to delete the alive west units just the dead ones. The number of bodies is becoming excessive. I can't seem to get it to work. Can anyone help?


#loop
_deaddudes=+(list triggertest)
_noarray=count _unitlist
?(_noarray==0):goto "end"
_unit=_deaddudes select 0
? (alive _unit) : goto "loop"
deletevehicle _unit
~0.01
goto "loop"

#end

exit
Xbox Rocks

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re:Deleting Dead Bodies
« Reply #1 on: 25 Nov 2002, 02:03:39 »
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


Hoz
« Last Edit: 25 Nov 2002, 02:07:56 by hoz »
Xbox Rocks

dreaming_adam

  • Guest
Re:Deleting Dead Bodies
« Reply #2 on: 27 Nov 2002, 17:22:50 »
Simple... Visit the editors department of this site (http://www.ofpec.com/editors/index.php) go to the TUTORIALS section, click the MP LAG ELIMINATOR tutorial of mine and customise it to your needs... that way you dont have to bother with arrays, which is good especially if you create units runtime using createunit.

hint: add a check for ?(side == west) if you dont want to delete all sides bodies

and edit delbody.sqs, put in a simple loop and instead of setpos to [0,0,0] setpos the body using a negitive value in the loop. That will make it sink into the ground...

besides, the script in the tutorial uses ONE trigger, and has about 8 lines of code.

cheers!
Adam

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re:Deleting Dead Bodies
« Reply #3 on: 27 Nov 2002, 19:27:45 »
Ok I tried out your script but there are problems with your script.

For instance on your foreach command you don't close the ".
Without close it you receive Error invalid number in expression.
And if you close the quote you receive the same error.

I'll try and work around this when I get home :)

Edit:
I don't see where your selecting a unit before you check to see if unit is alive?

#loop
_eunit = list triggertest
?(!alive _x):"[_x] exec {dead.sqs}" foreach _eunit
goto "loop"



Thanks,
Hoz
« Last Edit: 27 Nov 2002, 19:36:44 by hoz »
Xbox Rocks

dreaming_adam

  • Guest
Re:Deleting Dead Bodies
« Reply #4 on: 28 Nov 2002, 06:15:56 »
Appologies for the left out inverted commas... That sometimes happens when you type up tutorials at 3AM.  :-\

I have corrected this in the tutorial... thanks for pointing it out :)

BTW in your previous posting you placed the " in the wrong place. Please re-vist
http://www.ofpec.com/editors/tutorial_view.php?id=117 and recopy the script.

Please read the tutorial a little more carefully. You will notice that you need to place a trigger with a radius covering your whole map.
The _eunit local variable is set to "list EVERYUNIT". This means that _eunit is an array with EVERY unit that lies in the trigger zone. Seeing as the trigger zone is set to cover the whole map, this includes every unit on the map.
The foreach command steps through every unit in the array and tests to see if it is alive. If it isnt, then the units name is passed onto the delbody script.

Cheers and thanks for pointing out the missing "

Adam
« Last Edit: 28 Nov 2002, 06:18:55 by dreaming_adam »

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re:Deleting Dead Bodies
« Reply #5 on: 28 Nov 2002, 07:14:23 »

I still get the error in this line:
"?(!alive _x):[_x] exec {dead2.sqs}" foreach _eunit
Invalid number in expression.

Xbox Rocks

dreaming_adam

  • Guest
Re:Deleting Dead Bodies
« Reply #6 on: 28 Nov 2002, 18:45:31 »
I am terribly sorry for this! I accidently used the experimental foreach script instead of the working loop one in the tutorial :-[ I have updated the tutorial now, and have also included some updates to make it a) more efficient, and b) the bodies dont dissapear, they sink into the ground before being deleted.

Once again sorry for the inconvienience!

Ciao Ciao
Adam

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re:Deleting Dead Bodies
« Reply #7 on: 28 Nov 2002, 19:04:51 »


No inconvience here :)

I still can't get your scripts to work. I'm not getting any errors but the dudes aren't disappearing.

I'll play some more once i get home

Hoz
Xbox Rocks

dreaming_adam

  • Guest
Re:Deleting Dead Bodies
« Reply #8 on: 28 Nov 2002, 19:08:55 »
Hmmm... Well this time I tested them and the scripts seem to be working fine... You did place a trigger in the mission didnt you? and you checked that all the variable names are referenced properally?

Cheers
Adam

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re:Deleting Dead Bodies
« Reply #9 on: 28 Nov 2002, 19:13:35 »


Yes all the triggers are correct and variables. I'll check into it more later.

The only difference I have is I am accelerating the time to disappear. I have it set for ~5   (no use in waiting around)

Thanks for the help and quick response.
Hoz
Xbox Rocks

dreaming_adam

  • Guest
Re:Deleting Dead Bodies
« Reply #10 on: 28 Nov 2002, 19:18:46 »
Hmmm... What version of OFP have you got? Needs to be v1.34 or above.

I will upload the EXACT scripts as I have them in one of my missions for you...

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re:Deleting Dead Bodies
« Reply #11 on: 28 Nov 2002, 19:23:12 »
You should have attached the sqm file :)

I 'm not setting a gamestatus so I see that its exiting the script it seems.
I added a loop to the end and removed the gamestatus and I got one dude to disappear.  So now its kinda working.

I got the latest version of OFP and I have been editing scripts for some time now so I have a good understanding of whats going on. (most of the time) :))

Hoz

Xbox Rocks

dreaming_adam

  • Guest
Re:Deleting Dead Bodies
« Reply #12 on: 28 Nov 2002, 19:29:07 »
Ahhh.... Of course... Game status.... (runs back to edit his tutorial yet again) lmao

Sorry bout that yet again!

Oh and as for the mission.sqs file, its part of the battle royale suite im making, of course that is going to be freely distributed so its not that I dont want you to see, but rather it is VERY messy at the moment... There are about 20 addons that Ive compiled myself that I have to place into one PBO addon to be included with the mission... Additionally, there are about 15 scripts, incuding dialogs, purchase weapons, player money handling, team-kill scripting, AI tank and aircraft control, and various other scripts.... All very messy... And the entire mission including addons would well exceed the 50KB limit on files on OFPEC.

If you have any further questions tho, I am more than happy to answer them :)

Ciao ciao

Adam

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re:Deleting Dead Bodies
« Reply #13 on: 28 Nov 2002, 19:35:46 »


Ok well in your tutorial your scripts are different then that of the scripts you attached.

?(count list EVERYUNIT < 2):goto "loop"  In the one script isn't in the ones you attached.


I got 2 bodies to disappear now just by changing the order of who I shoot first.

dam i have to get back to work soon :)
Xbox Rocks

dreaming_adam

  • Guest
Re:Deleting Dead Bodies
« Reply #14 on: 28 Nov 2002, 19:42:24 »
Work? What is this "work" you speak of? Does it go well with Blue Castello cheese and Water Chestnuts?


That line that isnt in the attached script file is an addition that it to prevent getting DIVISION BY ZERO errors that are caused by the trigger only containing one unit.

I am prolly going to be of no help at the moment because it is 4:45AM and my brain is mush.

Cheers
Adam