Jump to content
Sign in to follow this  
ColonelSandersLite

ARMA Script: CSL_Bring_Out_Your_Dead.sqf

Recommended Posts

Bring out your dead, dead body removeal.

usage:

Run this script on man you want to be removed after death.

parameter 1 is a man. may or may not work on vehicles, untested.

Parameter 2 is the amount of time you want the bodies to last in seconds.

usage example:

[soldier1, 300] execVM "CSL_Utility\CSL_Bring_Out_Your_Dead.sqf"

a more flexible way of using this script, is to use a foreach loop and execute it for everyone in the group.

you can even rig up a trigger to make it execute for every man on the map at mission start, then just add this

script call to any spawn scripts you have.

Example trigger to remove everyone who starts in the mission, after they've been dead for 5 mins. (but not vehicles, just men)

trigger x = 99999

trigger y = 99999

anybody present

once

on activation: {if(driver _x == _x) then {[_x, 30] execVM "CSL_Utility\CSL_Bring_Out_Your_Dead.sqf"}} forEach thislist

The point of this is to remove dead bodies to free up those resources for other purposes.

ARMA Script: CSL_Bring_Out_Your_Dead.sqf

Share this post


Link to post
Share on other sites

Wouldn't it be more efficient to use the killed event handler instead of having a script constantly check the status of the object in question?

Share this post


Link to post
Share on other sites

long live Eric Idle wink_o.gif

btw: i'm doing that kind of thing with eventHandlers too. just wish i could hide the bodies first and then delete them, when they can't be seen anymore - but it seems once you started hiding them, they won't get deleted anymore. or am i wrong?

Share this post


Link to post
Share on other sites

@ Strango

The reason I avoided event handlers is that calling this kind of script is a little easier for your average joe that doesn't understand them. That's the only reason I did that. The script could easilly be adapted to do it the other way, but I'm not really interested in that.

My goals in scripting for the community are to make modules that are highly accessible, that your average complete noob scripting wise can drop into a mission and make it work. If the script had been for me, I would have used eventhandlers. Since it's not, I didn't.

@Mongoose_84

My script hides then deletes them. Take a look. It's like the last 3 lines.

I really gotta start proofreading *before* hitting the submit button...

Share this post


Link to post
Share on other sites

Is it me or can I not download this? I am logged into OFPEC, but it keeps asking me to log in over and over again.

Share this post


Link to post
Share on other sites

Works for me, and apparently the others. Try the OFPEC Thread though.

If you can't grab it directly from there. You have som kind of problem with ofpec.

If you can from there, but not here, you probably have some kinda security setting blocking that style of linking.

Share this post


Link to post
Share on other sites

It was a problem with IE7. I used firefox and no problem. Thanks for the script.

Share this post


Link to post
Share on other sites
@ Strango

The reason I avoided event handlers is that calling this kind of script is a little easier for your average joe that doesn't understand them. That's the only reason I did that. The script could easilly be adapted to do it the other way, but I'm not really interested in that.

My goals in scripting for the community are to make modules that are highly accessible, that your average complete noob scripting wise can drop into a mission and make it work. If the script had been for me, I would have used eventhandlers. Since it's not, I didn't.

@Mongoose_84

My script hides then deletes them. Take a look. It's like the last 3 lines.

I really gotta start proofreading *before* hitting the submit button...

have you ever checked, if they really get deleted? i'm not a 100% sure myself, but i once tried hiding and then a second later deleting bodies, so i would still see them and whether they really get deleted or not. and i think they didn't, but i can't say for sure anymore - maybe i made some mistake...

Share this post


Link to post
Share on other sites

I'm 90% sure that I checked it and it works.

If I remember, I just checked it like this:

(it's the script, without comments except for the debugging test I'm talking about here)

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

private ["_removeBodyAfterTime", "_unitToRemoveWhenDead", "_i", "_j"];

_unitToRemoveWhenDead = _this select 0;

_removeBodyAfterTime = _this select 1;

_i = 0;

while {(alive _unitToRemoveWhenDead) and (_i < 9999)} do

{

_j = 0;

while {(alive _unitToRemoveWhenDead) and (_j < 9999)} do

{

sleep 30;

_j = _j + 1;

};

_i = _i + 1;

};

sleep _removeBodyAfterTime;

hideBody _unitToRemoveWhenDead;

sleep 10;

deleteVehicle _unitToRemoveWhenDead;

// debugging

// give it a few seconds to be sure, then output the unit in string format.

// if it's a null value, then it's been deleted

sleep 10;

player sidechat format["%1", _unitToRemoveWhenDead];

Damn, I suppose I better check to be 100% certain then huh?

Share this post


Link to post
Share on other sites

Huh, that's interesting.

Believe it or not, my test results show that hideBody actually deletes them too. The deletebody is completely superfluous as far as infantry is concerned. It doesn't hurt anything by being there really, but it doesn't have to be there at all.

I wonder what the results are on empty vehicles? Regardless, It's late or early depending on how you care to look at it. And I don't care anymore for tonight.

Share this post


Link to post
Share on other sites
The reason I avoided event handlers is that calling this kind of script is a little easier for your average joe that doesn't understand them. That's the only reason I did that. The script could easilly be adapted to do it the other way, but I'm not really interested in that.

My goals in scripting for the community are to make modules that are highly accessible, that your average complete noob scripting wise can drop into a mission and make it work. If the script had been for me, I would have used eventhandlers. Since it's not, I didn't.

Using eventhandlers isnt more difficult than adding your commandline to the init e.g. this addeventhandler

["killed",{[_this select 0,_this select 1] exec "CSL_Utility\CSL_Bring_Out_Your_Dead.sqf"}]; this wouldnt cause that much performance.

Share this post


Link to post
Share on other sites

I suppose you're right at that. But truth be told, it's a refit of an old ofp script, and there where issues with eventhandlers in some situations. That may or may not be an issue in arma, but frankly it doesn't matter. What causes more lag? An event handler or checking his status manually every 30 seconds? 99% sure that it just flat doesn't make a difference.

Share this post


Link to post
Share on other sites

I have a CTF map and I am having an issue to where it only deletes the first player to die and none after that.

Share this post


Link to post
Share on other sites

It wasn't designed with multiplayer in mind, and I really can't do the port to multiplayer myself. If only I had a second computer that could run arma...

Feel free to take a crack at it though. There're several guides floating around for converting ofp scripts to mp floating around. Most of that info is probably still relevent.

Share this post


Link to post
Share on other sites

as far as i know, eventHandlers are passed on to the next player's unit after he dies (not in the case of group respawning). so if you use them instead, it should work well.

Share this post


Link to post
Share on other sites

put this in the unit's initialisation:

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

this addEventHandler ['killed', {(_this select 0) execVM 'removeBody.sqf'}];

and create a text file "removeBody.sqf" (in the mission's folder):

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

sleep 300;

deleteVehicle _this;

haven't tested, but i guess there isn't much i could've done wrong about this...

(you can also use "hideBody _this" instead of "deleteVehicle _this" or both with another delay in between - just not sure, if that works. of course, you can also use any other value (in seconds) for the delay after sleep)

Share this post


Link to post
Share on other sites
put this in the unit's initialisation:

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

this addEventHandler ['killed', {(_this select 0) execVM 'removeBody.sqf'}];

and create a text file "removeBody.sqf" (in the mission's folder):

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

sleep 300;

deleteVehicle _this;

haven't tested, but i guess there isn't much i could've done wrong about this...

(you can also use "hideBody _this" instead of "deleteVehicle _this" or both with another delay in between - just not sure, if that works. of course, you can also use any other value (in seconds) for the delay after sleep)

Yeah I think I used something similiar to this in OFP it was much easier than a big long script. I will try it. 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  

×