Jump to content
  • 0

MVP Rank Menu.


trizzy

Question


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  92
  • Reputation:   2
  • Joined:  01/04/15
  • Last Seen:  

Can someone add a simple menu on this script?

Menu

1. Check TOP 10 MVP ranking. [ it shows here the Top 1-10 names ]

2. Check my rank  [ it shows here how many mvp have you kill. ]

3. nothing just passing by.

 

and if possible to add also reset ranking.

 

thanks in advance.

 

Original Topic

https://rathena.org/board/topic/66423-mvp-rank/

 

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  92
  • Reputation:   2
  • Joined:  01/04/15
  • Last Seen:  

I highly recommend you to use SQL instead of txt, because those data are saved in variables and it's much more harder to track and debug the script than you can imagine  /whisp .

 

Here is an expample you can use for what you are looking for in SQL:

 

STEP 1: LOAD THE TABLE IN YOUR SQL BEFORE USE THE SCRIPT

 

Run this query on your sql database:

SET FOREIGN_KEY_CHECKS=0;

-- ------------------------------------
--  Table structure for `mvp_ranking`
-- ------------------------------------
DROP TABLE IF EXISTS `mvp_ranking`;
CREATE TABLE `mvp_ranking` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `char_id` int(11) unsigned NOT NULL DEFAULT '0',
  `mvp_count` smallint(6) unsigned NOT NULL DEFAULT '1',
  PRIMARY KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-- ------------------------------------
--  End of table `mvp_ranking`.
-- ------------------------------------

STEP 2: LOAD THE SCRIPT IN YOUR SERVER

 

Create and load the next script:

-	script	Rank MvP	-1,{

OnInit:

setarray .mobid[0],1511,1647,1785,1630,1399,1039,1874,2068,1272,1719,1046,1389,1112,1115,1957,1418,1871,1252,1768,1086,1688,1646,1373,1147,1059,1150,1956,2022,1087,1190,1038,1157,1159,1502,1623,1650,1583,1708,1312,1751,1685,1648,1917,1658;
set .a, 1; // [ 1 - Enable global announcement on MvP kill ] [ 0 - Disable global announcement ]
set $@top, 10; // Number of top rankings that will be shown.
end;

OnNPCKillEvent:
if (getgmlevel() > 10) end;

for (set .@c, 0; .@c < getarraysize(.mobid); set .@c, .@c + 1) { if (killedrid == .mobid[.@c]) set .@s, 1; } // Check MvP
if (!.@s) end;
if (.a) announce "The user [" +strcharinfo(0) +"] has killed [" +getmonsterinfo(killedrid,0) +"] in map [" +strcharinfo(3) +"]",bc_blue|bc_all;

query_sql "SELECT char_id FROM mvp_ranking WHERE char_id = "+getcharid(0),@char_id;

if (@char_id == getcharid(0)) {
	query_sql "SELECT mvp_count FROM mvp_ranking WHERE char_id = "+getcharid(0),@mvptotal;
	set @mvptotal, @mvptotal +1;
	query_sql "UPDATE mvp_ranking SET mvp_count = '"+@mvptotal+"' WHERE char_id = "+getcharid(0);
	} else {
	set @mvptotal, 1;
	query_sql "INSERT INTO mvp_ranking (id,char_id,mvp_count) VALUES ('','"+getcharid(0)+"','"+@mvptotal+"')";
	}
	end;
}

prontera,150,150,3	script	MvP Rank	411,{

set .@menu$, "- Check TOP 10 MVP ranking:- Check my stats";
if (getgmlevel() >= 80) { set .@menu$, .@menu$ + ":- ^FF0000Reset All Rankings^000000"; }

mes "[Top " +$@top +" MvP Rank]";
mes "Please select an option.";
next;
switch(select(.@menu$)) {
case 1:
	query_sql "SELECT mvp_count FROM mvp_ranking ORDER BY mvp_count ASC LIMIT "+$@top,@count[0];
	query_sql "SELECT char_id FROM mvp_ranking ORDER BY mvp_count ASC LIMIT "+$@top,@char_id[0];
	query_sql "SELECT `name` from `char` WHERE `char_id` = '"+@char_id[.@c]+"'",.@names$[0];

	mes "[Top " +$@top +" MvP Rank]";
	for (set .@c, 0; .@c < $@top; set .@c, .@c + 1){
		mes "";
		mes "Top ^FF0000" +(.@c + 1)+"^000000 ^0000FF"+.@names$[.@c]+"^000000 with ^FF0000"+@count[.@c]+"^000000 MVP killed.";
	}
	close;
case 2:
	query_sql "SELECT `mvp_count` FROM `mvp_ranking` WHERE `char_id` = "+getcharid(0),@amount;
	if (@amount) {
		mes "[Top " +$@top +" MvP Rank]";
		mes "You have killed ^FF0000"+@amount+"^000000 MVP"+( ( .@amount == 1)? "." : "s." );
	}
	close;
case 3:
	mes "[Top " +$@top +" MvP Rank]";
	mes "This will delete all existing rankings.";
	mes "Do you want to proceed?";
	next;
	if (select("No:Yes") == 1) end;
	query_sql "DELETE FROM `mvp_ranking`";
	mes "[Top " +$@top +" MvP Rank]";
	mes "All rankings have been reset.";
	close;
	}
	end;
}

Have tested it and works fine /no1 , if you find any error let me know.

 

PD: If there is any spelling mistake I apologize, I don't speak English. 

Now i'm having problem with this sql script when i restart my server all the mvp logs are gone. and in the top 10 list only it doesn't show the right ladder.

if someone can add this script like check my stats and resest mvp ladder this is much better for me.

prontera,139,159,6	script	MvP Rank	411,{
query_sql( "SELECT `name`,`Count` FROM `E-MVPRank` ORDER BY `Count` DESC LIMIT 10",.@Name$,.@Count );
if( getarraysize( .@Name$ ) ){
	for( set .@i,0; .@i < getarraysize( .@Name$ ); set .@i,.@i + 1 )
		mes "[ "+( .@i + 1 )+". ] "+.@Name$[.@i]+" - "+.@Count[.@i]+" ^ff0000Killed^000000 MVP.";
}else{
	mes "No Record Found.";
}
OnInit:
	delwaitingroom;
	waitingroom "Top 10 MVP Rank",0;
end;
close;

OnNPCKillEvent:
if( getmonsterinfo( killedrid,MOB_MVPEXP ) )
	query_sql( "INSERT INTO `E-MVPRank` SET `char_id`='"+getcharid(0)+"',`name`='"+strcharinfo(0)+"',`Count`='1' ON DUPLICATE KEY UPDATE `Count`=`Count`+1" );
end;
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  59
  • Reputation:   19
  • Joined:  01/03/13
  • Last Seen:  

I highly recommend you to use SQL instead of txt, because those data are saved in variables and it's much more harder to track and debug the script than you can imagine  /whisp .

 

Here is an expample you can use for what you are looking for in SQL:

 

STEP 1: LOAD THE TABLE IN YOUR SQL BEFORE USE THE SCRIPT

 

Run this query on your sql database:

SET FOREIGN_KEY_CHECKS=0;

-- ------------------------------------
--  Table structure for `mvp_ranking`
-- ------------------------------------
DROP TABLE IF EXISTS `mvp_ranking`;
CREATE TABLE `mvp_ranking` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `char_id` int(11) unsigned NOT NULL DEFAULT '0',
  `mvp_count` smallint(6) unsigned NOT NULL DEFAULT '1',
  PRIMARY KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-- ------------------------------------
--  End of table `mvp_ranking`.
-- ------------------------------------

STEP 2: LOAD THE SCRIPT IN YOUR SERVER

 

Create and load the next script:

-	script	Rank MvP	-1,{

OnInit:

setarray .mobid[0],1511,1647,1785,1630,1399,1039,1874,2068,1272,1719,1046,1389,1112,1115,1957,1418,1871,1252,1768,1086,1688,1646,1373,1147,1059,1150,1956,2022,1087,1190,1038,1157,1159,1502,1623,1650,1583,1708,1312,1751,1685,1648,1917,1658;
set .a, 1; // [ 1 - Enable global announcement on MvP kill ] [ 0 - Disable global announcement ]
set $@top, 10; // Number of top rankings that will be shown.
end;

OnNPCKillEvent:
if (getgmlevel() > 10) end;

for (set .@c, 0; .@c < getarraysize(.mobid); set .@c, .@c + 1) { if (killedrid == .mobid[.@c]) set .@s, 1; } // Check MvP
if (!.@s) end;
if (.a) announce "The user [" +strcharinfo(0) +"] has killed [" +getmonsterinfo(killedrid,0) +"] in map [" +strcharinfo(3) +"]",bc_blue|bc_all;

query_sql "SELECT char_id FROM mvp_ranking WHERE char_id = "+getcharid(0),@char_id;

if (@char_id == getcharid(0)) {
	query_sql "SELECT mvp_count FROM mvp_ranking WHERE char_id = "+getcharid(0),@mvptotal;
	set @mvptotal, @mvptotal +1;
	query_sql "UPDATE mvp_ranking SET mvp_count = '"+@mvptotal+"' WHERE char_id = "+getcharid(0);
	} else {
	set @mvptotal, 1;
	query_sql "INSERT INTO mvp_ranking (id,char_id,mvp_count) VALUES ('','"+getcharid(0)+"','"+@mvptotal+"')";
	}
	end;
}

prontera,150,150,3	script	MvP Rank	411,{

set .@menu$, "- Check TOP 10 MVP ranking:- Check my stats";
if (getgmlevel() >= 80) { set .@menu$, .@menu$ + ":- ^FF0000Reset All Rankings^000000"; }

mes "[Top " +$@top +" MvP Rank]";
mes "Please select an option.";
next;
switch(select(.@menu$)) {
case 1:
	query_sql "SELECT mvp_count FROM mvp_ranking ORDER BY mvp_count ASC LIMIT "+$@top,@count[0];
	query_sql "SELECT char_id FROM mvp_ranking ORDER BY mvp_count ASC LIMIT "+$@top,@char_id[0];
	query_sql "SELECT `name` from `char` WHERE `char_id` = '"+@char_id[.@c]+"'",.@names$[0];

	mes "[Top " +$@top +" MvP Rank]";
	for (set .@c, 0; .@c < $@top; set .@c, .@c + 1){
		mes "";
		mes "Top ^FF0000" +(.@c + 1)+"^000000 ^0000FF"+.@names$[.@c]+"^000000 with ^FF0000"+@count[.@c]+"^000000 MVP killed.";
	}
	close;
case 2:
	query_sql "SELECT `mvp_count` FROM `mvp_ranking` WHERE `char_id` = "+getcharid(0),@amount;
	if (@amount) {
		mes "[Top " +$@top +" MvP Rank]";
		mes "You have killed ^FF0000"+@amount+"^000000 MVP"+( ( .@amount == 1)? "." : "s." );
	}
	close;
case 3:
	mes "[Top " +$@top +" MvP Rank]";
	mes "This will delete all existing rankings.";
	mes "Do you want to proceed?";
	next;
	if (select("No:Yes") == 1) end;
	query_sql "DELETE FROM `mvp_ranking`";
	mes "[Top " +$@top +" MvP Rank]";
	mes "All rankings have been reset.";
	close;
	}
	end;
}

Have tested it and works fine /no1 , if you find any error let me know.

 

PD: If there is any spelling mistake I apologize, I don't speak English. 

Edited by Nanashi
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  92
  • Reputation:   2
  • Joined:  01/04/15
  • Last Seen:  

I tried the script and it works perfect smooth. this what i'm looking for, well i saw this script somewhere but without the SQL.

BTW Thank you so much~

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...