Jump to content
Sign in to follow this  
SilentSpike

Hide body 'x' time after unit is killed

Recommended Posts

Here's what I have:

_unit addMPEventHandler ["MPKilled", {
   _unit = (_this select 0);
   sleep 120;
   hideBody _unit;
   sleep 5;
   deleteVehicle _unit;
   _unit removeMPEventHandler ["MPKilled", 0];
}];

It's intended to wait 2 minutes after a unit is killed and then hide the body before deleting it. Oh and I should note that _unit is declared before the event handler.

Unfortunately this is giving me an error and I have a suspicion that it's because the killed unit argument is not actually the same unit as the dead body.

This is the error I'm getting: "Error generic error in expression". It's marking it right before the 5th line (sleep 5).

Here's the Biki entry on the event handler, any ideas on how to achieve what I'm looking for?

---------- Post added at 20:46 ---------- Previous post was at 20:42 ----------

Sure enough I find a solution I hadn't thought of right after posting this. I believe if I simply set corpseRemovalMaxTime to 2 minutes then it should give me what I'm looking for. Doh. :p

Share this post


Link to post
Share on other sites

You can't make eventhandlers sleep or wait. You have to spawn your code:

_unit addMPEventHandler ["MPKilled", { 
   _unit = (_this select 0); 
[_unit] spawn {
_unit = _this select 0;
   sleep 120; 
   hideBody _unit; 
   sleep 5; 
   deleteVehicle _unit; 
   _unit removeMPEventHandler ["MPKilled", 0]; 
};
}]; 

---------- Post added at 20:55 ---------- Previous post was at 20:51 ----------

More info here:

http://killzonekid.com/arma-scripting-tutorials-code-performance/

Share this post


Link to post
Share on other sites

Or calling an external script with the EH params, with sleeps, deletevehicle and all the stuff...

Share this post


Link to post
Share on other sites

You can add this in the description.ext

//Corpse limit before which ( <= ) corpseRemovalMaxTime applies and after which ( > ) corpseRemovalMinTime applies (see below).
corpseLimit = 1;
//Default value: 15

//Maximum time a corpse can remain on the ground if total number of corpses is equal or under corpseLimit.
corpseRemovalMaxTime = 1200; //seconds
//Default value: 3600

//Remove all bodies that have been dead longer than corpseRemovalMinTime when corpseLimit is breached.
corpseRemovalMinTime = 60; //seconds
//Default value: 10

---------- Post added at 10:54 AM ---------- Previous post was at 10:53 AM ----------

Oh you want it to hide. Don't know if that happens when using the above.

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  

×