[AllLookAtThis] count the money of a team
#1

How do i count all the money of a team

Like: team_1 has $187349
team_2 has $38722
Reply
#2

anyone?
Reply
#3

Quote:
Originally Posted by Fonsie
anyone?
Loop through the player team and count his money in a variable
Reply
#4

Yeah sure.
Код:
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.
Reply
#5

Thanks ALOT!

Ur a life saver
Reply
#6

Another question

How do i display the team with the most money?
Reply
#7

pawn Код:
if( team1cash > team2cash )
{
// display the team 1
}
if( team2cash > team1cash )
{
// display the team2
}
Reply
#8

And thanks again
Reply
#9

Now i have the command:

pawn Код:
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;
}
But nothing happens it says unknown command did i do wrong?
Reply
#10

Make sure the score are not equal.
Money is an integer (%d), so use d letter instead of string (s) in format.
Also, return 1; in the end of command, this would'nt give u the Uknown Command text.
Remember, that GetPlayerColor works only, if it has been set with SetPlayerColor.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)