Jump to content
  • 0

Top 5 PVP SQL Query


simplynice

Question


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  128
  • Reputation:   4
  • Joined:  11/14/11
  • Last Seen:  

So i have this global_reg_val:

PVPTotal

so everytime someone killed someone it adds : PVPTotal = 1 + 1 etc..

Now how can i query this in sql as top 5 highest?

I can't make it work though:

How to get the name of the account_id

//set @nb, query_sql("select account_id,name,str,value from `global_reg_value` WHERE str = 'PVPTotal' ORDER BY str DESC LIMIT 5", @name$, @value,@str ,@account_id);
//mes "Hall Of Fame: TOP5";
//mes "1.("+@value[0]+")"; // Will return a person with the biggest fame value.
//mes "2.("+@value[1]+")";
//mes "3.("+@value[2]+")";
//mes "4.("+@value[3]+")";
//mes "5.("+@value[4]+")";
//close;

Edited by simplynice
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Here's one way you could do the SQL query:

SELECT `char`.`name`, global_reg_value.`value` 
FROM global_reg_value LEFT JOIN `char` ON global_reg_value.char_id=`char`.char_id 
WHERE global_reg_value.`str` = 'PVPTotal' 
ORDER BY CAST(global_reg_value.`value` AS SIGNED) DESC 
LIMIT 5;

So your NPC script could look something like:

query_sql "SELECT `char`.`name`, global_reg_value.`value` " + 
         "FROM global_reg_value LEFT JOIN `char` ON global_reg_value.char_id=`char`.char_id " + 
         "WHERE global_reg_value.`str` = 'PVPTotal' " + 
         "ORDER BY CAST(global_reg_value.`value` AS SIGNED) DESC " + 
         "LIMIT 5", .@name$, .@points;

mes "Hall Of Fame: TOP5";
for (set .@i,0; .@i < getarraysize(.@name$); set .@i,.@i+1) {
mes (.@i+1) + ". " + .@name$[.@i] + " ("+ .@points[.@i] +")";
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  128
  • Reputation:   4
  • Joined:  11/14/11
  • Last Seen:  

Thank you very much sir.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...