PDA

View Full Version : Leaderboard [help?]


Thanks
11/06/2017, 09:51 PM
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?p=1178082&postcount=44 But without Score i want Kills how?!

Toroi
11/06/2017, 09:54 PM
Care if I use this thread as my signature?

Thanks
11/06/2017, 09:55 PM
no problem.

Thanks
11/06/2017, 10:17 PM
HELP?

Thanks
12/06/2017, 12:14 AM
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.

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);

Private200
12/06/2017, 12:20 AM
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.

Thanks
12/06/2017, 12:23 AM
Sorry but still not understand you can you explain more?!?

Thanks
12/06/2017, 01:04 AM
bumb?

RedRex
12/06/2017, 09:08 AM
A textdraws?!? You mean after a player killing someone put his name in the #1player between the players kills!!?

Thanks
12/06/2017, 05:26 PM
Yes how can everyone help me pleaseeeeeeeeeee

RedRex
12/06/2017, 10:03 PM
stop bumb your threads... if someone know they will helping you.

Thanks
12/06/2017, 10:31 PM
YOU GUYS STILL NOT UNDERSTAND? HERE YOU GO LEAVE THE NAMES.. ONLY HOW TO MAKE LIKE THIS. MY TEXTDRAW IS READY

http://i.imgur.com/88RZEU2.png?1

Thanks
13/06/2017, 06:19 PM
Help meeeeee

Sew_Sumi
13/06/2017, 08:40 PM
You need to look up sorting in pawn... That's how this is done... Sort the values, and update the textdraw strings.

Thanks
13/06/2017, 10:14 PM
Thanks god someone Replyed but how to do that?

Sew_Sumi
14/06/2017, 03:53 AM
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...

Thanks
14/06/2017, 06:30 AM
... man first time i'll try it can you give me a Example?? pls

CheezIt
14/06/2017, 06:56 AM
Store the players' score in an array, use a sorting algorithm (http://forum.sa-mp.com/showpost.php?p=1085586&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.

Thanks
14/06/2017, 09:25 AM
I really not understand this how it will update the textdraws after someone killing many players? you should understand what i mean...


Example:

#1- %s[PlayerName] - 43[Kills]
2. etc
3. etc
4.etc

we should use OnPlayerDeath kills++; right but how.

andrejc999
14/06/2017, 10:26 AM
add
new kills[MAX_PLAYERS];
on top of your script under includes and defines,

then under

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.

Thanks
14/06/2017, 10:31 AM
Nice.. but how did the textdraws updating? you didn't put my textdraws...

Textdraw19
Textdraw20
Textdraw21
Textdraw22
Textdraw23

You must put thiss right?

Thanks
14/06/2017, 10:44 AM
like this?

public OnPlayerSpawn(playerid) // you can also do 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;
TextDrawSetString(Textdraw19, kills[first]);
}
}
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;
TextDrawSetString(Textdraw20, kills[second]);
}
}
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;
TextDrawSetString(Textdraw21, kills[third]);
}
}
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;
TextDrawSetString(Textdraw22, kills[fourth]);
}
}
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;
TextDrawSetString(Textdraw23, kills[fifth]);
}
}

andrejc999
14/06/2017, 10:47 AM
new Name[5][MAX_PLAYER_NAME], string[5][64];

GetPlayerName(first, Name[0], MAX_PLAYER_NAME);
GetPlayerName(second, Name[1], MAX_PLAYER_NAME);
GetPlayerName(third, Name[2], MAX_PLAYER_NAME);
GetPlayerName(fourth, Name[3], MAX_PLAYER_NAME);
GetPlayerName(fifth, Name[4], MAX_PLAYER_NAME);

format(string[0], sizeof(string[0]), "~R~#1 - ~W~%s", Name[0],);
format(string[1], sizeof(string[1]), "~R~#2 - ~W~%s", Name[1],);
format(string[2], sizeof(string[2]), "~R~#3 - ~W~%s", Name[2],);
format(string[3], sizeof(string[3]), "~R~#4 - ~W~%s", Name[3],);
format(string[4], sizeof(string[4]), "~R~#5 - ~W~%s", Name[4],);

TextDrawSetString(Textdraw19, string[0]);
TextDrawSetString(Textdraw20, string[1]);
TextDrawSetString(Textdraw21, string[2]);
TextDrawSetString(Textdraw22, string[3]);
TextDrawSetString(Textdraw23, string[4]);

TextDrawShowForPlayer(playerid, Textdraw19);
TextDrawShowForPlayer(playerid, Textdraw20);
TextDrawShowForPlayer(playerid, Textdraw21);
TextDrawShowForPlayer(playerid, Textdraw22);
TextDrawShowForPlayer(playerid, Textdraw23);

SetTimerEx("TextdrawHide", 5000, false, "uiiiii", playerid, Textdraw19, Textdraw20, Textdraw21, Textdraw22, Textdraw23); //A timer which will hide the textdraw, it's set to 5 seconds and you can change that if you want to...

//Now put this under the new kills...

forward TextdrawHide(playerid, textdraw1, textdraw2, textdraw3, textdraw4, textdraw5);

//And put this down where other public functions are...

public TextdrawHide(playerid, textdraw1, textdraw2, textdraw3, textdraw4, textdraw5)
{
TextDrawHideForPlayer(playerid, textdraw1);
TextDrawHideForPlayer(playerid, textdraw2);
TextDrawHideForPlayer(playerid, textdraw3);
TextDrawHideForPlayer(playerid, textdraw4);
TextDrawHideForPlayer(playerid, textdraw5);
return 1;
}




And read my last comment I changed it a bit

Please, if you get any errors send them to me and I'll fix them...

EDIT:I changed the code just coppy it...

andrejc999
14/06/2017, 10:50 AM
EDIT: Deleted

Thanks
14/06/2017, 09:29 PM
Sorry but where should i put this?

new Name[5][MAX_PLAYER_NAME], string[5][64];

GetPlayerName(first, Name[0], MAX_PLAYER_NAME);
GetPlayerName(second, Name[1], MAX_PLAYER_NAME);
GetPlayerName(third, Name[2], MAX_PLAYER_NAME);
GetPlayerName(fourth, Name[3], MAX_PLAYER_NAME);
GetPlayerName(fifth, Name[4], MAX_PLAYER_NAME);

format(string[0], sizeof(string[0]), "~R~#1 - ~W~%s", Name[0],);
format(string[1], sizeof(string[1]), "~R~#2 - ~W~%s", Name[1],);
format(string[2], sizeof(string[2]), "~R~#3 - ~W~%s", Name[2],);
format(string[3], sizeof(string[3]), "~R~#4 - ~W~%s", Name[3],);
format(string[4], sizeof(string[4]), "~R~#5 - ~W~%s", Name[4],);

TextDrawSetString(Textdraw19, string[0]);
TextDrawSetString(Textdraw20, string[1]);
TextDrawSetString(Textdraw21, string[2]);
TextDrawSetString(Textdraw22, string[3]);
TextDrawSetString(Textdraw23, string[4]);

TextDrawShowForPlayer(playerid, Textdraw19);
TextDrawShowForPlayer(playerid, Textdraw20);
TextDrawShowForPlayer(playerid, Textdraw21);
TextDrawShowForPlayer(playerid, Textdraw22);
TextDrawShowForPlayer(playerid, Textdraw23);

Sew_Sumi
15/06/2017, 02:03 AM
This is why copying and pasting rarely teaches anything.

You need to learn how to use code before simply putting in a feature, especially when the next feature you want to add, will simply be the next thing you ask on the forum.

Thanks
15/06/2017, 08:10 AM
Hello again... im trying to use it but i got errors

My Code
if(kills[i] > kills[first])
{
GetPlayerName(first, Name[0], MAX_PLAYER_NAME);
format(string[0], sizeof(string[0]), "~R~#1 - ~W~%s", Name[0],);
TextDrawSetString(Textdraw19, string[0]);
TextDrawShowForPlayer(playerid, Textdraw19);

first = i;
}
}


ERRORS
C:\Users\---\Desktop\MoG\gamemodes\Warehouse.pwn(585) : error 001: expected token: "]", but found "-integer value-"
C:\Users\---\Desktop\MoG\gamemodes\Warehouse.pwn(585) : warning 215: expression has no effect
C:\Users\---\Desktop\MoG\gamemodes\Warehouse.pwn(585) : error 001: expected token: ";", but found "]"
C:\Users\---\Desktop\MoG\gamemodes\Warehouse.pwn(585) : error 029: invalid expression, assumed zero
C:\Users\---\Desktop\MoG\gamemodes\Warehouse.pwn(585) : fatal error 107: too many error messages on one line

Thanks
16/06/2017, 01:03 AM
Errors? help

CheezIt
16/06/2017, 01:05 AM
I'm just going to quote this here since you ignored me, it's the most viable way.

Store the players' score in an array, use a sorting algorithm (http://forum.sa-mp.com/showpost.php?p=1085586&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.

Thanks
16/06/2017, 01:09 AM
I'm just going to quote this here since you ignored me, it's the most viable way.

Dude.. you have to follow the code.. and i dont know how to learn about quickSort..

CheezIt
16/06/2017, 04:18 AM
Dude.. you have to follow the code.. and i dont know how to learn about quickSort..

If you want my help, then follow my guidelines (you didn't even bother to try anything related to them, there's another step you haven't reached yet; which is sorting the IDs accordingly alongside the scores). If you want rubbish code that just "works", then I cannot help you.

As I said, there's an example beyond the link. If you are clueless to an extent that you are ACTUALLY completely clueless, then learn scripting before proceeding.

If you don't like my teaching process (which is free and I have freedom to do it how I want), then there's always hiring someone with the knowledge (expect to pay) or waiting for someone else to feed the code to you.