[plaese Help me]How to check the most of a variable?
#1

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?
Reply
#2

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;

    }
Reply
#3

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.
Reply
#4

BTW, is this even possible?
Reply
#5

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.
Reply
#6

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"?
Reply
#7

up u go...
Reply
#8

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.
Reply
#9

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.
Reply
#10

I want something like that, but it sounds a bit too complicated...

Код:
Undefined symbol, "BestKiller"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)