Jump to content
  • 0
chojuro

MVP ranking Statue

Question

Question: Why NPC's does'nt transform to the top MVP Player?

Note: im using old hercules emulator

//====== rAthena Script ======================================================
//= MVP ladder script
//===== By: ==================================================================
//= Rokimoki but edited and adapted from AnnieRuru PVP Ladder
//= https://herc.ws/board/topic/18871-dota-pvp-ladder/
//= Mark Script fixed and adapted some small things
//===== Current Version: =====================================================
//= 2.1
//===== Compatible With: =====================================================
//= rAthena 2020-10-20, with MySQL 8.0
//===== Description: =========================================================
//= MVP ladder store in SQL table
//= Requested by DevThor
//===== Additional Comments: =================================================
//= 1.0 initial version
//= 2.0 added total kill count and fixed some sql bugs
//= 2.1 fixed sql sorting rank
//============================================================================

/*
CREATE TABLE `mvpladder` (
	`id` int(11) NOT NULL AUTO_INCREMENT,
	`char_id` int(11) unsigned NOT NULL default '0',
	`mob_id` INT NOT NULL,
	`kills` INT DEFAULT 0,
  	PRIMARY KEY (`id`),
	INDEX (`char_id`),
	INDEX (`mob_id`),
	INDEX (`kills`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
*/

//---- MvP Ladder Logic Script

-	script	MVPLadder	-1,{

OnInit:
// Config
	.map_killannounce = 1; // announce when MVP is dead on the map where the MVP was killed : 0 - off, 1 - o
	.killannounce = 1; // announce when MVP is dead globally : 0 - off, 1 - on
	.gmnokill = 0; // GMs are not suppose to kill MVP. A GM with <this number> level or higher will do nothing. IF set to 60, GM60 and above kill any player will not get anything : 0 - off

//	.min_gm_menu = 90; // minimum level of GM can use the GM menu on ladder npc

	.showtotal = 20; // show the length of ladder.
	.showpage = 10;	// set the views per page.

	.showstatue = 5; // number of statues. This number must match with the number of duplicates at the end of the script
	.fix_custom_sprite = false; // if your server has custom animated sprite that overlaps the sprite animation repeatedly on the statues, enable this

// Config ends ------------------------------------------------------------------------------------------

//	to prevent bug happen
	if (.gmnokill <= 0) .gmnokill = 100;

	sleep 1;
	
OnTimer1000: // refresh statues every 30 seconds. Note the `char` table is unrealiable, player still need to perform certain task to save the character -> see 'save_settings' in conf\map-server.conf
	[email protected]$ = "SELECT `char`.`char_id`, `char`.`name`, `char`.`guild_id`, `char`.`class`, "
			 + "`char`.`sex`, `char`.`hair`, `char`.`hair_color`, `char`.`clothes_color`, "
			 + "`char`.`body`, `char`.`head_top`, `char`.`head_mid`, `char`.`head_bottom`, `char`.`robe`, "
	         + "SUM(`mvpladder`.`kills`) as `orderKills` "
	         + "FROM `char` RIGHT JOIN `mvpladder` ON `char`.`char_id` = `mvpladder`.`char_id` GROUP BY `char`.`char_id` ORDER BY `orderKills` DESC LIMIT " + .showstatue;
	[email protected] = query_sql([email protected]$, [email protected], [email protected]$, [email protected]_id, [email protected], [email protected]$, [email protected], [email protected]_color, [email protected]_color, [email protected], [email protected]_top, [email protected]_mid, [email protected]_bottom, [email protected], [email protected]);
	if (.fix_custom_sprite) {
		for ([email protected] = 0; [email protected] < [email protected]; [email protected]) {
			setunitdata .statue[[email protected] +1], UDT_HEADTOP, 0;
			setunitdata .statue[[email protected] +1], UDT_HEADMIDDLE, 0;
			setunitdata .statue[[email protected] +1], UDT_HEADBOTTOM, 0;
			setunitdata .statue[[email protected] +1], UDT_ROBE, 0;
		}
	}
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]) {
		setunitdata .statue[[email protected] +1], UDT_CLASS, [email protected][[email protected]];
		setunitdata .statue[[email protected] +1], UDT_SEX, ([email protected]$[[email protected]] == "F")? SEX_FEMALE:SEX_MALE;
		setunitdata .statue[[email protected] +1], UDT_HAIRSTYLE, [email protected][[email protected]];
		setunitdata .statue[[email protected] +1], UDT_HAIRCOLOR, [email protected]_color[[email protected]];
		setunitdata .statue[[email protected] +1], UDT_CLOTHCOLOR, [email protected]_color[[email protected]];
		setunitdata .statue[[email protected] +1], UDT_BODY2, [email protected][[email protected]];
		setunitdata .statue[[email protected] +1], UDT_HEADTOP, [email protected]_top[[email protected]];
		setunitdata .statue[[email protected] +1], UDT_HEADMIDDLE, [email protected]_mid[[email protected]];
		setunitdata .statue[[email protected] +1], UDT_HEADBOTTOM, [email protected]_bottom[[email protected]];
		setunitdata .statue[[email protected] +1], UDT_ROBE, [email protected][[email protected]];
		setnpcdisplay "mvp_ladder_statue#"+([email protected] +1), [email protected]$[[email protected]];
		.statue_name$[[email protected] +1] = [email protected]$[[email protected]];
		.statue_guild$[[email protected] +1] = getguildname([email protected]_id[[email protected]]);
		.statue_kills[[email protected] +1] = [email protected][[email protected]];
	}
	for ([email protected] = [email protected]; [email protected] < .showstatue; [email protected])
		setunitdata .statue[[email protected] +1], UDT_CLASS, HIDDEN_WARP_NPC;
	initnpctimer;
	end;

OnNPCKillEvent: // Logic to detect when a MvP is killed
	if (getmonsterinfo(killedrid, MOB_MVPEXP) > 0) {
		[email protected]$ = "SELECT char_id, mob_id, kills FROM mvpladder WHERE char_id = '" + getcharid(0) + "' AND mob_id = '" + killedrid + "';";
		if (query_sql([email protected]$) > 0) { // Exist a kill of that MVP so +1 to kill count
			[email protected]$ = "UPDATE mvpladder SET kills = kills + 1 WHERE char_id = '" + getcharid(0) + "' AND mob_id = '" + killedrid + "'";
		} else { // Create a new kill of specific MVP
			//[email protected]$ = "INSERT INTO mvpladder (char_id, mob_id, kills) VALUES ('" + getcharid(0) + "','" + killedrid + "','1');";
			[email protected]$ = "INSERT INTO mvpladder (`char_id` , `mob_id` , `kills`) VALUES ('" + getcharid(0) + "','" + killedrid + "','1');";
		}
		query_sql([email protected]$);
	}
	end;
}

//---- MvP Ladder Info NPC

[email protected],48,89,5	script	MVP Ladder	120,{
	[email protected]$ = strnpcinfo(0);
	while (1) {
		mes "["+ [email protected]$ +"]";
		mes "Hello "+ strcharinfo(0) +"...";
		mes "If you want to I can show you your MVP stats.";
		next;
		switch (select("Most MVP killer list","Most MVP killed list","Own Information")) {
		mes "["+ [email protected]$ +"]";
		case 1:
			[email protected]$ = "SELECT t1.char_id, SUM(t1.kills) as `orderKills`, t2.name " +
								 "FROM `mvpladder` t1 " +
								 "INNER JOIN `char` t2 " +
								 "ON t1.char_id = t2.char_id " +
								 "GROUP BY t1.char_id " +
								 "ORDER BY `orderKills` DESC " +
								 "LIMIT " + getvariableofnpc(.showtotal, "MVPLadder") + ";";
			[email protected] = query_sql([email protected]$, [email protected], [email protected], [email protected]$);
			if ([email protected]) {
				mes "The ladder currently is empty.";
				next;
			}
			for ([email protected] = 0; [email protected] < [email protected]; [email protected] += getvariableofnpc(.showpage,"MVPLadder")) {
				for ([email protected] = [email protected]; [email protected] < (getvariableofnpc(.showpage,"MVPLadder") + [email protected]) && [email protected] < [email protected]; [email protected])
					mes "^996600" + ([email protected]+1) + ": ^006699" + [email protected]$[[email protected]] + " ^00AA00[^FF0000" + [email protected][[email protected]] + " MvP^00AA00 killed]^000000";
				next;
			}
			break;
			
		case 2:
			[email protected]$ = "SELECT char_id, mob_id, SUM(kills) as `orderKills` " +
								 "FROM `mvpladder` " +
								 "GROUP BY mob_id " +
								 "ORDER BY `orderKills` DESC " +
								 "LIMIT " + getvariableofnpc(.showtotal, "MVPLadder") + ";";
			[email protected] = query_sql([email protected]$, [email protected], [email protected], [email protected]);
			if ([email protected]) {
				mes "The ladder currently is empty.";
				next;
			}
			for ([email protected] = 0; [email protected] < [email protected]; [email protected] += getvariableofnpc(.showpage,"MVPLadder")) {
				for ([email protected] = [email protected]; [email protected] < (getvariableofnpc(.showpage,"MVPLadder") + [email protected]) && [email protected] < [email protected]; [email protected]) {
					mes "^996600" + ([email protected]+1) + ": ^006699" + strmobinfo(1, [email protected][[email protected]]) + " ^FF0000MvP ^00AA00[Killed ^FF0000" + [email protected][[email protected]] + " ^00AA00times]^000000";
				}
				next;
			}
			query_sql("SELECT SUM(kills) FROM mvpladder;", [email protected]);
			mes "^996600==> ^006699Total MvP Kills [^FF0000" + [email protected][0] + " ^00AA00kills]^000000";
			break;
			
		case 3:
			[email protected]$ = "SELECT char_id, mob_id, SUM(kills) as `orderKills` " +
								"FROM `mvpladder` " +
								"WHERE char_id = '" + getcharid(0) + "'" +
								"ORDER BY `orderKills` DESC;";
			[email protected] = query_sql([email protected]$, [email protected], [email protected], [email protected]);
			if ([email protected]) {
				mes "The ladder currently is empty.";
				next;
			}
			[email protected] = 0;
			for ([email protected] = 0; [email protected] < [email protected]; [email protected] += getvariableofnpc(.showpage,"MVPLadder")) {
				for ([email protected] = [email protected]; [email protected] < (getvariableofnpc(.showpage,"MVPLadder") + [email protected]) && [email protected] < [email protected]; [email protected] ) {	
					mes "^996600" + ([email protected]+1) + ": ^006699" + strmobinfo(1, [email protected][[email protected]]) + " ^FF0000MvP ^00AA00[Killed ^FF0000" + [email protected][[email protected]] + " ^00AA00times]^000000";
					[email protected] = [email protected] + [email protected][[email protected]];
				}
				next;
			}
			mes "^996600==> ^006699Total Own MvP Kills [^FF0000" + [email protected] + " ^00AA00kills]^000000";
			break;
        }
	close;
OnInit:
	initnpctimer;
	end;
OnTimer1000:
	showscript("MVP Ladder");
	setnpctimer 0;
	end;
    }
close;

}

//---- MSG board NPCs

-	script	mvp_ladder_statue	-1,{
	[email protected] = getelementofarray(getvariableofnpc(.npcgid, "MVPLadder"), getnpcid(0));
	mes "^996600[TOP "+ [email protected] +"]";
	mes "^006699Name : "+ getelementofarray(getvariableofnpc(.statue_name$, "MVPLadder"), [email protected]);
	[email protected]$ = getelementofarray(getvariableofnpc(.statue_guild$, "MVPLadder"), [email protected]);
	mes "^00AAAAGuild : "+(([email protected]$ == "null")? "^AAAAAANone": [email protected]$);
	mes "^00AA00Total MVP Kills : ["+ getelementofarray(getvariableofnpc(.statue_kills, "MVPLadder"), [email protected]) +"]";
	close;

OnInit:
	[email protected] = strnpcinfo(2);
	set getvariableofnpc(.statue[[email protected]], "MVPLadder"), getnpcid(0);
	set getvariableofnpc(.npcgid[getnpcid(0)], "MVPLadder"), [email protected];
	end;
}

[email protected],55,83,5	duplicate(mvp_ladder_statue)	mvp_ladder_statue#1	1_F_MARIA
[email protected],51,83,5	duplicate(mvp_ladder_statue)	mvp_ladder_statue#2	1_F_MARIA
[email protected],54,87,5	duplicate(mvp_ladder_statue)	mvp_ladder_statue#3	1_F_MARIA
[email protected],54,91,5	duplicate(mvp_ladder_statue)	mvp_ladder_statue#4	1_F_MARIA
[email protected],47,83,5	duplicate(mvp_ladder_statue)	mvp_ladder_statue#5	1_F_MARIA

[email protected],55,83,5	script	 #top1	111,{
OnInit:
	initnpctimer;
	end;
OnTimer1000:
	showscript("Top-1 MVP Killer");
	setnpctimer 0;
	end;
}

[email protected],51,83,5	script	 #top2	111,{
OnInit:
	initnpctimer;
	end;
OnTimer1000:
	showscript("Top-2 MVP Killer");
	setnpctimer 0;
	end;
}

[email protected],54,87,5	script	 #top3	111,{
OnInit:
	initnpctimer;
	end;
OnTimer1000:
	showscript("Top-3 MVP Killer");
	setnpctimer 0;
	end;
}

[email protected],54,91,5	script	 #top4	111,{
OnInit:
	initnpctimer;
	end;
OnTimer1000:
	showscript("Top-4 MVP Killer");
	setnpctimer 0;
	end;
}

[email protected],47,83,5	script	 #top5	111,{
OnInit:
	initnpctimer;
	end;
OnTimer1000:
	showscript("Top-5 MVP Killer");
	setnpctimer 0;
	end;
}

 

Share this post


Link to post
Share on other sites

11 answers to this question

Recommended Posts

  • 0
Posted (edited)

 Update your Herc and try that script there :)

EDIT:
works fine on my side.

Edited by KeiKun

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)
1 hour ago, chojuro said:

i have this error when i change to that

 

image.png.cc3edfc04977da428d72fc1255efd2ef.png

 

[email protected] = getelementofarray(getvariableofnpc(.npcgid, "MVPLadder"),  getnpcid());

try to input it manually

Edited by MikZ

Share this post


Link to post
Share on other sites
  • 0
50 minutes ago, MikZ said:

 

[email protected] = getelementofarray(getvariableofnpc(.npcgid, "MVPLadder"), getnpcid());

.@id = getelementofarray(getvariableofnpc(.npcgid, "MVPLadder"),  getnpcid());

try to input it manually

same error bro

Share this post


Link to post
Share on other sites
  • 0

probably you using too old hercules or some bad mod of plugin?

try test your script on latest clean hercules.

 

from script file look like this is ratnena? then not sure may be getnpcid in rathena always need npc name as parameter.

something like: getnpcid("MYNPC")

Share this post


Link to post
Share on other sites
  • 0
9 hours ago, 4144 said:

probably you using too old hercules or some bad mod of plugin?

try test your script on latest clean hercules.

 

from script file look like this is ratnena? then not sure may be getnpcid in rathena always need npc name as parameter.

something like: getnpcid("MYNPC")

yes my emulator is too old, when i compiled there is a lot of warnings too but the server run smooth.

the script working fine with latest clean hercules.

this is script has two version i implement hercules version so it is probably the problem is the my emulator is too old

Share this post


Link to post
Share on other sites
  • 0

then on old hercules try call getnpcid as getnpcid("MYNPC")

or may be it not exists in your hercules. look for getnpcid in atcommand.c

 

Share this post


Link to post
Share on other sites
  • 0
5 hours ago, 4144 said:

then on old hercules try call getnpcid as getnpcid("MYNPC")

or may be it not exists in your hercules. look for getnpcid in atcommand.c

 

[email protected] = getelementofarray(getvariableofnpc(.npcgid, "MVPLadder"), getnpcid(mvp_ladder_statue));

do you mean like this?
 

there's no getnpcid in atcommand.c but there is buildin in script.c

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)
13 hours ago, 4144 said:

[email protected] = getelementofarray(getvariableofnpc(.npcgid, "MVPLadder"), getnpcid("MVPLadder"));

[email protected] = getelementofarray(getvariableofnpc(.npcgid, "MVPLadder"), getnpcid("MVPLadder"));

like this

i got this error,debug and warning in console and nothing happen to the npc it doesnt disguise

image.png.6997ca1b1149f4f1298d1036b9f1e25d.pngimage.png.1ee68e8e86bb57c669d9fd34a7345e2a.pngimage.png.a79b363d0b911e53c2969769a7bdfe9b.png

Edited by chojuro

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

×
×
  • Create New...

Important Information

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