Jump to content
  • 0

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


Kavaline

Question


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.01
  • Content Count:  18
  • Reputation:   1
  • Joined:  02/15/20
  • Last Seen:  

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

3 answers to this question

Recommended Posts

  • 1

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

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

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  924
  • Reputation:   167
  • Joined:  04/05/13
  • Last Seen:  

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

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.01
  • Content Count:  18
  • Reputation:   1
  • Joined:  02/15/20
  • Last Seen:  

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 ?

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