[plaese Help me]How to check the most of a variable? -
Tigerbeast11 - 14.12.2009
I have a player kills variable which gets updated when the players dies like this:
pawn Код:
public OnPlayerDeath(killerid,playerid,reason)
{
PlayerKills[playerid]--;
PlayerKills[killerid]++;
}
But how can i check which player has the most kills?
Alos, how to check if the match is drawn?
Re: How to check the most? -
Jakku - 14.12.2009
Try this, not tested
pawn Код:
if(!strcmp(cmdtext, "/kills", true, 5))
{
if(!strlen(cmdtext[6]))
{
SendClientMessage(playerid, COLOR_ORED, "Usage: /kills [playerid]");
return 1;
}
new ID = strval(cmdtext[6]);
new strv[180];
if(IsPlayerConnected(ID))
{
format(strv, 180, "ID %d has %d kills",ID, PlayerKills[ID]);
SendClientMessage(playerid,COLOR_YOURCOLOR, strv);
}
return 1;
}
Re: How to check the most? -
Tigerbeast11 - 14.12.2009
thnx, but i mean something like this.
pawn Код:
forward gmend(playerid);
public gmend(playerid)
{
new pname[MAX_PLAYER_NAME];
new string[128];
GetPlayerName(playerid,pname,sizeof(pname);
format(string,sizeof(string),"%s wins with %d points!",pname,score);
SendClientMessageToAll(COLOR_ORANGE,string);
}
Also, how to check if players draw and it can say the match has drawn.
}[/pawn]
so it can be called at the end of gm.
Re: [plaese Help me]How to check the most of a variable? -
Tigerbeast11 - 14.12.2009
BTW, is this even possible?
Re: [plaese Help me]How to check the most of a variable? -
LarzI - 14.12.2009
Check if the variable is close to eg 99999 then return the var value which is closest to 99999.
Idk exactly how to make this, but you have to use a for loop AFAIK.
Sorry that I'm not much help..
EDIT:
Try this:
pawn Код:
//global
new
KillWinner,
MostKills;
pawn Код:
//onplayerdeath
if(PlayerKills[ killerid ] > MostKills)
{
KillWinner = killerid;
MostKills = PlayerKills[ killerid ];
}
I think it would work.
Re: [plaese Help me]How to check the most of a variable? -
Tigerbeast11 - 14.12.2009
is it possible to say "%s won the match with 12 kills" or something?
Or when it it a draw, "The match has been drawn"?
Re: [plaese Help me]How to check the most of a variable? -
Tigerbeast11 - 15.12.2009
up u go...
Re: [plaese Help me]How to check the most of a variable? -
Zamaroht - 15.12.2009
pawn Код:
new BestKiller;
for(new i; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i) && PlayerKills[i] > BestKiller) BestKiller = i;
}
Right there you will have in the "BestKiller" variable the id of the player with the most kills.
Re: [plaese Help me]How to check the most of a variable? -
LarzI - 15.12.2009
If, let's say, ID 57 is BestKiller.
Then next time it would be checked, it will check if the players kills (which is 56 in my example) is more than the BestKiller's ID, not the BestKillers kills.
Re: [plaese Help me]How to check the most of a variable? -
Tigerbeast11 - 17.12.2009
I want something like that, but it sounds a bit too complicated...
Код:
Undefined symbol, "BestKiller"