BestKiller
#1

Hello, how i can to check who killed more people?
Example:
1. Name1 - Killed 412 people.
2. Name2 - Killed 348 people.
3. Name3 - Killed 224 people.
4. Name4 - Killed 123 people.
Reply
#2

Use a sorting algorithm - search for them, I'm sure you'll find at least two (full code) as ****** and I have both made them.
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=361560 like this?
Reply
#4

Up....
Reply
#5

Do you have a variable in your script for saving player kills, like pInfo[playerid][pKills] or Kills[playerid]?
Reply
#6

yes T_T
Reply
#7

Show me the code then I'll script for you.
Do you want it with dialog?
Reply
#8

OnPlayerDeath
Kills[playerid] ++;
Reply
#9

Try this
pawn Код:
if (strcmp("/best", cmdtext, true, 10) == 0)
{
    new best[4], currentscore = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && Kills[i] > currentscore)
        {
            best[0] = i;
        }
    }
    currentscore = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && Kills[i] > currentscore && i != best[0])
        {
            best[1] = i;
        }
    }
    currentscore = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && Kills[i] > currentscore && i != best[0] && i != best[1])
        {
            best[2] = i;
        }
    }
    currentscore = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && Kills[i] > currentscore && i != best[0] && i != best[1] && i != best[2])
        {
            best[3] = i;
        }
    }
    new string[128];
    format(string, sizeof(string), "%s - Killed %d People\n%s - Killed %d People\n%s - Killed %d People\n%s - Killed %d People", Nick(best[0]), Kills[best[0]], Nick(best[1]), Kills[best[1]], Nick(best[2]), Kills[best[2]], Nick(best[3]), Kills[best[3]]);
    ShowPlayerDialog(playerid, 658, DIALOG_STYLE_MSGBOX, "BestKiller List", string, "Close", "");
   
    return 1;
}
Reply
#10

Quote:
Originally Posted by MouseBreaker
Посмотреть сообщение
Try this
pawn Код:
if (strcmp("/best", cmdtext, true, 10) == 0)
{
    new best[4], currentscore = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && Kills[i] > currentscore)
        {
            best[0] = i;
        }
    }
    currentscore = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && Kills[i] > currentscore && i != best[0])
        {
            best[1] = i;
        }
    }
    currentscore = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && Kills[i] > currentscore && i != best[0] && i != best[1])
        {
            best[2] = i;
        }
    }
    currentscore = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && Kills[i] > currentscore && i != best[0] && i != best[1] && i != best[2])
        {
            best[3] = i;
        }
    }
    new string[128];
    format(string, sizeof(string), "%s - Killed %d People\n%s - Killed %d People\n%s - Killed %d People\n%s - Killed %d People", Nick(best[0]), Kills[best[0]], Nick(best[1]), Kills[best[1]], Nick(best[2]), Kills[best[2]], Nick(best[3]), Kills[best[3]]);
    ShowPlayerDialog(playerid, 658, DIALOG_STYLE_MSGBOX, "BestKiller List", string, "Close", "");
   
    return 1;
}
ty so much!
but my name printed 4 times:
NoaM - Killed 1 People
NoaM - Killed 1 People
NoaM - Killed 1 People
NoaM - Killed 1 People
i can do -
Код:
if(IsPlayerConnected(i) && Kills[i] > currentscore && i != best[0] && i != best[1]  &&  Nick(best[0]) != Nick(best[1]))
??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)