Jump to content
  • 0

Top 10 ranking based on a variable


Question

Posted

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!

2 answers to this question

Recommended Posts

Posted (edited)

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
Posted

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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...