Jump to content
  • 0

Emperium Breaker Ladder Error


Noire

Question


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  103
  • Reputation:   1
  • Joined:  06/26/13
  • Last Seen:  

The script function well it counts how many times you broke the emperium, but when the player a (breaker on list) logout their name disappear from the list and cause an error from the map server. the error occurs when you tried to view the top 10 emp breakers not when you destroyed the emperium on agit.

Credits to Mabuhay for his script.

3.png

2.png

1111.png

empbreaker_ladder.txt

Edited by Noire
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   25
  • Joined:  11/28/11
  • Last Seen:  

My guess is that strcharinfo() only works on logged in players. One "could" leverage the power of SQL and use the char-id to find the actual player, but that is a bit more complicated. Instead I simply added a field to the table that contains the name. Instead of just saving the players ID, I also save the name. I haven't tested this, but maybe it will give you an idea how you could solve it:

//===== 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 .@GID,getcharid(2);
	// Show and log error if an unguilded player breaks the Emperium. (Should NEVER happen)
	if (.@GID <= 0) {
		set .@notice$,"Character "+strcharinfo(0)+" ("+getcharid(0)+") broke the Emperium in Castle: "+strnpcinfo(2)+" while guildless. No data will be saved and Emperium respawned.";
 		logmes .@notice$; debugmes .@notice$;
		donpcevent "Agit#"+strnpcinfo(2)+"::OnStartArena";
		end;
	}

---------------------------------------------
 Add these below..
 ---------------------------------------------
	query_sql("INSERT INTO `breaker_ladder` SET `char_id` = '"+getcharid(0)+"', `char_name` = '"+strcharinfo(0)+"', `count` = '1' ON DUPLICATE KEY UPDATE `count` = `count`+1");
	#EMPBREAKERPTS += $@empbreakpoints;

// For WoE Second Edition
// open npc/guild2/agit_main_se.txt

---------------------------------------------
Look for this part: 
---------------------------------------------

OnStartArena:
	set .@GID,getcharid(2);
	set .@region$, (compare(strnpcinfo(4),"arug"))?"Valfreyja":"Nithafjoll";
	// Lower castle Economy
	set .@Economy,getcastledata(strnpcinfo(4),CD_CURRENT_ECONOMY)-5;
	if (.@Economy < 0) set .@Economy, 0;
	setcastledata strnpcinfo(4),CD_CURRENT_ECONOMY,.@Economy;
	// Lower Castle Defence
	set .@Defence,getcastledata(strnpcinfo(4),CD_CURRENT_DEFENSE)-5;
	if (.@Defence < 0) set .@Defence, 0;
	setcastledata strnpcinfo(4),CD_CURRENT_DEFENSE,.@Defence;
	// Set new owner
	setcastledata strnpcinfo(4),CD_GUILD_ID,.@GID;
	// Clear castle's data.
	for(set .@i,CD_INVESTED_ECONOMY; .@i<CD_ENABLED_GUARDIAN00; set .@i,.@i+1)
		setcastledata strnpcinfo(4),.@i,0;
	// Disable Kafra
	disablenpc "Kafra Employee#"+strnpcinfo(2);
	
---------------------------------------------
 Add these below..
 ---------------------------------------------
	query_sql("INSERT INTO `breaker_ladder` SET `char_id` = '"+getcharid(0)+"', `char_name` = '"+strcharinfo(0)+"', `count` = '1' ON DUPLICATE KEY UPDATE `count` = `count`+1");
	#EMPBREAKERPTS += $@empbreakpoints;

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

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`, `char_name`, `count` FROM `breaker_ladder` ORDER BY `count` DESC LIMIT 10", .@cid, .@cname, .@count))) {
			mes "No data found.";
			close;
		}
		for ( .@i = 0; .@i < .@nb; .@i++ )
			mes (.@i+1) +". "+ .@cname[.@i]) +" ~ "+ .@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?
	$@empbreakpoints = 1; 

	query_sql("CREATE TABLE IF NOT EXISTS `breaker_ladder` (`char_id` int(11) unsigned NOT NULL, `char_name` varchar(255) NOT NULL DEFAULT 'unknown', `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

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  103
  • Reputation:   1
  • Joined:  06/26/13
  • Last Seen:  

3 hours ago, Terces said:

My guess is that strcharinfo() only works on logged in players. One "could" leverage the power of SQL and use the char-id to find the actual player, but that is a bit more complicated. Instead I simply added a field to the table that contains the name. Instead of just saving the players ID, I also save the name. I haven't tested this, but maybe it will give you an idea how you could solve it:


//===== 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 .@GID,getcharid(2);
	// Show and log error if an unguilded player breaks the Emperium. (Should NEVER happen)
	if (.@GID <= 0) {
		set .@notice$,"Character "+strcharinfo(0)+" ("+getcharid(0)+") broke the Emperium in Castle: "+strnpcinfo(2)+" while guildless. No data will be saved and Emperium respawned.";
 		logmes .@notice$; debugmes .@notice$;
		donpcevent "Agit#"+strnpcinfo(2)+"::OnStartArena";
		end;
	}

---------------------------------------------
 Add these below..
 ---------------------------------------------
	query_sql("INSERT INTO `breaker_ladder` SET `char_id` = '"+getcharid(0)+"', `char_name` = '"+strcharinfo(0)+"', `count` = '1' ON DUPLICATE KEY UPDATE `count` = `count`+1");
	#EMPBREAKERPTS += $@empbreakpoints;

// For WoE Second Edition
// open npc/guild2/agit_main_se.txt

---------------------------------------------
Look for this part: 
---------------------------------------------

OnStartArena:
	set .@GID,getcharid(2);
	set .@region$, (compare(strnpcinfo(4),"arug"))?"Valfreyja":"Nithafjoll";
	// Lower castle Economy
	set .@Economy,getcastledata(strnpcinfo(4),CD_CURRENT_ECONOMY)-5;
	if (.@Economy < 0) set .@Economy, 0;
	setcastledata strnpcinfo(4),CD_CURRENT_ECONOMY,.@Economy;
	// Lower Castle Defence
	set .@Defence,getcastledata(strnpcinfo(4),CD_CURRENT_DEFENSE)-5;
	if (.@Defence < 0) set .@Defence, 0;
	setcastledata strnpcinfo(4),CD_CURRENT_DEFENSE,.@Defence;
	// Set new owner
	setcastledata strnpcinfo(4),CD_GUILD_ID,.@GID;
	// Clear castle's data.
	for(set .@i,CD_INVESTED_ECONOMY; .@i<CD_ENABLED_GUARDIAN00; set .@i,.@i+1)
		setcastledata strnpcinfo(4),.@i,0;
	// Disable Kafra
	disablenpc "Kafra Employee#"+strnpcinfo(2);
	
---------------------------------------------
 Add these below..
 ---------------------------------------------
	query_sql("INSERT INTO `breaker_ladder` SET `char_id` = '"+getcharid(0)+"', `char_name` = '"+strcharinfo(0)+"', `count` = '1' ON DUPLICATE KEY UPDATE `count` = `count`+1");
	#EMPBREAKERPTS += $@empbreakpoints;

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

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`, `char_name`, `count` FROM `breaker_ladder` ORDER BY `count` DESC LIMIT 10", .@cid, .@cname, .@count))) {
			mes "No data found.";
			close;
		}
		for ( .@i = 0; .@i < .@nb; .@i++ )
			mes (.@i+1) +". "+ .@cname[.@i]) +" ~ "+ .@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?
	$@empbreakpoints = 1; 

	query_sql("CREATE TABLE IF NOT EXISTS `breaker_ladder` (`char_id` int(11) unsigned NOT NULL, `char_name` varchar(255) NOT NULL DEFAULT 'unknown', `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

 


having an error >.< and if i tried to view the top 10 list sql error.

sdfdsfdfdfss.png

2342342342342.png

Edited by Noire
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   25
  • Joined:  11/28/11
  • Last Seen:  

Ah yes...change

mes (.@i+1) +". "+ .@cname[.@i]) +" ~ "+ .@count[.@i] +" breaks.";

to

mes (.@i+1) +". "+ .@cname[.@i] +" ~ "+ .@count[.@i] +" breaks.";

There was a stray ")" in there.

 

The SQL error is because you already had the script running once so there already is an "breaker_ladder" table. You will have to either delete the table or add the "char_name" field manually.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  103
  • Reputation:   1
  • Joined:  06/26/13
  • Last Seen:  

23 hours ago, Terces said:

Ah yes...change


mes (.@i+1) +". "+ .@cname[.@i]) +" ~ "+ .@count[.@i] +" breaks.";

to


mes (.@i+1) +". "+ .@cname[.@i] +" ~ "+ .@count[.@i] +" breaks.";

There was a stray ")" in there.

 

The SQL error is because you already had the script running once so there already is an "breaker_ladder" table. You will have to either delete the table or add the "char_name" field manually.

do i need to add a new column to make it work? it doesnt count when i break the emperium.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   25
  • Joined:  11/28/11
  • Last Seen:  

yes, you'll need to add the column 'char_name'

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