Home   Help Search Login Register  

Author Topic: Team Score to end game  (Read 1950 times)

0 Members and 1 Guest are viewing this topic.

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Team Score to end game
« 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  :)

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Team Score to end game
« Reply #1 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
« Last Edit: 23 Sep 2007, 23:44:47 by Mr.Peanut »
urp!

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Team Score to end game
« Reply #2 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]]).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Team Score to end game
« Reply #3 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.