11.03.2010, 16:24
How do i count all the money of a team
Like: team_1 has $187349
team_2 has $38722
Like: team_1 has $187349
team_2 has $38722
|
Originally Posted by Fonsie
anyone?
|
new team1cash;
new team2cash;
for(new i = 1; i < MAX_PLAYERS; i++)
{
if( GetPlayerTeam( i ) == 1 ) // or other team checking
{
team1cash = team1cash+GetPlayerMoney(i);
}
if( GetPlayerTeam( i ) == 2 ) // or other team checking
{
team2cash = team2cash+GetPlayerMoney(i);
}
}
Sorry for no indention, wrote it right here in the forum.

if( team1cash > team2cash )
{
// display the team 1
}
if( team2cash > team1cash )
{
// display the team2
}
public OnPlayerCommandText(playerid, cmdtext[])
{
//LEADING TEAM COMMAND//////////////
if (strcmp("/lolled", cmdtext, true, 10) == 0)
{
new team1cash;
new team2cash;
for(new i = 1; i < MAX_PLAYERS; i++)
{
if( GetPlayerTeam( i ) == 1 ) // or other team checking
{
team1cash = team1cash+GetPlayerMoney(i);
}
if( GetPlayerTeam( i ) == 2 ) // or other team checking
{
team2cash = team2cash+GetPlayerMoney(i);
}
}
if( team1cash > team2cash )
{
new string[128];
format(string,sizeof(string),"The Grove team is leading with %s Money",team1cash);
SendClientMessageToAll(GetPlayerColor(playerid),string);
}
if( team2cash > team1cash )
{
new string[128];
format(string,sizeof(string),"The Balla team is leading with %s Money",team2cash);
SendClientMessageToAll(GetPlayerColor(playerid),string);
}
}
return 0;
}