Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 10/02/20 in all areas

  1. 1 point
    AnnieRuru

    gold_rank not working (rathena)

    so many rathena members here ... at least please put it on your profile so people like us don't have to do convert it again to rathena blah blah so many mistakes on your script 1. the checkweight should check from the variable from the *input, if you put check on goldPoint then if players actually farm high amount they might forever said being overweight 2. the overall ranking you put it this way for (.@i = 0; .@i < .@nb; ++.@i) mes "[ ^C6A518Gold Room Assistant^000000 ]"; mes (.@i +1)+". "+ .@name$[.@i] +" - "+ .@ppk[.@i] +" Kills"; should be this way mes "[ ^C6A518Gold Room Assistant^000000 ]"; for (.@i = 0; .@i < .@nb; ++.@i) mes (.@i +1)+". "+ .@name$[.@i] +" - "+ .@ppk[.@i] +" Kills"; 3. and the "your current rank" can be found on the pinned topic 4. rathena don't support strcharinfo(PC_MAP), it just strcharinfo(3) 5. finally its `Points` not `Kills`, this script gives random 1~3 points per kill, and the SQL table log in points not kills https://gist.github.com/AnnieRuru/88e558b500a6e4afe00b559e7dcacd1b
  2. 1 point
    AnnieRuru

    Advance SQL commands

    6. How to show the current rank of the player Question : This is the part of the script, output as below .@nb = query_sql("SELECT `name`, `kills` FROM `pvpladder` ORDER BY `kills` DESC LIMIT 5", .@name$, .@kills); for ( .@i = 0; .@i < .@nb; .@i++ ) mes "No."+(.@i+1)+" ["+ .@name$[.@i] +"] ~ "+ .@kills[.@i] +" kills"; No.1 [Alice] ~ 19 kills No.2 [Emily] ~ 11 kills No.3 [Irene] ~ 11 kills No.4 [Brittany] ~ 8 kills No.5 [Fiona] ~ 7 kills 2nd place and 3rd place has the same amount of kills, how do I make both of them display as 2nd place like this ? No.1 [Alice] ~ 19 kills No.2 [Emily] ~ 11 kills No.2 [Irene] ~ 11 kills No.4 [Brittany] ~ 8 kills No.5 [Fiona] ~ 7 kills Answer : Method no.1: Convert the table into InnoDB will return the result faster. Allow to use OFFSET .@nb = query_sql("SELECT `name`, `kills`, FIND_IN_SET(`kills`, (SELECT GROUP_CONCAT(`kills` ORDER BY `kills` DESC) FROM `pvpladder`)) FROM `pvpladder` ORDER BY `kills` DESC LIMIT 5", .@name$, .@kills, .@rank); for ( .@i = 0; .@i < .@nb; ++.@i ) mes "No."+ .@rank[.@i] +" ["+ .@name$[.@i] +"] ~ "+ .@kills[.@i] +" kills"; Method no.2: This method return result faster than method 1 in huge table. Not allow to use OFFSET .@query$ = "SELECT `name`, IF(@d=t.`kills`, @r, @r:=@i), @d:=t.`kills`, @i:=@i+1 "; .@query$ += "FROM `pvpladder` t, (SELECT @d:=0, @r:=0, @i:=1)q "; .@query$ += "ORDER BY `kills` DESC LIMIT 5"; .@nb = query_sql(.@query$, .@name$, .@rank, .@kills, .@dummy); for ( .@i = 0; .@i < .@nb; ++.@i ) mes "No."+ .@rank[.@i] +" ["+ .@name$[.@i] +"] ~ "+ .@kills[.@i] +" kills"; . . Question : How do I show the current ranking of the player ? mes "Your kills -> "+ .@kills; mes "Your rank -> "+ .@rank; Answer : query_sql "SELECT `kills`, 1+(SELECT COUNT(1) FROM `pvpladder` t1 WHERE t1.`kills` > t2.`kills`) FROM `pvpladder` t2 WHERE `char_id` = "+ getcharid(0), .@kills, .@rank; Remember to index the `kills` field Reference : https://dba.stackexchange.com/questions/13703/get-the-rank-of-a-user-in-a-score-table .
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.