Leaderboard [help?]
#1

So.. hey everyone im trying to searching at ****** how to make leaderboard with Textdraws so i find many but Not in my brain...

What do you mean?After players joining DM MAP... Showing him a Leaderboard - Textdraw Top5 kills only So after a map finished automacily says who win the map..So i want now a How to make Leaderboard with Textdraw TOP5 Kills... how?

Still not understand? I Want like this http://forum.sa-mp.com/showpost.php?...2&postcount=44 But without Score i want Kills how?!
Reply
#2

Care if I use this thread as my signature?
Reply
#3

no problem.
Reply
#4

HELP?
Reply
#5

OK Everyone... im creating the Textdraws.. but i need help after player killing someone Make his name at Player#[num]
Example:

Thanks - 30Kills
Test - 25Kills
Pro - 20 Kills
Me - 5kills

Like this but After player killing someone +1Kills to him... i hope if you understood me.

Code:
Textdraw7 = TextDrawCreate(35.200004, 181.440032, "Player #1 - Kills");
	TextDrawLetterSize(Textdraw7, 0.289199, 1.562666);
	TextDrawTextSize(Textdraw7, -366.400024, 71.680007);
	TextDrawAlignment(Textdraw7, 1);
	TextDrawColor(Textdraw7, -1);
	TextDrawSetShadow(Textdraw7, 0);
	TextDrawSetOutline(Textdraw7, 1);
	TextDrawBackgroundColor(Textdraw7, 51);
	TextDrawFont(Textdraw7, 1);
	TextDrawSetProportional(Textdraw7, 1);

	Textdraw8 = TextDrawCreate(33.600059, 201.600067, "Player #2 - Kills");
	TextDrawLetterSize(Textdraw8, 0.309999, 1.495466);
	TextDrawAlignment(Textdraw8, 1);
	TextDrawColor(Textdraw8, -1);
	TextDrawSetShadow(Textdraw8, 0);
	TextDrawSetOutline(Textdraw8, 1);
	TextDrawBackgroundColor(Textdraw8, 51);
	TextDrawFont(Textdraw8, 1);
	TextDrawSetProportional(Textdraw8, 1);

	Textdraw9 = TextDrawCreate(33.600051, 221.760101, "Player#3 - Kills");
	TextDrawLetterSize(Textdraw9, 0.309199, 1.622400);
	TextDrawAlignment(Textdraw9, 1);
	TextDrawColor(Textdraw9, -1);
	TextDrawSetShadow(Textdraw9, 0);
	TextDrawSetOutline(Textdraw9, 1);
	TextDrawBackgroundColor(Textdraw9, 51);
	TextDrawFont(Textdraw9, 1);
	TextDrawSetProportional(Textdraw9, 1);

Textdraw10 = TextDrawCreate(32.799991, 241.173385, "Player #4 - Kills");
	TextDrawLetterSize(Textdraw10, 0.316400, 1.712000);
	TextDrawAlignment(Textdraw10, 1);
	TextDrawColor(Textdraw10, -1);
	TextDrawSetShadow(Textdraw10, 0);
	TextDrawSetOutline(Textdraw10, 1);
	TextDrawBackgroundColor(Textdraw10, 51);
	TextDrawFont(Textdraw10, 1);
	TextDrawSetProportional(Textdraw10, 1);
Reply
#6

You should use your kills variable if any. Easiest way to do it without working much onto the code would be replacing in this line:

playerScores[index][player_Score] = GetPlayerScore(i);

GetPlayerScore(i) with your player variable.
Reply
#7

Sorry but still not understand you can you explain more?!?
Reply
#8

bumb?
Reply
#9

A textdraws?!? You mean after a player killing someone put his name in the #1player between the players kills!!?
Reply
#10

Yes how can everyone help me pleaseeeeeeeeeee
Reply
#11

stop bumb your threads... if someone know they will helping you.
Reply
#12

YOU GUYS STILL NOT UNDERSTAND? HERE YOU GO LEAVE THE NAMES.. ONLY HOW TO MAKE LIKE THIS. MY TEXTDRAW IS READY

Reply
#13

Help meeeeee
Reply
#14

You need to look up sorting in pawn... That\'s how this is done... Sort the values, and update the textdraw strings.
Reply
#15

Thanks god someone Replyed but how to do that?
Reply
#16

Code.


You need to store the leaderboard to an array, and then go through that array comparing it to whoever has gone into bottom place, and moving up the board simply putting whoever was above them, down one...
Reply
#17

... man first time i\'ll try it can you give me a Example?? pls
Reply
#18

Store the players\' score in an array, use a sorting algorithm (http://forum.sa-mp.com/showpost.php?...postcount=1737) then take the last 5 values.


An example is provided beyond the provided link.


If you have any questions or need help, then I can\'t help you. Bye.
Reply
#19

I really not understand this how it will update the textdraws after someone killing many players? you should understand what i mean...


Example:

Code:
#1- %s[PlayerName] - 43[Kills]
2. etc
3. etc
4.etc
we should use OnPlayerDeath kills++; right but how.
Reply
#20

add

new kills[MAX_PLAYERS];

on top of your script under includes and defines,


then under
Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    kills[killerid]++; //add this
    return 1;
}

//Then under

public OnPlayerSpawn(playerid) // you can also use onplayerconnect...
{
    new first, second, third, fourth, fifth;
    //make a loop
    for(new i=0;i<MAX_PLAYERS;i++) // This loop will check for the player that has the most kills
    {
        if(kills[i] > kills[first])
        {
            first = i;
        }
    }
    for(new d=0;d<MAX_PLAYERS;d++) // This loop will check for the player that has the second most kills
    {
        if(first == d) continue;
        if(kills[d] > kills[second])
        {
            second = d;
        }
    }
    for(new s=0;s<MAX_PLAYERS;s++) // This loop will check for the player that has the third most kills
    {
        if(first == s || second == s) continue;
        if(kills[s] > kills[third])
        {
            third = s;
        }
    }
    for(new a=0;a<MAX_PLAYERS;a++) // This loop will check for the player that has the fourth most kills
    {
        if(first == a || second == a || third == a) continue;
        if(kills[a] > kills[fourth])
        {
            fourth = a;
        }
    }
    for(new c=0;c<MAX_PLAYERS;c++) // This loop will check for the player that has the fifth most kills
    {
        if(first == c || second == c || third == c || fourth == c) continue;
        if(kills[c] > kills[fifth])
        {
            fifth = c;
        }
    }

    //Now you have the top 5 players with most kills
    /*Variables:
    first - id of the player with most kills
    second - id of the player with second most kills
    third - id of the player with third most kills
    fourth - id of the player with fourth most kills
    fifth - id of the player with fifth most kills
    */
    //Your only job now is to set the string of a textdraw to these 5 players and show it to a player that just connected(playerid)
    return 1;
}
I hope you can understand the code which I just wrote.


You\'re welcome.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)