KRMizu Posted July 3, 2020 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 29 Reputation: 0 Joined: 05/26/18 Last Seen: November 27, 2022 Share Posted July 3, 2020 Hello, I'm trying to show the player's classification, I found an example but he doesn't count the position if the amount is equal, for example: Player 1: 600Exp Player 2: 400 Exp Player 3: 400 Exp Player 4: 300 Exp The way I found the position of player 2 and 3 is the same as: Player 1: Top 1 Player 2: Top 2 Player 3: Top 2 Player 4: Top 3 I would like it to look like this: Player 1: Top 1 Player 2: Top 2 Player 3: Top 3 Player 4: Top 4 Here is an example I found below: dispbottom "============== My Rank ==============", 0xffe066; query_sql( "SELECT `points`, 1 + (SELECT COUNT(1) FROM `mvp_ranking` t1 WHERE t1.`points` > t2.`points`) FROM `mvp_ranking` t2 WHERE `char_id` = "+ getcharid(0), .@points, .@rank); dispbottom "My Rank is: " + .@rank+ ".", 0x6666ff; dispbottom "My Points is: " + .@points+ ".", 0x6666ff; dispbottom "==========================================", 0xffe066; Quote Link to comment Share on other sites More sharing options...
0 Kreustoo Posted July 3, 2020 Group: Members Topic Count: 34 Topics Per Day: 0.01 Content Count: 216 Reputation: 45 Joined: 05/03/13 Last Seen: March 9 Share Posted July 3, 2020 Hello, This should work (not tested): dispbottom "============== My Rank ==============", 0xffe066; query_sql( "SELECT `points`, 1 + (SELECT COUNT(1) FROM `mvp_ranking` t1 WHERE t1.`points` > t2.`points`) FROM `mvp_ranking` t2 WHERE `char_id` = "+ getcharid(0), .@points, .@rank); query_sql( "SELECT `char_id` FROM `mvp_ranking` WHERE `points` = "+ .@points, .@charid);//search all that are equals, supposing there's less than 127 players at the same value .@size = getarraysize(.@charid); for(.@i = 0;.@i<.@size && .@charid[.@i] != getcharid(0);.@i++){ //Parse every line and rank++ for each one different than charid .@rank++; } dispbottom "My Rank is: " + .@rank+ ".", 0x6666ff; dispbottom "My Points is: " + .@points+ ".", 0x6666ff; dispbottom "==========================================", 0xffe066; Be aware that the rank when they have the same number of points would depend of the entry in the database, not the time it had its points. If it's not clear, for example: Suppose Player 2 killed a mvp before player 3 => he's added in the table before the player 3--Player 3 got 400 points first, Player 3 has a better rank Player 3: 400 ExpPlayer 2: 399 Exp --Player 2 go to 400 points, Player 2 has now a better rank Player 2: 400 ExpPlayer 3: 400 Exp 1 Quote Link to comment Share on other sites More sharing options...
0 KRMizu Posted July 4, 2020 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 29 Reputation: 0 Joined: 05/26/18 Last Seen: November 27, 2022 Author Share Posted July 4, 2020 4 hours ago, Kreustoo said: Olá, Isso deve funcionar (não testado): Esteja ciente de que a classificação quando eles têm o mesmo número de pontos dependeria da entrada no banco de dados, não do tempo em que eles tiveram seus pontos. Se não estiver claro, por exemplo: Suponha que o Jogador 2 matou um mvp antes do jogador 3 => ele foi adicionado na mesa antes que o jogador 3 --Jogador 3 tenha 400 pontos primeiro, o Jogador 3 tenha uma classificação melhor Jogador 3: 400 Exp Jogador 2: 399 Exp --Jogador 2 para 400 pontos, o Jogador 2 agora tem uma classificação melhor Jogador 2: 400 Exp Jogador 3: 400 Exp I understand what you mean, unfortunately I have no other criteria for the tiebreaker or... I have an online time field, would it be possible to use it for the tiebreaker? Quote Link to comment Share on other sites More sharing options...
0 KRMizu Posted July 4, 2020 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 29 Reputation: 0 Joined: 05/26/18 Last Seen: November 27, 2022 Author Share Posted July 4, 2020 Thank you very much, what you did is perfect, I only have one problem, I have an NPC that also shows the Top 20, and the positions do not match the one shown for my character, for example this showing that I am the top 6, more in this than you made it for me shows that i am the top 9 This is just to show my position in the rank : This shows the overall rank for all players: Quote set .rank,20; next; mes " ^0412cc[TOP "+.rank+" Mineradores]^000000"; mes " "; for(.@i = 0;.@i<.rank;.@i++){ query_sql( "select `First_Name`, `xpmineracao`, `nvmineracao` from `hourly_points` where `xpmineracao` > '0' order by `xpmineracao` DESC", .@nomizin$[.@i], .@xpzera[.@i], .@nvzera[.@i] ); set .@z,.@i + 1; mes "^2c16d0[»]^000000Rank : ^f80505"+.@z+"° Colocado^000000"; mes "^2c16d0[»]^000000Jogador : ^0e1ecc"+.@nomizin$[.@i]+"^000000 "; switch(.@nvzera[.@i]){ case 1: set .nvrank$[.@i],"^0e1ecc[Novato]^000000"; break; case 2: set .nvrank$[.@i],"^0e1ecc[Aprendiz]^000000"; break; case 3: set .nvrank$[.@i],"^0e1ecc[Artesão]^000000"; break; case 4: set .nvrank$[.@i],"^0e1ecc[Especialista]^000000"; break; case 5: set .nvrank$[.@i],"^0e1ecc[Mestre]^000000"; break; case 6: set .nvrank$[.@i],"^0e1ecc[Grão-Mestre]^000000"; break; case 7: set .nvrank$[.@i],"^0e1ecc[Ancião]^000000"; break; } mes "^2c16d0[»]^000000Nv de Profissão: "+.nvrank$[.@i]+""; mes "^2c16d0[»]^000000Experiência Total : ^0e1ecc" + .@xpzera[.@i] + "^000000"; mes "^f80505===========================^000000"; .@z++; Quote Link to comment Share on other sites More sharing options...
0 Kreustoo Posted July 4, 2020 Group: Members Topic Count: 34 Topics Per Day: 0.01 Content Count: 216 Reputation: 45 Joined: 05/03/13 Last Seen: March 9 Share Posted July 4, 2020 It seems the first script search in mvp_ranking and the other in hourly_points? First) query_sql( "SELECT `points`, 1 + (SELECT COUNT(1) FROM `mvp_ranking` t1 WHERE t1.`points` > t2.`points`) FROM `mvp_ranking` t2 WHERE `char_id` = "+ getcharid(0), .@points, .@rank); -- Second) query_sql( "select `First_Name`, `xpmineracao`, `nvmineracao` from `hourly_points` where `xpmineracao` > '0' order by `xpmineracao` DESC", .@nomizin$[.@i], .@xpzera[.@i], .@nvzera[.@i] ); So you can be rank 6 in one and rank 9 on the other? Quote Link to comment Share on other sites More sharing options...
0 KRMizu Posted July 4, 2020 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 29 Reputation: 0 Joined: 05/26/18 Last Seen: November 27, 2022 Author Share Posted July 4, 2020 4 hours ago, Kreustoo said: Parece que a primeira pesquisa de script em mvp_ranking e a outra em hourly_points? Então você pode ser classificado em 6 em um e 9 em outro? Already managed to solve by adding an option ORDER BY `xpmineracao` DESC , `account_hourly` ASC , thank you very much I'm using the code you created. Quote Link to comment Share on other sites More sharing options...
Question
KRMizu
Hello, I'm trying to show the player's classification, I found an example but he doesn't count the position if the amount is equal, for example:
Player 1: 600Exp
Player 2: 400 Exp
Player 3: 400 Exp
Player 4: 300 Exp
The way I found the position of player 2 and 3 is the same as:
Player 1: Top 1
Player 2: Top 2
Player 3: Top 2
Player 4: Top 3
I would like it to look like this:
Player 1: Top 1
Player 2: Top 2
Player 3: Top 3
Player 4: Top 4
Here is an example I found below:
dispbottom "============== My Rank ==============", 0xffe066; query_sql( "SELECT `points`, 1 + (SELECT COUNT(1) FROM `mvp_ranking` t1 WHERE t1.`points` > t2.`points`) FROM `mvp_ranking` t2 WHERE `char_id` = "+ getcharid(0), .@points, .@rank); dispbottom "My Rank is: " + .@rank+ ".", 0x6666ff; dispbottom "My Points is: " + .@points+ ".", 0x6666ff; dispbottom "==========================================", 0xffe066;
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.