[AllLookAtThis] count the money of a team - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [AllLookAtThis] count the money of a team (
/showthread.php?tid=133234)
[AllLookAtThis] count the money of a team -
Fonsie - 11.03.2010
How do i count all the money of a team
Like: team_1 has $187349
team_2 has $38722
Re: count the money of a team -
Fonsie - 11.03.2010
anyone?
Re: count the money of a team -
armyoftwo - 11.03.2010
Quote:
|
Originally Posted by Fonsie
anyone?
|
Loop through the player team and count his money in a variable
Re: count the money of a team -
kLx - 11.03.2010
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.
Re: count the money of a team -
Fonsie - 11.03.2010
Thanks ALOT!
Ur a life saver
Re: count the money of a team -
Fonsie - 11.03.2010
Another question
How do i display the team with the most money?
Re: count the money of a team -
kLx - 11.03.2010
pawn Код:
if( team1cash > team2cash )
{
// display the team 1
}
if( team2cash > team1cash )
{
// display the team2
}
Re: count the money of a team -
Fonsie - 11.03.2010
And thanks again
Re: count the money of a team -
Fonsie - 11.03.2010
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?
Re: count the money of a team -
kLx - 11.03.2010
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.