OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: JasonO on 19 Sep 2007, 21:49:52

Title: Team Score to end game
Post 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  :)
Title: Re: Team Score to end game
Post by: Mr.Peanut on 22 Sep 2007, 22:11:31
Presuming groups grp1A and grp1B are one team and grp2A and grp2B are the other team:
Code: [Select]
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:
Code: [Select]
scoreFlag and score1 > score2
Code: [Select]
scoreFlag and score2 > score1
Code: [Select]
scoreFlag and score1 == score2
to select the right ending.

edit : fixed error pointed out by spoon-boy
Title: Re: Team Score to end game
Post by: Spooner on 23 Sep 2007, 11:55:54
Small error in that code...
Code: [Select]
{score1 = score1 + score _x;} forEach (units grp1A + [units grp1B]);
should be:
Code: [Select]
{score1 = score1 + score _x;} forEach (units grp1A + units grp1B);
(otherwise you would be doing something like [fred, john] + [[terry, alan]] => [fred, john, [terry, alan]]).
Title: Re: Team Score to end game
Post by: JasonO on 29 Sep 2007, 12:19:16
Thanks guys. Been away from OFPEC for a bit, haven't had time to come and do things much here.

Much appreciated.