Jump to content
Sign in to follow this  
joduh

removing group with foreach problem

Recommended Posts

I'v read countless foreach problems and solutions, but cant seem to get them to work in my own example :mad:

{deletevehicle _x} foreach units group player; 

works great, but how to make it work on groups other then player :confused:

here are the lines in question

private ["_groupAlpha","_squad","_base","_caller","_id"];

_base = (_this select 0);
_caller = (_this select 1);
_id = (_this select 2);

if (_id == inf) then {
_groupAlpha = createGroup east;
_squad = [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10];
{_x = "TK_Soldier_AT_EP1" createUnit [getMarkerPos "spawn", _groupAlpha,"", 1, "corporal"]} foreach _squad ;

player hcsetgroup [_groupAlpha,""];
_base removeaction _id;
infR = _base addaction ["remove squad", "bitch.sqf"];
};

if (_id == infR) then {
{deletevehicle _x} foreach units group (leader _groupAlpha);
deletegroup _groupAlpha;
_base removeaction _id;
inf = _base addaction ["recruit squad", "bitch.sqf"] ;

};

got a base with init: inf = base addAction ["Recruit Squad", "bitch.sqf"];

highcommand module synced with player, hcsubordinate module synced with hcmodule.

the squad gets created and joins me, addaction @ base changes.

When i use remove squad addaction changes back again to recruit squad,

but nothing happens with the 1st squad

i'v try to get it to work with

{deletevehicle _x} foreach _squad;

and countless other variations :cry2:

any help will be greatly apreciated :worship:

Share this post


Link to post
Share on other sites

Would you not need to rename the group again once they have left the players group ? then use that name to

{deleteVehicle _x} forEach units GroupName;  
sleep 0.2;
deleteGroup GroupName; 

Or deletevehicle the units [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10];

Edited by Koni

Share this post


Link to post
Share on other sites

neither seems to work (groupname should be _groupAlpha in this case right?).

Whats even weirder, iv just try'd

deleteVehicle a1;

deleteVehicle a2;

deleteVehicle a3;

deleteVehicle a4;

etc

and not even that works...:confused:

Edit: iv placed

hint format ["team: %1,leader:%2", group _groupAlpha, leader _groupAlpha];

just before removing them and it returns team: 0x9aef4 leader: 0xc9ac6c

lol that doesent seem right...maybe iv messed up something else?

Edited by joduh

Share this post


Link to post
Share on other sites

Just looking at it I suspect the problem is _groupAlpha is local try using groupAlpha in the scripts

I don't think the units will be a1,a2 ect, but I'm not sure of the correct way. Maybe setvehiclevarname somehow.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

thnx for trying to help a noob like me, but i already gave up :P

completly rewrote it in a style befitting my skill....very primitive :D

private ["_groupAlpha","_squad","_base","_caller","_id"];

_base = (_this select 0);

_caller = (_this select 1);

_id = (_this select 2);

if (_id == a) then {

_group_a = createGroup east;

_a1 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_a,"a1 = this", 1, "PRIVATE"];

_a2 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_a,"a2 = this", 1, "PRIVATE"];

_a3 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_a,"a3 = this", 1, "PRIVATE"];

_a4 = "TK_Soldier_SniperH_EP1" createUnit [getMarkerPos "spawn", _group_a,"a4 = this", 1, "PRIVATE"];

_a5 = "TK_Soldier_SniperH_EP1" createUnit [getMarkerPos "spawn", _group_a,"a5 = this", 1, "PRIVATE"];

_a6 = "TK_Soldier_Medic_EP1" createUnit [getMarkerPos "spawn", _group_a,"a6 = this", 1, "PRIVATE"];

_a7 = "TK_Soldier_MG_EP1" createUnit [getMarkerPos "spawn", _group_a,"a7 = this", 1, "PRIVATE"];

_a8 = "TK_Soldier_MG_EP1" createUnit [getMarkerPos "spawn", _group_a,"a8 = this", 1, "PRIVATE"];

_a9 = "TK_Soldier_Engineer_EP1" createUnit [getMarkerPos "spawn", _group_a,"a9 = this", 1, "PRIVATE"];

a1 addweapon "NVgoggles";

a2 addweapon "NVgoggles";

a3 addweapon "NVgoggles";

a4 removeweapon "binocular";

a5 removeweapon "binocular";

a6 addweapon "NVgoggles";

a7 addweapon "NVgoggles";

a8 addweapon "NVgoggles";

a9 addweapon "NVgoggles";

player hcsetgroup [_group_a];

_base removeaction _id;

aR = _base addaction ["Disband Alpha", "bitch.sqf"];

};

if (_id == aR) then {

player hcRemoveGroup _group_a;

moveOut a1;

moveOut a2;

moveOut a3;

moveOut a4;

moveOut a5;

moveOut a6;

moveOut a7;

moveOut a8;

moveOut a9;

deleteVehicle a1;

deleteVehicle a2;

deleteVehicle a3;

deleteVehicle a4;

deleteVehicle a5;

deleteVehicle a6;

deleteVehicle a7;

deleteVehicle a8;

deleteVehicle a9;

deletegroup _group_a;

_base removeaction _id;

a = _base addaction ["Recruit Alpha", "bitch.sqf"] ;

};

if (_id == b) then {

_group_b = createGroup east;

_b1 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_b,"b1 = this", 1, "PRIVATE"];

_b2 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_b,"b2 = this", 1, "PRIVATE"];

_b3 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_b,"b3 = this", 1, "PRIVATE"];

_b4 = "TK_Soldier_SniperH_EP1" createUnit [getMarkerPos "spawn", _group_b,"b4 = this", 1, "PRIVATE"];

_b5 = "TK_Soldier_SniperH_EP1" createUnit [getMarkerPos "spawn", _group_b,"b5 = this", 1, "PRIVATE"];

_b6 = "TK_Soldier_Medic_EP1" createUnit [getMarkerPos "spawn", _group_b,"b6 = this", 1, "PRIVATE"];

_b7 = "TK_Soldier_MG_EP1" createUnit [getMarkerPos "spawn", _group_b,"b7 = this", 1, "PRIVATE"];

_b8 = "TK_Soldier_MG_EP1" createUnit [getMarkerPos "spawn", _group_b,"b8 = this", 1, "PRIVATE"];

_b9 = "TK_Soldier_Engineer_EP1" createUnit [getMarkerPos "spawn", _group_b,"b9 = this", 1, "PRIVATE"];

b1 addweapon "NVgoggles";

b2 addweapon "NVgoggles";

b3 addweapon "NVgoggles";

b4 removeweapon "binocular";

b5 removeweapon "binocular";

b6 addweapon "NVgoggles";

b7 addweapon "NVgoggles";

b8 addweapon "NVgoggles";

b9 addweapon "NVgoggles";

player hcsetgroup [_group_b];

_base removeaction _id;

bR = _base addaction ["Disband Bravo", "bitch.sqf"];

};

if (_id == bR) then {

player hcRemoveGroup _group_b;

moveOut b1;

moveOut b2;

moveOut b3;

moveOut b4;

moveOut b5;

moveOut b6;

moveOut b7;

moveOut b8;

moveOut b9;

deleteVehicle b1;

deleteVehicle b2;

deleteVehicle b3;

deleteVehicle b4;

deleteVehicle b5;

deleteVehicle b6;

deleteVehicle b7;

deleteVehicle b8;

deleteVehicle b9;

deletegroup _group_b;

_base removeaction _id;

b = _base addaction ["Recruit Bravo", "bitch.sqf"] ;

};

if (_id == c) then {

_group_c = createGroup east;

_c1 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_c,"c1 = this", 1, "PRIVATE"];

_c2 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_c,"c2 = this", 1, "PRIVATE"];

_c3 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_c,"c3 = this", 1, "PRIVATE"];

_c4 = "TK_Soldier_SniperH_EP1" createUnit [getMarkerPos "spawn", _group_c,"c4 = this", 1, "PRIVATE"];

_c5 = "TK_Soldier_SniperH_EP1" createUnit [getMarkerPos "spawn", _group_c,"c5 = this", 1, "PRIVATE"];

_c6 = "TK_Soldier_Medic_EP1" createUnit [getMarkerPos "spawn", _group_c,"c6 = this", 1, "PRIVATE"];

_c7 = "TK_Soldier_MG_EP1" createUnit [getMarkerPos "spawn", _group_c,"c7 = this", 1, "PRIVATE"];

_c8 = "TK_Soldier_MG_EP1" createUnit [getMarkerPos "spawn", _group_c,"c8 = this", 1, "PRIVATE"];

_c9 = "TK_Soldier_Engineer_EP1" createUnit [getMarkerPos "spawn", _group_c,"c9 = this", 1, "PRIVATE"];

c1 addweapon "NVgoggles";

c2 addweapon "NVgoggles";

c3 addweapon "NVgoggles";

c4 removeweapon "binocular";

c5 removeweapon "binocular";

c6 addweapon "NVgoggles";

c7 addweapon "NVgoggles";

c8 addweapon "NVgoggles";

c9 addweapon "NVgoggles";

player hcsetgroup [_group_c];

_base removeaction _id;

cR = _base addaction ["Disband Charlie", "bitch.sqf"];

};

if (_id == cR) then {

player hcRemoveGroup _group_c;

moveOut c1;

moveOut c2;

moveOut c3;

moveOut c4;

moveOut c5;

moveOut c6;

moveOut c7;

moveOut c8;

moveOut c9;

deleteVehicle c1;

deleteVehicle c2;

deleteVehicle c3;

deleteVehicle c4;

deleteVehicle c5;

deleteVehicle c6;

deleteVehicle c7;

deleteVehicle c8;

deleteVehicle c9;

deletegroup _group_c;

_base removeaction _id;

c = _base addaction ["Recruit Charlie", "bitch.sqf"] ;

};

if (_id == d) then {

_group_d = createGroup east;

_d1 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_d,"d1 = this", 1, "PRIVATE"];

_d2 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_d,"d2 = this", 1, "PRIVATE"];

_d3 = "TK_Soldier_HAT_EP1" createUnit [getMarkerPos "spawn", _group_d,"d3 = this", 1, "PRIVATE"];

_d4 = "TK_Soldier_SniperH_EP1" createUnit [getMarkerPos "spawn", _group_d,"d4 = this", 1, "PRIVATE"];

_d5 = "TK_Soldier_SniperH_EP1" createUnit [getMarkerPos "spawn", _group_d,"d5 = this", 1, "PRIVATE"];

_d6 = "TK_Soldier_Medic_EP1" createUnit [getMarkerPos "spawn", _group_d,"d6 = this", 1, "PRIVATE"];

_d7 = "TK_Soldier_MG_EP1" createUnit [getMarkerPos "spawn", _group_d,"d7 = this", 1, "PRIVATE"];

_d8 = "TK_Soldier_MG_EP1" createUnit [getMarkerPos "spawn", _group_d,"d8 = this", 1, "PRIVATE"];

_d9 = "TK_Soldier_Engineer_EP1" createUnit [getMarkerPos "spawn", _group_d,"d9 = this", 1, "PRIVATE"];

d1 addweapon "NVgoggles";

d2 addweapon "NVgoggles";

d3 addweapon "NVgoggles";

d4 removeweapon "binocular";

d5 removeweapon "binocular";

d6 addweapon "NVgoggles";

d7 addweapon "NVgoggles";

d8 addweapon "NVgoggles";

d9 addweapon "NVgoggles";

player hcsetgroup [_group_d];

_base removeaction _id;

dR = _base addaction ["Disband Delta", "bitch.sqf"];

};

if (_id == dR) then {

player hcRemoveGroup _group_d;

moveOut d1;

moveOut d2;

moveOut d3;

moveOut d4;

moveOut d5;

moveOut d6;

moveOut d7;

moveOut d8;

moveOut d9;

deleteVehicle d1;

deleteVehicle d2;

deleteVehicle d3;

deleteVehicle d4;

deleteVehicle d5;

deleteVehicle d6;

deleteVehicle d7;

deleteVehicle d8;

deleteVehicle d9;

deletegroup _group_d;

_base removeaction _id;

d = _base addaction ["Recruit Delta", "bitch.sqf"] ;

};

awell atleast it works :icon_lol:

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  

×