Jump to content
Sign in to follow this  
Junker

Delete dead without names

Recommended Posts

i have made a Defend mission where all the enemy is spawned, trouble is i have 30 squads and that means towards the end it will start LAGGING the mission, So i need away to delete the dead after so many have died, Ive tried a few scripts some dont work and some just keep throwing errors up.

can anyone help plz wink.gif

Share this post


Link to post
Share on other sites

This is going to sound like a lot of work (cos you'll need to have it in the init-line, or as part of the spawn script for every unit ), but you'll probably have to add an event handler to every unit you want to delete. Straight from the comref:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE"> object addEventHandler handler

Operand types:

object: Object

handler: Array

Compatibility:

Version 1.85 required.

Type of returned value:

Number

Description:

Format of handler is [type,command]. Check scripting topic Event handlers for more information. Index of currently added handler is returned.

Example:

player addEventHandler ["killed",{_this exec "playerKilled.sqs"}] <span id='postcolor'>

Play around with that a bit and it should help.

Share this post


Link to post
Share on other sites

add a call to a script for each of your units you place.

[this] exec "cleanup.sqs"

where this is your unit you want to track.

then in cleanup.sqs watch if your unit has died, wait some delay, then deletevehicle that unit. You will have a copy of this script running for each unit but there's no looping looking what what is dead or alive this way.

Share this post


Link to post
Share on other sites

The best way of doing this would be to use an eventhandler like MintyBoy suggested.

Add this eventhandler to the leader of each group:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> "_xaddEventHandler [""killed"",{_this exec "delete.sqs"}]" foreach units group this

Make a script file called delete.sqs:

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

_unit = _this select 0

~10

deleteVehicle _unit

exit

RED

Share this post


Link to post
Share on other sites
Quote[/b] ]RED

------------------

The best way of doing this would be to use an eventhandler like MintyBoy suggested.

Add this eventhandler to the leader of each group:

Code Sample

"_xaddEventHandler [""killed"",{_this exec "delete.sqs"}]" foreach units group this

Make a script file called delete.sqs:

Code Sample

_unit = _this select 0

~10

deleteVehicle _unit

exit

RED

Excuse my ignorance Red but l get a error when putting this in group leader's init. Where would l put the group leader's name ? Thank you smile_o.gif

Share this post


Link to post
Share on other sites

The problem was with the quote marks within the eventhandler, it should have looked like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x addEventHandler [""killed"",{_this exec {delete.sqs}}]" foreach units group this

A working example of this can be found at:

http://www.red-dev.net/missions/Test_delete.zip

RED

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  

×