Jump to content
Sign in to follow this  
BigRed

Removing Deadbodies

Recommended Posts

This is the script I used in OFP but doesn't work in ArmA 2 can someone help me out?

This is in the init file:

[]exec "Clearcorpse.sqs"

then the Clearcorpse:

?(!local server):exit

_n=-1

#loop

?(count (list EVERYUNIT) < 2):goto "loop"

_curlist = list EVERYUNIT

#loop2

_n = _n + 1

?(!alive (_curlist select _n)): [(_curlist select _n)] exec "common\delbody.sqs"

?(_n < (count _curlist)):goto "loop2"

_n=0

?(MISSIONSTOP):exit

goto "loop"

exit

the delbody:

; Select the Unit

_unit = _this select 0

;-Delay the delete after death

~15

; delete the unit

deletevehicle _unit

exit

Share this post


Link to post
Share on other sites

You may be better off with something more... simple (could there be :p).

Execution:

_xhandle = execvm "clearCorpses.sqf"

clearCorpses.sqf

private ["_aU", "_dU"];
_aU = allUnits;

while {true} do {
sleep 60;
if (count _aU != count allUnits) then {
	_dU = _aU - allUnits;
	{hidebody _x} foreach _dU;
};
_aU = allUnits;
};

SQF all the way mate.

Share this post


Link to post
Share on other sites

I will give it a go thanks Rommel;)

Share this post


Link to post
Share on other sites

No, it cleans up memory problems with certain modules AFAIK.

Share this post


Link to post
Share on other sites

It can go anywhere you want it too, but yes the init.sqf should hold it fine. :)

Share this post


Link to post
Share on other sites

You can sweep it with Garbage Collector, it will remove a desired (dead) object when the player (or a group member) is further than 500 meters.

It Also sweep empty groups.

Use it like that (NOTE: don't use it server side!):

//--- Delete body (Garbage Collector)
[_unit] call BIS_GC_trashItFunc;

GC:

scriptName "garbage_collector\data\scripts\process_queue.sqf";
/*
File: process_queue.sqf
Related: garbagecollector.fsm
Author: Joris-Jan van 't Land

Description:
Process the garbage queue for the Garbage Collector FSM.
*/

//TODO: dangerous and does not work on dedicated server. Allow registering important units to the GC through a function?
private ["_mainGrp", "_queue"];
_mainGrp = group player;
_queue = BIS_GC getVariable "queue";

for "_i" from 0 to ((count _queue) - 1) do
{
private ["_entry", "_time"];
_entry = _queue select _i;
_time = _entry select 1;

//Check the object was in the queue for at least the assigned time (expiry date).
if (_time <= time) then
{
	private ["_object"];
	_object = _entry select 0;

	switch (typeName _object) do
	{
		case (typeName objNull):
		{
			//Player and his squadmates cannot be too close.
			//ToDo: use 'cameraOn' as well?
			if (({(_x distance _object) <= 500} count (units _mainGrp)) == 0) then
			{
				deleteVehicle _object;
				_queue set [_i, -1];
			};
		};

		case (typeName grpNull):
		{
			//Make sure the group is empty.
			if (({alive _x} count (units _object)) == 0) then
			{
				deleteGroup _object;
				_queue set [_i, -1];
			};
		};

		default {};
	};
};
};

_queue = _queue - [-1];
BIS_GC setVariable ["queue", _queue];

true

Edited by Benny.

Share this post


Link to post
Share on other sites

It worked thanks Rommel and Ziggy, I did put it in the init and it works like a champ!

Share this post


Link to post
Share on other sites
You may be better off with something more... simple (could there be :p).

Execution:

_xhandle = execvm "clearCorpses.sqf"

clearCorpses.sqf

private ["_aU", "_dU"];
_aU = allUnits;

while {true} do {
sleep 60;
if (count _aU != count allUnits) then {
	_dU = _aU - allUnits;
	{hidebody _x} foreach _dU;
};
_aU = allUnits;
};

SQF all the way mate.

**update tried with a spawning unit script and seems to work very nicely, thank you**

Edited by Ghost

Share this post


Link to post
Share on other sites

i cant seem to be able to get it to work, could you explain the condidtions to me?

ie sleep 60? is that 60 seconds? minutes? units?

i have a small 8 player dm which builds up bodies quick and would appreiate a way of removing them :D

cheers

Share this post


Link to post
Share on other sites

The loop removes burries all dead every 60 seconds.

Edited by Heatseeker

Share this post


Link to post
Share on other sites

hmm ok, didnt seem to work for me, i even tried setting it to 10, ill try again in the morning.. well when i get up as its 2:20am ... hehe

cheers

Share this post


Link to post
Share on other sites

Hi,

This script works great so far. However, would it be possible to add some code which deletes vehicles as well?

Share this post


Link to post
Share on other sites

Hi ,i second what Gaffa said about adding a line for vehicles.

Ive tried the examples in Mr Murrays Guide ,with and without ,niether worked for me.

So i ended up using Rommels which worked like a treat.

But it would be even better if it got rid of vehicles.

Any one else who has managed to over come this could u plz help.

Share this post


Link to post
Share on other sites

If this script only buries bodies, is it actually reducing the burden on the server?

Also in testing on a dedi server I've noted that it causes some bodies to linger behind and bounce in mid air.

Share this post


Link to post
Share on other sites
If this script only buries bodies, is it actually reducing the burden on the server?

Also in testing on a dedi server I've noted that it causes some bodies to linger behind and bounce in mid air.

Burying body = deleting bodies. They are first buried, then deleted.

Share this post


Link to post
Share on other sites
Cool.

Anyone else experienced or solved the bouncy bodies bug?

Ya, hideBody isn't reliable. Add a small sleep and then a deleteVehicle in case it doesn't work.

Share this post


Link to post
Share on other sites

Having never seen this bouncy bodies problem. However as suggested, a simple deletevehicle after a few seconds should be suffice. :yay:

Share this post


Link to post
Share on other sites

Tried the hidebody script.

Is this supposed to be for player bodies, AI units or both?

The one time it worked, it only half buried the AI units and never deleted them...

Edited by DrStrangeLove_EBDA

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  

×