Jump to content
  • 0
Sign in to follow this  
ZelosAvalon

Event Ranking

Question

Hi guys, this is my SQL table, and i want to make an ranking for it, but idk what to do, can anyone help me with this ?

CREATE TABLE IF NOT EXISTS `event_rank` (
  `id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `name` VARCHAR(30) NOT NULL DEFAULT '',
  `event_points` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `t_event_points` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM;

 

i want a ranking like this:

 

rank:

 

name (character) already earn X events points



ranking is by character not account!
 
I would appreciate some help! ty all
 
 
 
 
May The Force Be With You

Share this post


Link to post
Share on other sites

12 answers to this question

Recommended Posts

  • 0

Do you want a NPC to search in that table the TOP 10 and show them sorted desc? And what is the difference between even_points and t_even_points?

Share this post


Link to post
Share on other sites
  • 0

Do you want a NPC to search in that table the TOP 10 and show them sorted desc? And what is the difference between even_points and t_even_points?

 

t_event_point is just for count = total points already earned

 

event_point you can spend for buy event items

 

like this:

 

you already earned t_event_points, but you have event_points to spend

Share this post


Link to post
Share on other sites
  • 0

So 'alias' total_event_points... anyway this must be in request forum.

 

As far I understand you, you want just a NPC that list the TOP10 (or whatever) users who has the higher t_event_points value, right?

Share this post


Link to post
Share on other sites
  • 0

So 'alias' total_event_points... anyway this must be in request forum.

 

As far I understand you, you want just a NPC that list the TOP10 (or whatever) users who has the higher t_event_points value, right?

 

yes I would like a ranking that show the top 10 where the points will be calculated by t_event_points,

 

==============================================================================

 

[ANOTHER TOPIC]

 

if possible I would like the players could change the page and see the other players in the ranking.

for example:

 

Top 1-10 Ranking

1 - Name1 - 2000 Pts

2 - Name2 - 1890 Pts

3 - Name3 - 1712 Pts

4 - Name4 - 1680 Pts

5 - Name5 - 1578 Pts

6 - Name6 - 1572 Pts

7 - Name7 - 1300 Pts

8 - Name8 - 1256 Pts

9 - Name9 - 1210 Pts

10 - Name10 - 1000 Pts

 

Next>

 

in the next area appear the next 10 of top ranked, rank 11 to 20

 

Top 11-20 Ranking

11 - Name1 - 956 Pts

[...]

20 - Name20 - 400 pts

 

Next>

 

in the next area appear rank 21 to 30 and so on...

this would be repeated until no more people in the ranking

Share this post


Link to post
Share on other sites
  • 0

It's possible, I will help you as soon as possible, but anyway, I recommend you to puy just top10 and in your website show the whole rank.

 

- Message:

You had a total of X points, you can use Y points.

 

- Menu:
[show rank]
[Exit]

- Show rank
[TOP 10]

Edited by rokimoki

Share this post


Link to post
Share on other sites
  • 0

If you have PVP Rankings, just follow the script and change the variables and tables there.

 

That's right.

 

 

 

// ------------------------------------------------
// Event points ranking [SQL Version] v1.0
// ------------------------------------------------
// Developed by Rokimoki for ZelosAvalon.ç
// URL: http://herc.ws/board/topic/13501-event-ranking/
// ------------------------------------------------
prontera,165,168,3    script    EventPoint Rank#EventPoint::EventPointR    2_BULLETIN_BOARD,{
    mes "[^FF0000Event Points Rank^000000]";
    cleararray .@players$[0], "", 10; // defining 10 positions
    cleararray .@event_point[0], 0, 10;
    query_sql("SELECT `name`, `t_event_points` FROM `event_rank` DESC LIMIT 10;", .@players$, .@event_point);
    for (.@i = 0; .@i < 10; .@i++) {
        if (strcmp(.@players$[.@i], "") == 0) break; // if some is empty, stop printing
        mes (.@i + 1) + ".- ^0000FF" + .@players$[.@i] + "^000000 - ^FF0000" + .@event_point[.@i] + "^000000 Pts.";
    }
close;
} // End Script
Edited by rokimoki

Share this post


Link to post
Share on other sites
  • 0
: DB error - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC LIMIT 10' at line 1
[Debug]: at c:\users\conrado\desktop\projeto\ragnarok offline emulator\hercules-master\src\map\script.c:16299 - SELECT `name`, `t_event_points` FROM `event_rank` DESC LIMIT 10;
 

Share this post


Link to post
Share on other sites
  • 0
: DB error - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC LIMIT 10' at line 1

[Debug]: at c:\users\conrado\desktop\projeto\ragnarok offline emulator\hercules-master\src\map\script.c:16299 - SELECT `name`, `t_event_points` FROM `event_rank` DESC LIMIT 10;

 

CREATE TABLE IF NOT EXISTS `event_rank` (

`id` INT(11) UNSIGNED NOT NULL DEFAULT '0',

`name` VARCHAR(30) NOT NULL DEFAULT '',

`event_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0',

`t_event_points` INT(11) UNSIGNED NOT NULL DEFAULT '0',

PRIMARY KEY (`id`)

) ENGINE=MyISAM;

 

that should be solve your problem.

Share this post


Link to post
Share on other sites
  • 0

 

: DB error - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC LIMIT 10' at line 1

[Debug]: at c:\users\conrado\desktop\projeto\ragnarok offline emulator\hercules-master\src\map\script.c:16299 - SELECT `name`, `t_event_points` FROM `event_rank` DESC LIMIT 10;

 

CREATE TABLE IF NOT EXISTS `event_rank` (

`id` INT(11) UNSIGNED NOT NULL DEFAULT '0',

`name` VARCHAR(30) NOT NULL DEFAULT '',

`event_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0',

`t_event_points` INT(11) UNSIGNED NOT NULL DEFAULT '0',

PRIMARY KEY (`id`)

) ENGINE=MyISAM;

 

that should be solve your problem.

 

now all NPCs who used the event table rank stopped working LOL

 

my npcs:

 

Event_Helper

Event_Invasion

Share this post


Link to post
Share on other sites
  • 0

do you use a test server? as far I know, your sql DB the `id` field is not the table `id`, is the `character_id` from the player, anyway, should be a `primary_key` to avoid duplicates, but as far I see in the script, you have `ON DUPLICATE KEY UPDATE`, so this is better if you use `primary_key`, if you don't have one this gives error so, if that worked before change anything, I think you already had a `primary_key` defined (which was not represented in the sql schematic, that's why Shatotech told you to do that).

 

I recommend you to do the `id` auto_increment primary key, and have a `char_id`, `event_points` and `total_event_points`, don't duplicate data as `name` that you can get by a sql query, but you can have a `name` column too. Of course this require other script modification so I don't recommend if you don't want to change.

 

Anyway, I saw here that you had the primary key already.

 

So, ignore everything before (your scripts are perfect, but read the post). Change my sql and replace by:

 

SELECT `name`, `t_event_points` FROM `event_rank` ORDER BY `t_event_points` DESC LIMIT 10;

 

PS: You should use a test server first.

Edited by rokimoki

Share this post


Link to post
Share on other sites
  • 0

do you use a test server? as far I know, your sql DB the `id` field is not the table `id`, is the `character_id` from the player, anyway, should be a `primary_key` to avoid duplicates, but as far I see in the script, you have `ON DUPLICATE KEY UPDATE`, so this is better if you use `primary_key`, if you don't have one this gives error so, if that worked before change anything, I think you already had a `primary_key` defined (which was not represented in the sql schematic, that's why Shatotech told you to do that).

 

I recommend you to do the `id` auto_increment primary key, and have a `char_id`, `event_points` and `total_event_points`, don't duplicate data as `name` that you can get by a sql query, but you can have a `name` column too. Of course this require other script modification so I don't recommend if you don't want to change.

 

Anyway, I saw here that you had the primary key already.

 

So, ignore everything before (your scripts are perfect, but read the post). Change my sql and replace by:

 

SELECT `name`, `t_event_points` FROM `event_rank` ORDER BY `t_event_points` DESC LIMIT 10;

 

PS: You should use a test server first.

 

tyvm working now, i reference you in script http://upaste.me/6d2234037a1ae42c9

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

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