Jump to content

Question

Posted (edited)

Anyone can help on this item link script

-	script	itemdescs	-1,{
end;

OnInit:
	bindatcmd "ii2",strnpcinfo(3)+"::OnAtcommand";
	bindatcmd "itemdesc",strnpcinfo(3)+"::OnAtcommand";
	end;
	
OnAtcommand:
  mes "^3355FF[ Item Description Search ]^000000";
  mes "Input item name:";
  input .@item;
  mes "<ITEMLINK>"+getitemname(.@item)+"<INFO>"+.@item+"</INFO></ITEMLINK>";
  mes "Click on the name of the item above.";
  close;

}

script is not mine, ctto. I revised it and made it search the item using its item id. Now I want to make it more user friendly by replacing item id to name. User inputs the name of an item then it will show the corresponding list(s) of item with the same name. If the input is invalid / not in the database return Invalid input.

Edited by Mad Walker

2 answers to this question

Recommended Posts

  • 0
Posted (edited)

@Mad Walker

Here is what you have requested.

-	script	itemdescs	-1,{
OnAtcommand:
	mes "^3355FF[ Item Description Search ]^000000";
	mes "Input item name:";
	next;
	input .@item$;
	set .@result, searchitem(.@matches[0],.@item$);
	mes "^3355FF[ Item Description Search ]^000000";
	mes "I found "+.@result+" items:";
	next;
	for (set .@i, 0; .@i < .@result; set .@i, .@i + 1) {
		mes "<ITEMLINK>"+getitemname(.@matches[.@i])+"<INFO>"+.@matches[.@i]+"</INFO></ITEMLINK>";
		mes "Click on the name of the item above.";
	}
	close;

OnInit:
	bindatcmd "ii2",strnpcinfo(3)+"::OnAtcommand";
	bindatcmd "itemdesc",strnpcinfo(3)+"::OnAtcommand";
}

Changes I've made:

 *searchitem <array name>,"<item name>";


This command will fill the given array with the ID of items whose name matches
the given one. It returns the number of items found. For performance reasons,
the results array is limited to 10 items.

    mes "What item are you looking for?";
    input .@name$;
    .@qty = searchitem(.@matches[0],.@name$);
    mes "I found " + .@qty + " items:";
    for (.@i = 0; .@i < .@qty; .@i++)
        // Display name (eg: "Apple[0]")
        mes getitemname(.@matches[.@i]) + "[" + getitemslots(.@matches[.@i]) + "]";
Edited by _Okuz_

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