Jump to content
Sign in to follow this  
Balschoiw

Deleting units and vehicles

Recommended Posts

Having an odd problem right now.

I have several convois going to a harbour for evacuation.

There is a trigger with a radius of 25 at the end of the route, activated by OPFOR, set to repeatedly that calls a script to remove the units within a radius from the map.

The script is:

_clear1 = _this select 0;

_remove = nearestObjects [_clear1, [], 25];

{deletevehicle _x} foreach _remove;

exit

My first problem is that only the vehicles get removed, the crew

kisses the tarmack and dies.

How can I delete their bodies aswell ?

Second problem, the trigger is set to repeatedly, but when the second convoi arrives it doesn´t fire anymore and vehicles do not get removed. Can it be that the trigger itself also gets removed ?

How can I solve that ?

I also tried to setpos the units out on the sea with a variation from the script above but the trigger also only fires once and not more than that.

Weird issue.

Share this post


Link to post
Share on other sites

Try this:  wink_o.gif

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

private ["_clear1","_i","_remove"];

while {true} do

{

_remove = nearestObjects [_clear1, ["landvehicle"], 25];

for [{_i = 0},{_i < (count _remove)},{_i = _i + 1}] do

{

{deletevehicle _x} foreach crew (_remove select _i);

deletevehicle (_remove select _i);

};

sleep 0.1;

};

Share this post


Link to post
Share on other sites

The problem with that is that. you will delete all vehicles and crew. no matter what side they are on..

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

_clear1 = _this select 0;

private ["_clear1","_i","_remove"];

while {true} do

{

_remove = nearestObjects [_clear1, ["landvehicle"], 25];

for [{_i = 0},{_i < (count _remove)},{_i = _i + 1}] do

{

_side = side (_remove select _i);

if (_side != side player) then

{

{deletevehicle _x} foreach crew (_remove select _i);

deletevehicle (_remove select _i);

};

};

sleep 0.1;

};

Share this post


Link to post
Share on other sites

That´s no problem nuxil as there are only units of one side coming to the point.

I will try that script.

Thank you thumbs-up.gif

Update:

Tried both of the scripts and I always get

´|#|sleep 0.1;´

Error Generic error in expression

I´ve saved the script as .sqf

and it get´s called with

[clear] exec "clearzone.sqf";

Share this post


Link to post
Share on other sites

with sqf scripts you need execvm no exec

exec is for sqs

Share this post


Link to post
Share on other sites

Ah, I see. I have no real knowledge on scripting with sqf´s.

I tried to call the script now with

_clear2 = clear execVM "clearzone.sqf";

but it keeps nagging me with

error

type object expected array and a mileslong error message.

Sorry to be nagging you, but I don´t have knowledge with sqf´s yet.

My trigger is named clear now and I use this script:

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

private ["_clear1","_i","_remove"];

while {true} do

{

_remove = nearestObjects [_clear1, ["landvehicle"], 25];

for [{_i = 0},{_i < (count _remove)},{_i = _i + 1}] do

{

_side = side (_remove select _i);

if (_side != side player) then

{

{deletevehicle _x} foreach crew (_remove select _i);

deletevehicle (_remove select _i);

};

};

sleep 0.1;

};

How can I call the script properly ?

Share this post


Link to post
Share on other sites

strange.. i dont know if a trigger is seen as a object.

try a postition instead.

nil = [pos-of-trigger] execVM "clearzone.sqf";

or you can test by adding a invisible helipad ontop of the trigger.

then on trigger put.

nil = [helipad] execVM "clearzone.sqf";

or

nil = [(getpos helipad)] execVM "clearzone.sqf";

Share this post


Link to post
Share on other sites

Tried all 3 combinations and none brings up an error, but nothing gets removed aswell. I combined the trigger with a hint to see if it´s firing and it does but the script does not have any effect.

My trigger setup:

radius 30

Activated by OPFOR

Repeatedly

condition : this

Triggername: clear

OnActivation: nil = [(getpos clear)] execVM "clearzone.sqf"; hint "fired"

script:

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

private ["_clear1","_i","_remove"];

while {true} do

{

_remove = nearestObjects [_clear1, ["LandVehicle"], 25];

for [{_i = 0},{_i < (count _remove)},{_i = _i + 1}] do

{

_side = side (_remove select _i);

if (_side != side player) then

{

{deletevehicle _x} foreach crew (_remove select _i);

deletevehicle (_remove select _i);

};

};

sleep 0.1;

};

If it helps I can upload the scenario.

Edit

Isolated the scenario and packed it into a missionfile:

Scenario file

Share this post


Link to post
Share on other sites

Well, that won't work.

In your example the player is on the OPFOR side and the units you want to delete too.

In your script there is the following if construct:

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

if (_side != side player) then

This will allways return false and that means, it will never start to delete anything.

Change the line above to:

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

if (_side == side player && !isPlayer (_remove select _i)) then

and it'll work.

You can also use thislist or list of the "clear" trigger to iterate through the list items.

Xeno

Share this post


Link to post
Share on other sites

You can officially call me the "!"-man now icon_rolleyes.gif

Thx for input ! Will check it out later, but it´s pretty obious now where my supadupa error was banghead.gif

Share this post


Link to post
Share on other sites

_Xeno_ yea i just tested that,, and it wount work with "!="

The simplest way, might just be to.

put a trigger on map.. then on act put:

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

{_units = crew _x; {deletevehicle _x} foreach _units; deleteVehicle _x } foreach thislist

Share this post


Link to post
Share on other sites

@Balschoiw

You must call the function this way:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[name_trigger] execVM "Clear.sqf"

I have tested the function and works properly

Share this post


Link to post
Share on other sites

All nice and dandy now.

I´m using the scripted version though as I guess it will cause less load. In my experience trigger actions are more load for CPU than script actions.

Anyway, a big thank you to all of you who were involved in solving this puzzle for me.

thumbs-up.gif

Share this post


Link to post
Share on other sites

No. actualy my last way is the way that puts less stress on the cpu. but. the foreach command can put alot of stress on cpus if there is alot og units there.. this goes for both examples..

but anyway. since you are uning the script. remember to only activate the script once in the trigger options..

otherwize you will start up a new script each time a unit comes inside the trigger zone. this is because the script is a loop with no exit.

Share this post


Link to post
Share on other sites

Could someone clearly explain to me how this script does remove the dead units only, like it was asked in the first post ?

I don't get it.

Otherwise, could someone explain to me how to selectively remove the dead bodies of dead units of a defined team ?

Thanks a lot.

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  

×