Jump to content
  • 0

Newbie question: how get an item ID by item name, in script?


Question

Posted (edited)

I have a string var with the item name stored (a Jellopy, for example). How I get the ID of the Jellopy by their name, via NPC script?

I need do this in this way, because the name that I get is dynamic, based on a long list of items.

I want something like "getitemname(<item id>)", but moke like "getitemid(<item name>)", or a way to get it, without using "searchitem(<array name>, "<item name>")".

Edited by Kavaline
Explaining that is in script

3 answers to this question

Recommended Posts

  • 1
Posted (edited)
	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]) + "]";

or better 

getiteminfo("<item name>", ITEMINFO_ID)

 

Edited by Emistry
update
  • Upvote 1
  • 0
Posted (edited)

Use atcommand "@idsearch " + .@item_name$; to display item id by item name.

If you want scripts please wait other to reply, I don't know command that work like idsearch.

Edited by Start_
  • 0
Posted
4 minutes ago, Start_ said:

Use atcommand "@idsearch " + .@item_name$; to display item id by item name.

If you want scripts please wait other to reply, I don't know command that work like idsearch.

Sorry, I don't explain that is for script. I need do this in a NPC script, thanks for the shot ?

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