Jump to content
Sign in to follow this  
legion7698

Deleting multiple units?

Recommended Posts

Hey all,

I'm trying to create a zombie mission over most of a rather large map. I've set up areas that when entered, spawn the zombies but my problem is when I leave I want them to be deleted.

i know how to delete units via naming them all, but this is not an option that is really viable due to I then find that they cannot be spawned again when re-entering the area. The other way I've found of doing it only deletes one of them.

So my question is, what would I need to do to create a script that would delet all units within a set area upon leaving without having to name them all first.

Thank you for any help in advance.

Regards,

Dave.

Edited by Rellikki
Moved

Share this post


Link to post
Share on other sites

I think this should work:

Create a trigger, activated by Anybody, Repeadetly. On the condition field type:

!(player in thisList) && alive player

On the activation field type:

{deleteVehicle _x} forEach thisList

This will delete everything from the trigger area once the player has left it. One bad side of it is that this will delete everything - Units from all sides, empty vehicles,... But static objects won't be deleted - Ammo crates, fences,... I hope that doesn't bring any problems. This is the simplest way to do what you described.

Edited by Rellikki

Share this post


Link to post
Share on other sites

Hey Rellikki,

Thank you for the response. This would appear to give what I need with the exeption of its needed for multiplayer with a player force of currently around 9. So I assume instead of having the line of

!(player in thisList) && alive player

I could have something like

!(a1, a2 in thisList) && alive a1, a2

Or something like that?

Regards,

LEGION7698.

Share this post


Link to post
Share on other sites

I think the commands I provided should work, because all the players are considered "player", so the trigger shouldn't activate until all of them have left the trigger area, so naming them seperately in the command like you showed won't be necessary. Haven't tested though, so don't take my word for it.

Share this post


Link to post
Share on other sites

That's not true as the other clients will remove your unit then.

Try this as condition:

{isPlayer _x} count thisList == 0

Share this post


Link to post
Share on other sites

Thank you both for the help.

However this bit

{isPlayer _x} count thisList == 0

appears to not be working, producing and error (think its the _x bit its having a fit over) and is now not deleting anything.

Thank you and regards,

LEGION7698.

Share this post


Link to post
Share on other sites

isPlayer is an ArmA command. ;) This should do the trick:

{_x == player} count thisList == 0

Share this post


Link to post
Share on other sites

D'oh, sorry, I didn't see we're in the OFP section. Huh.

Rellikki, this will again not work ;) As "player" is different on every client.

For OFP, you have to do it this way:

Give every player a name (name1, name2, ...) Put this in a player's init line:

myPlayerArray = []; {if (format ["%1", _x] != "scalar bool array string 0xfcffffef") then {myPlayerArray set [count myPlayerArray, _x]}} forEach [name1, name2, ...]

And this is your trigger's condition:

{alive _x && _x in myPlayerArray} count thisList == 0

If there are empty slots and you have it filled with AI, the AI will be handled as player, so you have to make sure they're leaving the trigger as well.

(Sorry, it's years ago that I coded the last time for OFP, so this doesn't work maybe ...)

Share this post


Link to post
Share on other sites

Hey all,

Cheers for the help guys, got it working like a treat now, it deletes all the zombies in the area. One thing I did note while testing in MP quickly is that if I've set it up to say spawn 4 zombies when I enter an area, it will multiply it by each amount of human players present. So in the quick MP test with two players, instead of spawning 4 it spawned 8. Could this be becouse of the way Ive writen the spawn script.

This is the line I use to spawn them with (one for each I want spawned of course.

"pep_Zslow_soldierw" createUnit [position z2,dead1, "",0.4,"Corporal"]

So after helping me fix my other problem, could you please help me with this.

Thank you and regards,

LEGION7698.

Share this post


Link to post
Share on other sites

You probably have a trigger with something like

player in thisList

... to create the zombies, right? Every player then executes this trigger. You have to add a additional variable for example (there are probably various other ways ...).

Put this in a player's init:

spawnedZombies1 = false

Add this to the trigger's current condition:

... && !(spawnedZombies1)

And add this to the trigger's onActivation line:

spawnedZombies1 = true; publicVariable "spawnedZombies1"

Share this post


Link to post
Share on other sites

Hey,

Thats done the trick, now the whole thing is working perfectly, thank you.

Regards,

LEGION7698.

Share this post


Link to post
Share on other sites

hey all,

I have found anouther problem :). The scripts will not acivate whilst inside a vehicle, so the spawn will only work if I get out and if I try to get back in again it registers me as not there anymore so does the delete thing, including the vehicle, which I am aware that the delete part will do this, but I was hoping to take it with me as this is for use on the whole island and it would take a long time to walk everywhere.

So any help with this would be brilliant.

regards,

LEGION7698.

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  

×