Jump to content

Question

Posted
// LOJA DE MVP POINTS
-	pointshop	Shop_MVPPOINTS	-1,#MVPPOINTS,501:10,502:10,503:10,504:10,505:10,506:10

//---- MvP Ladder Logic Script

-	script	mvpladder	-1,{

OnInit:
// Configurações
	.map_killannounce = 0; // anunciar quando o MVP é morto no mapa onde o MVP foi morto: 0 - desativado, 1 - ativado
	.killannounce = 1; // anunciar quando o MVP é morto globalmente: 0 - desativado, 1 - ativado
	.gmnokill = 0; // GMs não devem matar MVPs. Um GM com nível <este número> ou superior não fará nada. Se definido como 60, GMs de nível 60 ou superior não receberão nada ao matar jogadores: 0 - desativado

	.min_gm_menu = 90; // nível mínimo do GM que pode usar o menu do GM no NPC da escada

	.showtotal = 10; // mostrar o comprimento da escada.
	.showpage = 10;	// definir as visualizações por página.

	.showstatue = 3; // número de estátuas. Este número deve corresponder ao número de duplicatas no final do script.
	.fix_custom_sprite = true; // se o seu servidor tem sprites animados personalizados que se sobrepõem à animação da estátua repetidamente, ative isso
// Config ends ------------------------------------------------------------------------------------------

////	to prevent bug happen
//	if (.gmnokill <= 0) .gmnokill = 100;
//
//	sleep 1;
	
OnTimer10000: // refresh statues every 1 minute. 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
	.@query$ = "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;
	.@nb = query_sql(.@query$, .@cid, .@name$, .@guild_id, .@class, .@sex$, .@hair, .@hair_color, .@clothes_color, .@body, .@head_top, .@head_mid, .@head_bottom, .@robe, .@kills);
	if (.fix_custom_sprite) {
		for (.@i = 0; .@i < .@nb; ++.@i) {
			setunitdata .statue[.@i +1], UNPC_HEADTOP, 0;
			setunitdata .statue[.@i +1], UNPC_HEADMIDDLE, 0;
			setunitdata .statue[.@i +1], UNPC_HEADBOTTOM, 0;
			setunitdata .statue[.@i +1], UNPC_ROBE, 0;
		}
	}
	for (.@i = 0; .@i < .@nb; ++.@i) {
		setunitdata .statue[.@i +1], UNPC_CLASS, .@class[.@i];
		setunitdata .statue[.@i +1], UNPC_SEX, (.@sex$[.@i] == "F")? SEX_FEMALE:SEX_MALE;
		setunitdata .statue[.@i +1], UNPC_HAIRSTYLE, .@hair[.@i];
		setunitdata .statue[.@i +1], UNPC_HAIRCOLOR, .@hair_color[.@i];
		setunitdata .statue[.@i +1], UNPC_CLOTHCOLOR, .@clothes_color[.@i];
		setunitdata .statue[.@i +1], UNPC_BODY2, .@body[.@i];
		setunitdata .statue[.@i +1], UNPC_HEADTOP, .@head_top[.@i];
		setunitdata .statue[.@i +1], UNPC_HEADMIDDLE, .@head_mid[.@i];
		setunitdata .statue[.@i +1], UNPC_HEADBOTTOM, .@head_bottom[.@i];
		setunitdata .statue[.@i +1], UNPC_ROBE, .@robe[.@i];
		setnpcdisplay "mvp_ladder_statue#"+(.@i +1), .@name$[.@i];
		.statue_name$[.@i +1] = .@name$[.@i];
		.statue_guild$[.@i +1] = getguildname(.@guild_id[.@i]);
		.statue_kills[.@i +1] = .@kills[.@i];
	}
	for (.@i = .@nb; .@i < .showstatue; ++.@i)
		setunitdata .statue[.@i +1], UNPC_CLASS, HIDDEN_WARP_NPC;
	initnpctimer;
	end;

OnNPCKillEvent: // Logic to detect when a MvP is killed
	if(getgmlevel() < 3) {
		if (getmonsterinfo(killedrid, MOB_MVPEXP) > 0) {
			announce "[ Ranking MVP ] : O jogador ["+ strcharinfo(0) +"] do grupo ["+ strcharinfo(1) +"] acaba de matar o MVP "+ getmonsterinfo( killedrid, MOB_NAME ) +" em "+ strcharinfo(3), bc_all;
			.@selectIfKillExistQuery$ = "SELECT char_id, mob_id, kills FROM mvpladder WHERE char_id = '" + getcharid(0) + "' AND mob_id = '" + killedrid + "';";
			if (query_sql(.@selectIfKillExistQuery$) > 0) { // Exist a kill of that MVP so +1 to kill count
				.@updateLadderQuery$ = "UPDATE mvpladder SET kills = kills + 1 WHERE char_id = '" + getcharid(0) + "' AND mob_id = '" + killedrid + "'";
			} else { // Create a new kill of specific MVP
				//.@updateLadderQuery$ = "INSERT INTO mvpladder (char_id, mob_id, kills) VALUES ('" + getcharid(0) + "','" + killedrid + "','1');";
				.@updateLadderQuery$ = "INSERT INTO mvpladder (`char_id` , `mob_id` , `kills`) VALUES ('" + getcharid(0) + "','" + killedrid + "','1');";
			}
			query_sql(.@updateLadderQuery$);
		}			
	}
	
end;
}

//Pontos MVP

-	script	mvppoint01	-1,{
OnNPCKillEvent:
	setarray .@monsterID[0],1038,1039,1046,1059,1086,1087,1112,1115,1147,1150,1157,1159,1190,1251,1252,1272,1312,1373,1389,1418,1492,1511,1583,1623,1630,1658,1685,1688,1719,1785,1885,2068,1957; // ID Dos Boss	
	for(set @a,0; @a <= getarraysize(.@monsterID); set @a,@a+1)
	if(killedrid == .@monsterID[@a]){
		set #MVPPOINTS,#MVPPOINTS+1;
		message strcharinfo(0),"[RagnaUp]: Você possui "+#MVPPOINTS+" ponto(s) de MvPs.";
		if (rand(1000) < 10){
			getitem 45000,1;
			announce "O jogador "+strcharinfo(0)+" acaba de dropar Cash Eletrônico do MVP "+ getmonsterinfo( .@monsterID[@a], MOB_NAME ) +"!",0;
		}
	}
}

-	script	mvppoint03	-1,{
OnNPCKillEvent:
	setarray .@monsterID[0],1708,1734,1751,1768,1779,1832,1871,1917; // ID Dos Boss
	for(set @a,0; @a <= getarraysize(.@monsterID); set @a,@a+1)
	if(killedrid == .@monsterID[@a]){
		set #MVPPOINTS,#MVPPOINTS+15;
		message strcharinfo(0),"[RagnaUp]: Você possui "+#MVPPOINTS+" ponto(s) de MvPs.";
		if (rand(1000) < 50){
			getitem 45000,1;
			announce "O jogador "+strcharinfo(0)+" acaba de dropar Cash Eletrônico do MVP "+ getmonsterinfo( .@monsterID[@a], MOB_NAME ) +"!",0;
		}
	}
	
}

-	script	mvppoint05	-1,{
OnNPCKillEvent:
	setarray .@monsterID[0],1646,1647,1648,1649,1650,1651,1874,1929,1956,2022; // ID Dos Boss
	for(set @a,0; @a <= getarraysize(.@monsterID); set @a,@a+1)
	if(killedrid == .@monsterID[@a]){
		set #MVPPOINTS,#MVPPOINTS+30;
		message strcharinfo(0),"[RagnaUp]: Você possui "+#MVPPOINTS+" ponto(s) de MvPs.";
		if (rand(1000) < 100){
			getitem 45000,1;
			announce "O jogador "+strcharinfo(0)+" acaba de dropar Cash Eletrônico do MVP "+ getmonsterinfo( .@monsterID[@a], MOB_NAME ) +"!",0;
		}
	}
}

//---- Informações do NPC Lider MVP

prontera,122,135,5	script	Caçador de MVP	733,{
	.@npcname$ = strnpcinfo(0);
	while (1) {
		mes "["+ .@npcname$ +"]";
		mes "Olá ^A020F0"+ strcharinfo(0) +"^000000...";
		mes "Você tem atualmente ^0000ff"+#MVPPOINTS+"^000000 Pontos MVP.";
		next;
		switch (select("^339966[»]^000000 Ranking MVP","^008aff[»]^000000 MVPs mais Caçados","^A020F0[»]^000000 Abrir a Loja")) {
		case 1:
		mes "^FF0000O ranking é resetado todo dia 01.^000000";
		mes "";
			.@queryKillerList$ = "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") + ";";
			.@nb = query_sql(.@queryKillerList$, .@charid, .@kills, .@name$);
			if (!.@nb) {
				mes "O Ranking está vazio no momento.";
				next;
			}
			for (.@j = 0; .@j < .@nb; .@j += getvariableofnpc(.showpage,"mvpladder")) {
				for (.@i = .@j; .@i < (getvariableofnpc(.showpage,"mvpladder") + .@j) && .@i < .@nb; ++.@i)
					mes "^996600" + (.@i+1) + ": ^006699" + .@name$[.@i] + " - ^00AA00[" + .@kills[.@i] + "]^FF0000 MVPs Mortos^000000";
				next;
			}
			break;
			
		case 2:
			.@queryKilledList$ = "SELECT char_id, mob_id, SUM(kills) as `orderKills` " +
								 "FROM `mvpladder` " +
								 "GROUP BY mob_id " +
								 "ORDER BY `orderKills` DESC " +
								 "LIMIT " + getvariableofnpc(.showtotal, "mvpladder") + ";";
			.@nb = query_sql(.@queryKilledList$, .@charid, .@mobid, .@kills);
			if (!.@nb) {
				mes "O top está vazio no momento.";
				next;
			}
			for (.@j = 0; .@j < .@nb; .@j += getvariableofnpc(.showpage,"mvpladder")) {
				for (.@i = .@j; .@i < (getvariableofnpc(.showpage,"mvpladder") + .@j) && .@i < .@nb; ++.@i) {
					mes "^996600" + (.@i+1) + ": ^006699" + getmonsterinfo(.@mobid[.@i], 1) + " ^FF0000MVP ^00AA00[Morto ^FF0000" + .@kills[.@i] + " ^00AA00Vezes]^000000";
				}
				next;
			}
			query_sql("SELECT SUM(kills) FROM mvpladder;", .@killCount);
			mes "^996600==> ^006699Total de MVPs Mortos [^00AA00" + .@killCount[0] + "^000000^006699]^FF0000";
			break;
			
		case 3:
			dispbottom "Você tem "+#MVPPOINTS+" Pontos de MVP.";
			close2;
			callshop "Shop_MVPPOINTS";
			end;
        }
OnInit:
	initnpctimer;
	setunittitle(getnpcid(0), "[ Ranking e Loja ]");
	end;
OnTimer10000:
	showscript("Líder MVP");
	setnpctimer 0;
	end;
    }
close;

}

//---- MSG board NPCs

-	script	mvp_ladder_statue	-1,{
	.@id = getelementofarray(getvariableofnpc(.npcgid, "mvpladder"), getnpcid(0));
	mes "^996600[TOP MVP "+ .@id +"]";
	mes "^006699Nome: "+ getelementofarray(getvariableofnpc(.statue_name$, "mvpladder"), .@id);
	.@guildname$ = getelementofarray(getvariableofnpc(.statue_guild$, "mvpladder"), .@id);
	mes "^00AAAAGuild: "+((.@guildname$ == "null")? "^AAAAAANone": .@guildname$);
	mes "^00AA00Matou: ["+ getelementofarray(getvariableofnpc(.statue_kills, "mvpladder"), .@id) +"]";
	close;

OnInit:
	.@id = strnpcinfo(2);
	set getvariableofnpc(.statue[.@id], "mvpladder"), getnpcid(0);
	set getvariableofnpc(.npcgid[getnpcid(0)], "mvpladder"), .@id;
	end;
}

prontera,127,138,4	duplicate(mvp_ladder_statue)	mvp_ladder_statue#1	1_F_MARIA
prontera,124,141,4	duplicate(mvp_ladder_statue)	mvp_ladder_statue#2	1_F_MARIA
prontera,130,141,4	duplicate(mvp_ladder_statue)	mvp_ladder_statue#3	1_F_MARIA
//== clone base
prontera,127,138,2	script	#2	844,{
end;

OnInit:
while(1) {
specialeffect EF_MVP;
sleep 10000;
}
}
//prontera,172,204,2	script	#npcuniquename	PORTAL,{}
//prontera,140,180,5	script	#npcuniquename1	PORTAL,{}
//prontera,138,182,2	script	#npcuniquename2	PORTAL,{}
//== msg top da cabeça
prontera,127,138,4	script	 #top1	111,{
OnInit:
	initnpctimer;
	end;
OnTimer1000:
	showscript("Top-1 MVP");
	setnpctimer 0;
	end;
}

prontera,124,141,4	script	 #top2	111,{
OnInit:
	initnpctimer;
	end;
OnTimer1000:
	showscript("Top-2 MVP");
	setnpctimer 0;
	end;
}

prontera,130,141,4	script	 #top3	111,{
OnInit:
	initnpctimer;
	end;
OnTimer1000:
	showscript("Top-3 MVP");
	setnpctimer 0;
	end;
}

-	script	reset_ranking	-1,{
	
OnClock0005:
    if(gettime(DT_DAYOFMONTH) == 1){
		query_sql ("TRUNCATE `mvpladder`");
		end;
	}

OnInit:
	bindatcmd "resetrankingmvp", strnpcinfo(0) +"::OnReset";
	end;
OnReset:
	if (getgmlevel() > 98) {
	query_sql ("TRUNCATE `mvpladder`");
	dispbottom "Ranking MVP resetado com sucesso!";
	end;
	} else {
		dispbottom "Somente Administradores podem usar este comando";
		end;
	}
	end;

}
I have a warning problem whenever a player defeats an MVP. Can someone help me with this problem? The error line is below:

[Warning]: script:query_sql: Too many columns, discarding last 3 columns.

2 answers to this question

Recommended Posts

  • 0
Posted

For me, works like you have, but maybe your SQL have something.

 

Try this.

.@query$ = "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`, `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` "
         + "ORDER BY `orderKills` DESC LIMIT " + .showstatue + ";";

 

  • 0
Posted
On 4/15/2025 at 12:46 PM, Scanty said:

For me, works like you have, but maybe your SQL have something.

 

Try this.

.@query$ = "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`, `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` "
         + "ORDER BY `orderKills` DESC LIMIT " + .showstatue + ";";

 

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;

my sql

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