PDA

View Full Version : Define team and show for team.



Loveboy
12th July 2013, 09:51
Hi Guys, i want to make a special end map, before all will be ended then will come something with string with "Lose" or "Win" (for the team who win/lose) and "Draw".

Here is my tried script:



endMap()
{
game["state"] = "intermission";
level notify("intermission");

alliedscore = getTeamScore("allies");
axisscore = getTeamScore("axis");

self freezeControls(true);
self playsound("end");

if(alliedscore == axisscore) // DRAW
{
script.........
}
else if(alliedscore > axisscore)
{
if(self.pers["team"] == "allies") // Allies WIN!
{
script...........
}
else if(self.pers["team"] == "axis") // Axis LOSE!
{
script.............
}
}
wait(13);

/////////// NOW ALL WILL BE ENDED HOW LIKE DEFAULT
if(alliedscore == axisscore)
{
winningteam = "tie";
losingteam = "tie";
text = "MP_THE_GAME_IS_A_TIE";
}
else if(alliedscore > axisscore)
{
winningteam = "allies";
losingteam = "axis";
text = &"MP_ALLIES_WIN";
}
else
{
.................................................. ....


So what now happens:
If map ends, then i will be not freeze (should be all) and there will not come WIN or Lose or Draw for teams.
Why and how i can fix it that it comes to teams the win or lose for players?

But after 13 secounds works that it ends.

Loveboy
12th July 2013, 13:39
EDIT: Fixed by RobsoN per TV!

Ni3ls
12th July 2013, 15:18
Can you show the working script then, please?

Loveboy
12th July 2013, 15:24
Made by RobsoN:



endMap()
{
game["state"] = "intermission";
level notify("intermission");

alliedscore = getTeamScore("allies");
axisscore = getTeamScore("axis");

if(alliedscore == axisscore)
{
winningteam = "tie";
losingteam = "tie";
text = "MP_THE_GAME_IS_A_TIE";
}
else if(alliedscore > axisscore)
{
winningteam = "allies";
losingteam = "axis";
text = &"MP_ALLIES_WIN";
}
else
{
winningteam = "axis";
losingteam = "allies";
text = &"MP_AXIS_WIN";
}

players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
{
if(winningteam == "tie")
{
players[i] iprintlnbold("Game is a tie");
}
else if(winningteam == "axis") //axis won
{
if(players[i].pers["team"] == "axis")
{
players[i] iprintlnbold("Congratulations, your team has won the match.");
}
else if(players[i].pers["team"] == "allies")
{
players[i] iprintlnbold("Your team has lost the match.");
}
else //spectator
{
players[i] iprintlnbold("Axis won.");
}
}
else if(winningteam == "allies") //allies won
{
if(players[i].pers["team"] == "axis")
{
players[i] iprintlnbold("Your team has lost the match.");
}
else if(players[i].pers["team"] == "allies")
{
players[i] iprintlnbold("Congratulations, your team has won the match.");
}
else //spectator
{
players[i] iprintlnbold("Allies won.");
}
}
}

wait 13;

winners = "";
losers = "";

if(winningteam == "allies")
level thread playSoundOnPlayers("MP_announcer_allies_win");
else if(winningteam == "axis")
level thread playSoundOnPlayers("MP_announcer_axis_win");
else
level thread playSoundOnPlayers("MP_announcer_round_draw");

players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
{
player = players[i];
if((winningteam == "allies") || (winningteam == "axis"))
{
lpGuid = player getGuid();
if((isDefined(player.pers["team"])) && (player.pers["team"] == winningteam))
winners = (winners + ";" + lpGuid + ";" + player.name);
else if((isDefined(player.pers["team"])) && (player.pers["team"] == losingteam))
losers = (losers + ";" + lpGuid + ";" + player.name);
}

player closeMenu();
player closeInGameMenu();
player setClientCvar("cg_objectiveText", text);

player spawnIntermission();
}

if((winningteam == "allies") || (winningteam == "axis"))
{
logPrint("W;" + winningteam + winners + "\n");
logPrint("L;" + losingteam + losers + "\n");
}

// set everyone's rank on xenon
if(level.xenon)
{
players = getentarray("player", "classname");
highscore = undefined;

for(i = 0; i < players.size; i++)
{
player = players[i];

if(!isdefined(player.score))
continue;

if(!isdefined(highscore) || player.score > highscore)
highscore = player.score;
}

for(i = 0; i < players.size; i++)
{
player = players[i];

if(!isdefined(player.score))
continue;

if(highscore <= 0)
rank = 0;
else
{
rank = int(player.score * 10 / highscore);
if(rank < 0)
rank = 0;
}

if(player.pers["team"] == "allies")
setplayerteamrank(player, 0, rank);
else if(player.pers["team"] == "axis")
setplayerteamrank(player, 1, rank);
else if(player.pers["team"] == "spectator")
setplayerteamrank(player, 2, rank);
}
sendranks();
}

wait 10;
exitLevel(false);
}