TOP 5 Kills
#1

Hello guys, I need help with this function I've Copy `Ryder Function for Highlist Scores And trying Change it From Scores to Kills What I mean? I want make It If there a player kill someone Textdraw Updated to
Example: RedRex - 1 Its mean I've killed a 1player now I've Creating it and Its worked But If I killed my Friend The textdraw is not updated to 1 or 2 Help me?

//OnPlayerDeath adding this


PHP код:
new
            
playerKills[MAX_PLAYERS][rankingEnum],
            
index
        
;
        for(new 
i; i != MAX_PLAYERS; ++i)
        {
            if(
IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                
playerKills[index][player_Kill] = GetPlayerKills(i);
                
playerKills[index++][player_ID] = i;
            }
        }
        
GetPlayerHighestKills(playerKills, 0, index);
        new
            
score_Text[256] = "~n~",
            
player_Name[20]
        ;
        for(new 
i; i < 5; ++i)
        {
            if(
i < index)
            {
                
GetPlayerName(playerKills[i][player_ID], player_Name, sizeof(player_Name));
                
format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", score_Text, i + 1, player_Name, playerKills[i][player_Kill]);
            }
            else
                
format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~r~N/A", score_Text, i + 1);
        }
        
TextDrawSetString(text_Top5[1], score_Text);
        
TextDrawShowForPlayer(playerid, text_Top5[0]);
        
TextDrawShowForPlayer(playerid, text_Top5[1]); 
PHP код:
stock GetPlayerKills(playerid)
{
    return 
PlayerInfo[playerid][pKills];
}
stock GetPlayerHighestKills(array[][rankingEnum], left, right)
{
    new
        
tempLeft = left,
        
tempRight = right,
        
pivot = array[(left + right) / 2][player_Kill],
        
tempVar
    
;
    while(
tempLeft <= tempRight)
    {
        while(array[
tempLeft][player_Kill] > pivot) tempLeft++;
        while(array[
tempRight][player_Kill] < pivot) tempRight--;
        if(
tempLeft <= tempRight)
        {
            
tempVar = array[tempLeft][player_Kill], array[tempLeft][player_Kill] = array[tempRight][player_Kill], array[tempRight][player_Kill] = tempVar;
            
tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
            
tempLeft++, tempRight--;
        }
    }
    if(
left < tempRight) GetPlayerHighestKills(array, left, tempRight);
    if(
tempLeft < right) GetPlayerHighestKills(array, tempLeft, right);
} 
Reply
#2

Use a timer
Reply
#3

Quote:
Originally Posted by Hunud
Посмотреть сообщение
Use a timer
Are you kidding me? Timer for what man? I just want If someone killed Updated the textdraw !!
Reply
#4

any help guys?
Reply
#5

What is that code you posted? How does it behave?
Reply
#6

PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new
            
playerKills[MAX_PLAYERS][rankingEnum],
            
index
        
;
        for(new 
i; i != MAX_PLAYERS; ++i)
        {
            if(
IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                
playerKills[index][player_Kill] = GetPlayerKills(i);
                
playerKills[index++][player_ID] = i;
            }
        }
        
GetPlayerHighestKills(playerKills, 0, index);

        new
            
score_Text[256] = "~n~",
            
player_Name[50]
        ;
        for(new 
i; i < 5; ++i)
        {
            if(
i < index)
            {
                
GetPlayerName(playerKills[i][player_ID], player_Name, sizeof(player_Name));
                
format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", score_Text, i + 1, player_Name, playerKills[i][player_Kill]);
            }
            else
                
format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~r~N/A", score_Text, i + 1);
        }
    
TextDrawSetString(text_Top5[1], score_Text);
    
TextDrawShowForPlayer(playerid, text_Top5[0]);
    
TextDrawShowForPlayer(playerid, text_Top5[1]);
    return 
1;
} 
Need anything else? Just help me!
Reply
#7

You've over-complicated this...

There's too much code somehow.

The kills for each player should also be under a global array, rather than one you are creating on each death.
Reply
#8

How to do that!!!
Reply
#9

Judging that the top 5 will only be able to change if someone actually enters the leaderboard, you could check the lowest of the 5 places, and check if the killerid actually even has enough to get on the board, rather than going through the whole process needlessly.

Also you can use

Код:
if(killerid != INVALID_PLAYER_ID)
And start counting also in your death, as killerid, hasn't been checked, nor has it been counted up, to add to their killcount.
Reply
#10

Anyone help me!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)