Items.id Shared function

From Gothic 2 Online: Wiki
Jump to navigation Jump to search

This function was added in version: 0.0.0.0

Function gets item id by it's instance. Items must be registered in items.xml file, in order to be able to, for example: give item for specifc player.

NOTE! After server restart, every item does have different id. The id is the same on both sides. You should only use item id in functions, not in save eq, etc.

Syntax

int Items.id(string instance)

Required Arguments

  • instance: The item code.

Returns

  • int: If item is registered in items.xml it will return it's id, otherwise -1.

Example

addEventHandler("onInit",function(pid)
{
	local itemId = Items.id("ITMI_GOLD"))
	print("ITMI_GOLD id: "+itemId); // it will print item id of ITMI_GOLD
};

Related functions