Jump to content
  • 0
Sign in to follow this  
driver

Add player guild to the ranking

Question

 

Masters, I want to add the player's guild after the player's name in the ranking.

I have two classifications in different scripts. But both show only Position | Player | Points

I would like this. example: Position| Player | Guild | Points

I have no idea what code should be added to 'query_sql' or how to set it in the script.

Please, if anyone can help me with this I would be very grateful.

Ranking Empbreaker:
 

		mes "Top 10 Emperium Breaker";
		if(!(.@nb = query_sql("SELECT `char_id`, `count` FROM `breaker_ladder` ORDER BY `count` DESC LIMIT 10", .@cid, .@count))) {
			mes "No data found.";
			close;
		}
		for ( .@i = 0; .@i < .@nb; .@i++ ) {
			query_sql("SELECT `name` FROM `char` WHERE `char_id` = '"+.@cid[.@i]+"'",.@name$);
			mes (.@i+1) +". "+ .@name$ +" ~ "+ .@count[.@i] +" breaks.";
		}
		close;

and

Ranking WoT:

			mes "Position | Player | Points";
			query_sql "SELECT `name`, `baus` FROM `char` WHERE '"+getcharid(0)+"' AND `baus` > '0' ORDER BY `baus` DESC LIMIT 10",.@nome$,.@baus;
	
			for (set .@i,0; .@i < getarraysize(.@nome$); set .@i, .@i + 1)
				mes (.@i+1)+"º^000000 | ^228B22"+.@nome$[.@i]+"^000000 | ^00B2EE"+.@baus[.@i]+"^000000";
			break;
	}
	close;

Thank you very much.

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I don't understand why you need the complete code when there's the query for it already.

Emperium Breaker:

		mes "Top 10 Emperium Breaker";
		if(!([email protected] = query_sql("SELECT B.`name`,B.`guild_id`,A.`count` FROM `breaker_ladder` AS A LEFT JOIN `char` AS B ON A.`char_id` = B.`char_id` ORDER BY `count` DESC LIMIT 10", [email protected]$,[email protected],[email protected]))) {
			mes "No data found.";
			close;
		}
		for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
			mes ([email protected]+1) +". "+ [email protected]$[[email protected]] +" ~ "+(getguildname([email protected][[email protected]]) == "null" ? "None":getguildname([email protected][[email protected]]))+" ~ "+ [email protected][[email protected]] +" breaks.";
		}

for the WoT Ranking. i'll leave this to you so you can learn how to left join.

EDIT: FYI you actually don't need to create a breaker_ladder sql.. just use a character variable such as "set EmpBreak,EmBreak+1;" then simply join the char_reg_num with char table. although it has certain delay

Edited by Haruka Mayumi
  • Like 1

Share this post


Link to post
Share on other sites
  • 0

You can get after break the emperium post the complete code then we will check.

Position | Player | Points | Guild

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, Cookie-rae said:

You can get after break the emperium post the complete code then we will check.

Position | Player | Points | Guild

Sorry, I didn't quite understand what you meant ... I don't think I posted the full code, right?

In the ranking, I would like to add the guild to which the player belongs.

Code:

Spoiler
	// Code to break the emperium in 'agit_main.txt'
	query_sql("INSERT INTO `breaker_ladder` SET `char_id` = '"+getcharid(0)+"', `count` = '1' ON DUPLICATE KEY UPDATE `count` = `count`+1");
	#EMPBREAKERPTS += [email protected];


 

	OnInit:
	// how much points gained per emp break
	[email protected] = 1; 

	query_sql("CREATE TABLE IF NOT EXISTS `breaker_ladder` (`char_id` int(11) unsigned NOT NULL, `count` int(11) NOT NULL DEFAULT '0', PRIMARY KEY ( `char_id` )) ENGINE=InnoDB");
}


 

		// Ranking code
		mes "Top 10 Emperium Breaker";
		if(!(.@nb = query_sql("SELECT `char_id`, `count` FROM `breaker_ladder` ORDER BY `count` DESC LIMIT 10", .@cid, .@count))) {
			mes "No data found.";
			close;
		}
		for ( .@i = 0; .@i < .@nb; .@i++ ) {
			query_sql("SELECT `name` FROM `char` WHERE `char_id` = '"+.@cid[.@i]+"'",.@name$);
			mes (.@i+1) +". "+ .@name$ +" ~ "+ .@count[.@i] +" breaks.";
		}
		close;


Full script:

Spoiler

//===== rAthena Script =======================================
//= Emperium Breaker Ladder + Points + Shop
//===== By: ==================================================
//= Mabuhay
//===== Description: ========================================= 
// title says it all
// ============================================================
/*
// For WoE First Edition
// open npc/guild/agit_main.txt

---------------------------------------------
Look for this part: 
---------------------------------------------
// The Emperium has been broken.
OnAgitBreak:
	set [email protected],getcharid(2);
	// Show and log error if an unguilded player breaks the Emperium. (Should NEVER happen)
	if ([email protected] <= 0) {
		set [email protected]$,"Character "+strcharinfo(0)+" ("+getcharid(0)+") broke the Emperium in Castle: "+strnpcinfo(2)+" while guildless. No data will be saved and Emperium respawned.";
 		logmes [email protected]$; debugmes [email protected]$;
		donpcevent "Agit#"+strnpcinfo(2)+"::OnStartArena";
		end;
	}

---------------------------------------------
 Add these below..
 ---------------------------------------------
	query_sql("INSERT INTO `breaker_ladder` SET `char_id` = '"+getcharid(0)+"', `count` = '1' ON DUPLICATE KEY UPDATE `count` = `count`+1");
	#EMPBREAKERPTS += [email protected];

*/
// ============================================================

prontera,158,176,6	script	Emp Breaker Ladder	4_BOARD3,{
	query_sql("SELECT `count` FROM `breaker_ladder` WHERE `char_id` = "+ getcharid(0), .@count);
	mes "You currently have ^ff0000"+.@count+"^000000 emp breaks.";
	mes "And "+#EMPBREAKERPTS+" Emp Break Points.";
	mes " ";
	mes "What would you like to do?";
	next;
	switch(select("~ View Top 10 Emp Breakers","~ Open Emp Breaker Point Shop",(getgmlevel()> 60) ? "~ [GM MENU] Reset data":"")) {
	case 1:
		mes "Top 10 Emperium Breaker";
		if(!(.@nb = query_sql("SELECT `char_id`, `count` FROM `breaker_ladder` ORDER BY `count` DESC LIMIT 10", .@cid, .@count))) {
			mes "No data found.";
			close;
		}
		for ( .@i = 0; .@i < .@nb; .@i++ ) {
			query_sql("SELECT `name` FROM `char` WHERE `char_id` = '"+.@cid[.@i]+"'",.@name$);
			mes (.@i+1) +". "+ .@name$ +" ~ "+ .@count[.@i] +" breaks.";
		}
		close;

	case 2:
		callshop "EmpBreakerShop", 4;
		mes "You currenlty have ^ff0000"+((#EMPBREAKERPTS) ? #EMPBREAKERPTS:"no" )+" Emp Breaker Points^000000 to purchase from this shop.";
		end;
	
	case 3:
		mes "Are you sure you want to delete all Emp Breaker Ladder data?";
		next;
		select("Yes");
		message strcharinfo(0), "Deleting...";
		progressbar "", 5;
		query_sql("TRUNCATE TABLE `breaker_ladder`");
		mes "Deleting complete..";
		close;
	}
	end;

OnInit:
	// how much points gained per emp break?
	[email protected] = 1; 

	query_sql("CREATE TABLE IF NOT EXISTS `breaker_ladder` (`char_id` int(11) unsigned NOT NULL, `count` int(11) NOT NULL DEFAULT '0', PRIMARY KEY ( `char_id` )) ENGINE=InnoDB");
}

// Emp Breaker Point Shop Data
// Edit the points here.. "#EMPBREAKERPTS" currently set to '#EMPBREAKERPTS'
// Also edit the items for sale here...
-	pointshop	EmpBreakerShop	FAKE_NPC,#EMPBREAKERPTS,901:2,903:1,904:5

 

 

 

Share this post


Link to post
Share on other sites
  • 0

#edit.

@Haruka Mayumi
Before closing the topic. Just one more question, please.
Using your model, I did the WOT Player Ranking, but I have a question about that.
My idea is when the player breaks the chest he will get +1 breakpoint in the player ranking And his guild will also get +1 point in the guild ranking.
The +1 breakpoint in the Player Ranking is ok.

My question is, how can I use the sql table 'count' both to add points for players and to add points for the guild? And what changes should I make in the ranking? Please.
 

		case 1:
			next;
			mes @npcR$; // Players Ranking WOT
		if(!(.@nb = query_sql("SELECT B.`name`,B.`guild_id`,A.`count` FROM `wot_ladder` AS A LEFT JOIN `char` AS B ON A.`char_id` = B.`char_id` ORDER BY `count` DESC LIMIT 10", .@name$,.@gid,.@count))) {
			mes "No data found.";
			close;
		}
		for ( .@i = 0; .@i < .@nb; .@i++ ) {
			mes (.@i+1) +". "+ .@name$[.@i] +" ~ "+(getguildname(.@gid[.@i]) == "null" ? "None":getguildname(.@gid[.@i]))+" ~ "+ .@count[.@i] +" breaks.";
		}
		close;

		case 2:
			next;
			mes @npcR$;	// Guild Ranking WOT
			query_sql "SELECT `guild_id`, `count` FROM `wot_ladder` WHERE '"+getcharid(2)+"' AND `count` > '0' ORDER BY `count` DESC LIMIT 10",.@nom$,.@bau;

			for (set .@i,0; .@i < getarraysize(.@nom$); set .@i, .@i + 1)
				mes (.@i+1)+"º^000000 - ^228B22"+.@nom$[.@i]+"^000000 - ^00B2EE"+.@bau[.@i]+"^000000";
			break;
	}

And, how to add + 1 Point Ranking Guild

	announce "[War of Treasure]: The ["+strcharinfo(0)+"] from the ["+getguildname(.@guild_id)+"] guild destroyed a chest!",8;
	// Breaker Point only for those who destroyed the chest. (Ranking Player)
	query_sql("INSERT INTO `wot_ladder` SET `char_id` = '"+getcharid(0)+"', `count` = '1' ON DUPLICATE KEY UPDATE `count` = `count`+1");

Please.
Thank you very much. And I'm sorry. It is very complicated for me.

Edited by driver

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

Sign in to follow this  

×
×
  • Create New...

Important Information

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