SA-MP Forums Archive
TOP 5 Kills - 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)
+--- Thread: TOP 5 Kills (/showthread.php?tid=647011)



TOP 5 Kills - RedRex - 28.12.2017

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!= MAX_PLAYERS; ++i)
        {
            if(
IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                
playerKills[index][player_Kill] = GetPlayerKills(i);
                
playerKills[index++][player_ID] = i;
            }
        }
        
GetPlayerHighestKills(playerKills0index);
        new
            
score_Text[256] = "~n~",
            
player_Name[20]
        ;
        for(new 
i5; ++i)
        {
            if(
index)
            {
                
GetPlayerName(playerKills[i][player_ID], player_Namesizeof(player_Name));
                
format(score_Textsizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d"score_Text1player_NameplayerKills[i][player_Kill]);
            }
            else
                
format(score_Textsizeof(score_Text), "%s~n~~b~%d. ~r~N/A"score_Text1);
        }
        
TextDrawSetString(text_Top5[1], score_Text);
        
TextDrawShowForPlayer(playeridtext_Top5[0]);
        
TextDrawShowForPlayer(playeridtext_Top5[1]); 
PHP код:
stock GetPlayerKills(playerid)
{
    return 
PlayerInfo[playerid][pKills];
}
stock GetPlayerHighestKills(array[][rankingEnum], leftright)
{
    new
        
tempLeft left,
        
tempRight right,
        
pivot = array[(left right) / 2][player_Kill],
        
tempVar
    
;
    while(
tempLeft <= tempRight)
    {
        while(array[
tempLeft][player_Kill] > pivottempLeft++;
        while(array[
tempRight][player_Kill] < pivottempRight--;
        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 tempRightGetPlayerHighestKills(array, lefttempRight);
    if(
tempLeft rightGetPlayerHighestKills(array, tempLeftright);




Re: TOP 5 Kills - Hunud - 28.12.2017

Use a timer


Re: TOP 5 Kills - RedRex - 28.12.2017

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 !!


Re: TOP 5 Kills - RedRex - 28.12.2017

any help guys?


Re: TOP 5 Kills - mirou123 - 28.12.2017

What is that code you posted? How does it behave?


Re: TOP 5 Kills - RedRex - 28.12.2017

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

        new
            
score_Text[256] = "~n~",
            
player_Name[50]
        ;
        for(new 
i5; ++i)
        {
            if(
index)
            {
                
GetPlayerName(playerKills[i][player_ID], player_Namesizeof(player_Name));
                
format(score_Textsizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d"score_Text1player_NameplayerKills[i][player_Kill]);
            }
            else
                
format(score_Textsizeof(score_Text), "%s~n~~b~%d. ~r~N/A"score_Text1);
        }
    
TextDrawSetString(text_Top5[1], score_Text);
    
TextDrawShowForPlayer(playeridtext_Top5[0]);
    
TextDrawShowForPlayer(playeridtext_Top5[1]);
    return 
1;

Need anything else? Just help me!


Re: TOP 5 Kills - Sew_Sumi - 28.12.2017

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.


Re: TOP 5 Kills - RedRex - 28.12.2017

How to do that!!!


Re: TOP 5 Kills - Sew_Sumi - 28.12.2017

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.


Re: TOP 5 Kills - RedRex - 29.12.2017

Anyone help me!!