Jump to content
  • 0

Item link input


Mad Walker

Question


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  177
  • Reputation:   9
  • Joined:  06/25/12
  • Last Seen:  

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
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  92
  • Reputation:   17
  • Joined:  08/11/12
  • Last Seen:  

@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_
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  177
  • Reputation:   9
  • Joined:  06/25/12
  • Last Seen:  

Thank you OKUZ! <3

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