Jump to content
  • 0

Top 10 ranking based on a variable


Genesis

Question


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   2
  • Joined:  12/01/11
  • Last Seen:  

Hello all,

 

I am trying to create a simple ranking NPC ingame that will rank players based on a variable, this variable is increased automatically once a player is killed, or does a specific quest. I know SQL is an option but I wanted to code it without it. I was originally thinking of adding the top 10 players to an array, but the thing that i can't figure out is how I would continuously update this top list. Do you guys have any suggestions or potentially, some sample scripts I can take a look at to based mine off of? Thanks!

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   3
  • Joined:  02/24/12
  • Last Seen:  

You could use a variable to save the infos... but..:

"$"      - A global permanent variable.
           They are stored in database table `mapreg`.

http://svn.code.sf.net/p/rathena/svn/trunk/doc/script_commands.txt

They use sql too

 

- - - -

I don't think rAthena supports asort()arsort()krsort() or ksort()

You could ask in the src section if someone would add it for you then you could do it like this:

set $rank[<charid>],<value>;

and then use arsort() and pick the first 10 entires

Edited by Sunzuke
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Maybe like that

copyarray .@tmp_points, .points, .size;// points in temp array
.@tmp = .size;
while( .@tmp ) {
	.@max = .@tmp_points[0];
	.@index = 0;
	for ( .@i = 0; .@i < .@tmp; .@i++ )
		if ( .@max < .@tmp_points[.@i] ) {
			.points[ ( .size - .@tmp ) ] = .@tmp_points[.@i];
			.@index = .@i;
		}
	deletearray .@tmp_points[.@index], 1;
	.@tmp--;
}

  • Upvote 1
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...