Jump to content
  • 0

NPC Searching


Question

4 answers to this question

Recommended Posts

Posted

hello, this was made by capachue, i'm not sure if it will work for eathena, give a try ok (:?

prontera,144,158,6	script	Espia	56,{
	if ( getgmlevel() < 99 ) end;
	mes "Enter an item id or item name. Display a list order by max amount found.";
	input .@tmp$;
	set .@item_id, atoi( .@tmp$ );
	if ( .@item_id == 0 && getstrlen( .@tmp$ ) > 2 ) {// item name, eventually
		set .@count, searchitem( .@tmp_array, .@tmp$ );
		if ( .@count == 0 ) {// none item found
			mes "None item found.";
			close;
		}
		mes "I found the following items: ";
		next;
		while( .@i < .@count ) {
			set .@menu$, .@menu$ + getitemname( .@tmp_array[.@i] ) +" (ID "+ .@tmp_array[.@i] +"):";
			set .@i, .@i +1;
		}
		set .@s, select( .@menu$ ) -1;
		set .@item_id, .@tmp_array[.@s];
	}
	else if ( .@item_id == 0 || getiteminfo( .@item_id,2 ) == -1 ) {
		mes "Wrong item id";
		close;
	}

	set .@search$, "`nameid` = "+ .@item_id +" or `card0` = "+ .@item_id +" or `card1` = "+ .@item_id +" or `card2` = "+ .@item_id +" or `card3` = "+ .@item_id;
	while(1) {
		set .@count, query_sql( "SELECT `char`.`name`, "+
			"( SELECT COALESCE( SUM(`amount`),0 ) FROM `inventory` WHERE `char`.`char_id` = `inventory`.`char_id` and ( "+ .@search$ +" ) ) AS inv, "+
			"( SELECT COALESCE( SUM(`amount`),0 ) FROM `cart_inventory` WHERE `char`.`char_id` = `cart_inventory`.`char_id` and ( "+ .@search$ +" ) ) AS cart, "+
			"( SELECT COALESCE( SUM(`amount`),0 ) FROM `storage` WHERE `storage`.`account_id` = `char`.`account_id` and ( "+ .@search$ +" ) ) AS sto, "+
			"( SELECT COALESCE( SUM(`amount`),0 ) FROM `guild_storage` WHERE `guild_storage`.`guild_id` = `char`.`guild_id` and ( "+ .@search$ +" ) ) AS gsto "+
			"FROM `char` order by ( inv + cart + sto + gsto ) desc limit "+ ( .@page * 100 ) +", 100", .@name$, .@inventory, .@cart, .@storage, .@gstorage );
		if ( .@count == 0 ) break;
		for ( set .@i, 0; .@i < .@count && .@name$[.@i] != ""; set .@i, .@i +20 ) {
			mes "^ff0000<player>^000000 <inv>,^00ff00<cart>,^0000ff<sto>,^006600<gsto>";
			for ( set .@j, 0; .@j < 20 && .@name$[ (.@i+.@j) ] != ""; set .@j, .@j +1 ) {
				set .@tmp, .@i + .@j;
				if ( ( .@inventory[.@tmp] + .@cart[.@tmp] + .@storage[.@tmp] + .@gstorage[.@tmp] ) == 0 ) {
					next;
					goto L_end;// XP!
				}
				set .@num, .@num +1;
				mes .@num +"/ ^ff0000"+ .@name$[.@tmp] +"^000000 : < "+ .@inventory[.@tmp] +", ^00ff00"+ .@cart[.@tmp] +", ^0000ff"+ .@storage[.@tmp] +", ^006600"+ .@gstorage[.@tmp] +"^000000 >";
			}
			next;
		}
		set .@page, .@page +1;
	}
L_end:
	mes "*end of the list*";
	close;
}
Posted

i dont know how can use this...

 

click the npc and then input the name of an items

 

the npc will search how many players have that item

 

the npc even detects similar items and will give you a list of which item may be

 

the npc window shows you firs the location of where the items are

 

if you need more explanation let me know o; so i can elaborate more this, give a try (:

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