Jump to content
Sign in to follow this  
DChristy87

deleteGroup isn't deleting the group?!

Recommended Posts

Okay, so I have a script run from a player. It creates an enemy patrol at a randomly selected game logic and puts a marker on the players map. For some reason, deleteGroup isn't working for me now. Here's my script:

_unit = _this;
sleep 20;
_apos = [posA,posB] call BIS_fnc_selectRandom;
_rSound = ["RadioAmbient8","RadioAmbient6","RadioAmbient2"] call BIS_fnc_selectRandom;
_eArray1 = ["O_Soldier_SL_F","O_Soldier_GL_F","o_soldier_f","o_soldier_f","O_Soldier_AR_F"];
_eArray2 = ["O_Soldier_SL_F","O_Soldier_SL_F","O_Soldier_SL_F","o_soldier_f","o_soldier_f","o_soldier_f","o_soldier_f"];
_eArray3 = ["O_Soldier_SL_F","o_soldier_f","o_soldier_f"];
_eArray = [_eArray1,_eArray2,_eArray3] call BIS_fnc_selectRandom;
_pos = getPos _apos;
_side = createCenter East;
_grp = creategroup East;
_grp = [_pos, EAST, _eArray] call BIS_fnc_spawnGroup;
[_grp, _pos, 45] call bis_fnc_taskPatrol;
hint format["Enemies have been spotted! \nCheck your map for their location.",_unit];

_marker1 = createMarkerLocal ["Marker1", getPos _apos];
_marker1 setMarkerTypeLocal "o_unknown";
_marker1 setMarkerColorLocal "ColorOPFOR";
_marker1 setMarkerTextLocal "Enemy patrol!";
_marker1 setMarkerSizeLocal [1, 1];
playSound _rSound;

sleep 20;

deleteGroup _grp;
deleteMarkerLocal _marker1;
_unit execVM "sideMissions.sqf";

As you can see I have short sleep times just for testing. The script creates a group, makes them patrol, waits 20 seconds and then is supposed to delete the group and start over again. The marker is deleting, but not the group. Any ideas why it's not working?

NOTE: the deleteGroup WAS working before I added the _eArrays to randomize the group that spawns. But that shouldn't effect the group being recognized as "_grp" and preventing the deletGroup from working.

Share this post


Link to post
Share on other sites

Don't need the _grp = createGroup thing there, spawnGroup does that itself. Probably don't need _side = either.

Why are you trying to delete the group 20 seconds after you create it? Surely the player hasn't killed them that quickly?

The deleteGroup command won't remove the group members, just the group data type. If there are living units in the group the command does nothing. It doesn't kill anyone, just frees up one of the 144 group objects available per side to the engine.

If you wanted to kill everyone then free up the group you'd do:

{deleteVehicle _x;} forEach units _grp;
deleteGroup _grp;

Share this post


Link to post
Share on other sites

That did it! Thanks kylania! (deleting the group only 20 seconds after it was created was for testing purposes) I plan to have it sleep 500 + random 400; or something but I can't wait that long just for testing it :)

Share this post


Link to post
Share on other sites

Also, if you are trying to delete a non-local group, it seems to not really work, even though most deleting scripting commands can be executed anywhere and work just fine. So you may just want to make things easy on you and only run spawning/deleting scripts on the server if it's AI you are dealing with.

Share this post


Link to post
Share on other sites

Hmm, I appreciate the tip. I'll have to look into finding out how to run scripts on the server vs otherwise. I'm still a noob and trying to to figure all that out.

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  

×