Jump to content
Sign in to follow this  
TriGGa

Remove Dead Corpses

Recommended Posts

Im wanting to run a script every so often to clean out the server of dead bodies, I tried the following script:

_corpse  = _this select 0;

sleep 360;

deleteVehicle _corpse;

But i believe this is for a single corpse, how can I edit so I can make this delete all dead corpses in the server?

Share this post


Link to post
Share on other sites

but doesnt "_this select 0;" make it only for the 1 corpse?

Share this post


Link to post
Share on other sites

all "_this select 0" does is the following.

if you execute a script like this

0 = [dude1,100,true] execVM "script.sqf";

you will send information into the script (script.sqf) that can be used by it. inside the script _this stands for the object/array that executes the script. in this case it's an array. an array is a collection of values/objects inside a brackets like these [].

so if you do this inside a script

_corpse = _this select 0;

all it does is select the first entry (it starts with 0 not 1) of the array you sent to the script and gives it a new variable so you can go on working with it.

so in the the case of

0 = [dude1,100,true] execVM "script.sqf";

dude1 is _this select 0

100 is _this select 1

true is _this select 2

this is just a random example but it shows that you can make scripts very flexible with this. 100 could be a time delay in seconds and true could be an optional boolean for a feature of the script.

i'm writing all this down here because it took me a while to figure this out myself since if you have no programming background and know the basics of handling arrays you'll have to just understand stuff by looking at it which can be a tedious process. so i hope this helps you or anyone browsing the forums understand the concept.

having said this...what MadDogX was refering to is the example on the wikipage of "alldead" not the script example you posted.

{ deleteVehicle _x } forEach allDead;

this line of code removes all dead units. all you have to do is run it in the intervall you want. like maybe 30-60 seconds. if you want to make it look less abrupt you can use https://community.bistudio.com/wiki/hideBody .

make sure you have a delay of atleast 6 seconds between hidebody and deletevehicle ;)

Share this post


Link to post
Share on other sites

awesome response.... its clearer now, time to put what I have learnt here to the test. Thanks!

Share this post


Link to post
Share on other sites

And what's the most efficient way to pospone deletion until no player is near the body, in SP and MP? SP is of course rather easy, but I'm not sure how to go about when the mission can be run in hosted MP, and dedicated server.

Share this post


Link to post
Share on other sites

Or you could just use Celery's excellent battlefield clearance script "cly_removedead.sqf":

http://forums.bistudio.com/showthread.php?113434-CLY-Remove-Dead-script&highlight=Celery

Call it from a separate script that sets a trigger round each player which is deleted after the clear-up. Any bodies in the trigger area are excluded. Run it at intervals of say 300 seconds or whatever. NB I don't play or make missions for MP so locality might be an issue with this approach.

Edited by Orcinus

Share this post


Link to post
Share on other sites
awesome response.... its clearer now, time to put what I have learnt here to the test. Thanks!

Did you manage to get it working?

Share this post


Link to post
Share on other sites
NB I don't play or make missions for MP so locality might be an issue with this approach.

The problem would be the existence of more than one player :).

Share this post


Link to post
Share on other sites

holy F*** thank you, I have been digging through many many useless time-based / overcomplicated scripts to delete dead, and that one little line of code was all I needed.

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  

×