OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: JasonO on 19 Sep 2007, 21:49:52
-
Hey there
I have a Team Deathmatch map and I want to have the game end when a Teams score (which is like the individual score from kills a player gets, but all added together for the whole team), however I don't know how to detect the score for the team. I know score _unit will do a seperate unit, but for the whole team I am baffled.
So lets say Loon1 has 4 points and Loon2 has 6 points - the param for the team score limit is 10 - how would I detect the total and trigger a Team Win (depending on team) outro from this?
Thanks for your help :)
-
Presuming groups grp1A and grp1B are one team and grp2A and grp2B are the other team:
scoreFlag = FALSE;
if isServer then {
while {not scoreFlag} do {
score1 = 0;
score2 = 0;
{score1 = score1 + score _x;} forEach (units grp1A + units grp1B);
{score2 = score2 + score _x;} forEach (units grp2A + units grp2B);
if (score1 > 20 or score2 > 20) then {
scoreFlag = TRUE;
{publicVariable _x;} forEach ["score1","score2","scoreFlag"];
};
sleep 1;
};
};
Use 3 end triggers with conditions:
scoreFlag and score1 > score2
scoreFlag and score2 > score1
scoreFlag and score1 == score2
to select the right ending.
edit : fixed error pointed out by spoon-boy
-
Small error in that code...
{score1 = score1 + score _x;} forEach (units grp1A + [units grp1B]);
should be:
{score1 = score1 + score _x;} forEach (units grp1A + units grp1B);
(otherwise you would be doing something like [fred, john] + [[terry, alan]] => [fred, john, [terry, alan]]).
-
Thanks guys. Been away from OFPEC for a bit, haven't had time to come and do things much here.
Much appreciated.