This page describes the format of the item table shared by the functions that read / create / modify items, and the item-creation functions of the Item table. Information about item types (name, size, group) is on the page Item: type information (Item: item type information); the function that transfers an item intact to the website is on the page Item: record for the website (Item: record for the website).

Item table

The read functions (Player.GetItem, Warehouse.GetItem, EventInventory.GetItem, MuunInventory.GetItem, Item.GetGroundItem) return a table with the following fields. The create / modify functions (Item.Give, Item.Drop, Item.GremoryAdd, Inventory.SetItem) accept a table with the same field names.

FieldTypeWhen readingWhen creating / modifying
IndexintegerItem code (group * 512 + sequence number)Required when creating; must be a code that exists in ItemList. Cannot be changed with Inventory.SetItem
SerialnumberSerial numberNot used
LevelintegerLevel +Clamped from 0 to the item's maximum level
DurabilitynumberDurability / stack count0 to 255. 0 or 255 = default durability
SkillintegerHas skill (0 / 1)Clamped to 0 to 1
LuckintegerHas luck (0 / 1)Clamped to 0 to 1
OptionintegerAdditional option0 to 255
ExcintegerExcellent attributes (bit mask)0 to 255
AncientintegerSet / Ancient item attributes0 to 255
HarmonyintegerHarmony option (Jewel of Harmony)0 to 255
Option380integer380 option0 to 255
SocketBonusintegerSocket bonus0 to 255, default 255
ExpireDatenumberExpiry time (timestamp); 0 = no expiryNot used (use Duration when creating)
SocketstableTable of 5 elements (indexes 1 to 5)Table of 5 elements
Durationinteger(not present when reading)The item's lifetime in seconds counted from creation, maximum 10 years. 0 = no expiry set
Countinteger(not present when reading)Quantity to create (see each function)

Each element of Sockets: -1 = no socket slot, 254 = empty socket slot, any other value = the code of the socket seed fitted in the slot. A field missing when creating uses the default value above.

The Skill and Luck fields also have the old-style names Option1 and Option2; Option = Option3; Exc = NewOption; Ancient = SetOption; Harmony = JoHOption; Option380 = ["380Option"]; Sockets = SocketOption1 to SocketOption5; SocketBonus = SocketOptionBonus; ExpireDate = DurationTime. The old names only exist in tables returned by the short-name functions (InventoryGetItemTable, EventInventoryGetItemTable, MuunInventoryGetItemTable, MapGetItemTable), and are accepted in tables passed to InventorySetItemTable.

Giving items to a character

Item.Give

Creates an item and puts it into the character's inventory. Creation is asynchronous (GameServer requests the serial number from the database and only then adds it to the inventory), so the function checks for free space first and limits the quantity to the remaining space.

Item.Give(aIndex, item) -> integer
ParameterTypeDescription
aIndexintegerCharacter index
itemtableItem table (see above). Count from 1 to 50 (default 1)

Returns: the number of items requested to be created; 0 if there is not enough space, the table is wrong (the code does not exist), the character is trading / has a window open or the conditions are not met. Rules by type:

  • Event bag items: need free space in the event bag, always create 1.
  • Muun items: need a free slot in the Muun bag, always create 1.
  • Normal items: need space for at least 1; Count is limited by the number of free cells divided by the item's area (width x height).

Short names: ItemGiveEx(aIndex, item, level, dur, skill, luck, option, exc, ancient, harmony, opt380, s1, s2, s3, s4, s5, socketBonus, duration), and CreateItem(useType = 1, aIndex, ...). You should call Player.CheckItemAction first.

local given = Item.Give(aIndex, { Index = 7181, Count = 5 })
if given == 0 then
    Message.Send(aIndex, 1, "Your inventory is full")
end

-- An item with attributes, valid for 7 days
Item.Give(aIndex, { Index = 3 * 512 + 5, Level = 9, Luck = 1, Option = 4, Exc = 1, Duration = 7 * 86400 })

Item.GiveBag

Opens a random item bag (ItemBag) and puts the items into the character's inventory at the position where the character is standing.

Item.GiveBag(aIndex, bag) -> boolean
ParameterTypeDescription
aIndexintegerCharacter index
baginteger or stringNumber (GUID) or name of the ItemBag

Returns: true if the bag was executed; false if the bag was not found, the character is trading or the conditions are not met. Short name: ItemGive.

Item.GiveBag does not check for free space in the inventory. Any item that cannot be added to the inventory (inventory full) is not created: it does not drop on the ground and is not moved to the Gremory Box. If you need to be sure the full reward is received, check for free space first, or use Item.GremoryAdd to give the reward.
Item.GiveBag(aIndex, "DailyReward")

Item.DropBag

Opens a random item bag and makes the items drop on the ground. The character is the owner of the items.

Item.DropBag(aIndex, bag [, map, x, y]) -> boolean
ParameterTypeDescription
aIndexintegerCharacter index
baginteger or stringNumber (GUID) or name of the ItemBag
mapintegerMap where it drops; defaults to the character's map
x, yintegerDrop coordinates (clamped from 0 to 255); defaults to the character's coordinates

Returns: true if it was executed; false if the bag was not found, the map does not exist or the conditions are not met. Short name: ItemDrop(aIndex, map, x, y, bag).

Item.DropBag(aIndex, "BossReward", Object.GetMap(aIndex), Object.GetX(aIndex), Object.GetY(aIndex))

Items lying on the ground

Item.Drop

Makes an item drop on the ground.

Item.Drop(map, x, y, item [, ownerIndex]) -> boolean
ParameterTypeDescription
mapintegerMap number (must exist on this GameServer)
x, yintegerDrop coordinates (clamped from 0 to 255)
itemtableItem table (see above). The Count field is not used: each call drops 1 item
ownerIndexintegerIndex of the character / monster that owns the item (only that one can pick it up). -1 or omitted = anyone can pick it up

Returns: true if the drop was requested; false if the map does not exist, the table is wrong or the script is in restricted mode. Short names: ItemDropEx(aIndex, map, x, y, item, level, dur, skill, luck, option, exc, ancient, harmony, opt380, s1, s2, s3, s4, s5, socketBonus, duration) (aIndex is the owner), and CreateItem(useType = 0, ...).

When there is a valid ownerIndex, only the owner can pick up the item and this right does not expire (the item stays there until it is picked up or disappears according to the item's lifetime on the ground); other players cannot pick it up, even in the same party. Administrator accounts are not subject to this restriction.

Item.Drop(MAP_LORENCIA, 130, 130, { Index = 14 * 512 + 13 })   -- a Jewel of Bless drops in the middle of Lorencia

Item.GetGroundItem

Reads the information of an item lying on the ground.

Item.GetGroundItem(map, itemIndex) -> table | nil
ParameterTypeDescription
mapintegerMap number
itemIndexintegerIndex of the item on the map (from 0 to Object.GetMaxItem() - 1)

Returns: an item table with two extra fields X and Y (the position); nil if the slot has no item or the parameters are wrong. Short name: MapGetItemTable(map, index) (the table also has the old-style field names).

local it = Item.GetGroundItem(MAP_LORENCIA, 0)
if it then Log.Add("Item " .. it.Index .. " at " .. it.X .. "," .. it.Y) end

Gremory Box

Item.GremoryAdd

Adds an item to the character's Gremory Box (used when you want to give a reward without needing free inventory space).

Item.GremoryAdd(aIndex, item) -> boolean
ParameterTypeDescription
aIndexintegerCharacter index
itemtableItem table (see above) plus the two special fields below. Count from 1 to 100 (default 1)

The two special fields of this function:

FieldValueMeaning
Storage1 (default), 2, 3Where it is stored: 1 = the character's box, 2 = the account's box, 3 = the Personal Store tab (150 slots, used for items put up for sale). Values other than 2 and 3 are treated as 1
Rewardinteger 0 to 255Reward source shown in the box. The default is the "GM reward" source (with Storage = 3 the default is the event source)

Returns: true if the addition was requested; false if the character does not meet the conditions, item is not a table or the item code does not exist. The function does not check whether the box has space: use Item.GremoryFreeSlots first if needed.

Short names: InsertItem_GremoryCaseEx(aIndex, storage, reward, index, level, dur, skill, luck, option, ancient, opt380, harmony, exc, unused, s1, s2, s3, s4, s5, socketBonus, duration, count) and InsertItem_GremoryCase(aIndex, storage, reward, index, level, dur, skill, luck, option, ancient, isSocket, isElemental, muunEvo, exc, masteryExe, s1, s2, s3, s4, s5, socketBonus, receiptDuration, duration, count). With the second short name, the receiptDuration value is used as Duration and duration is ignored; the parameters isSocket, isElemental, muunEvo, masteryExe are ignored.

The Duration field (seconds), when greater than 0, sets the item's usage time limit (counted from the moment it is added to the box, and kept as is when the player takes it out into the inventory); 0 = the item has no usage time limit. Duration is not the time the item is kept in the box.

Item.GremoryAdd(aIndex, { Index = 14 * 512 + 13, Count = 10, Storage = 2 })

Item.GremoryFreeSlots

Returns the number of free slots in the Gremory Box.

Item.GremoryFreeSlots(aIndex [, storage]) -> integer
ParameterTypeDescription
aIndexintegerCharacter index
storageinteger1 = character box (default), 2 = account box, 3 = Personal Store tab

Returns: the number of free slots; 0 if invalid. Short name: GCTotalFreeSlotCount(aIndex, storage).

if Item.GremoryFreeSlots(aIndex, 1) >= 3 then
    Item.GremoryAdd(aIndex, { Index = 14 * 512 + 13, Count = 3 })
end

Item.RandomLevel

Returns a random item level (+) in the range minLevel to maxLevel (both ends included). Use it when building rewards with a random level yourself.

Item.RandomLevel(minLevel, maxLevel) -> integer
ParameterTypeDescription
minLevelintegerLowest level (limited to 0 up to the item's maximum level, which is 15)
maxLevelintegerHighest level (limited to 0 to 15)

Returns: an integer from minLevel to maxLevel. If minLevel is greater than maxLevel, the two numbers are swapped automatically; a missing parameter is treated as 0. Short name: GetBagItemLevel(min, max).

-- give 1 sword (group 0, number 0) with a random level from +7 to +9
local level = Item.RandomLevel(7, 9)
Item.Give(aIndex, { Index = 0 * 512 + 0, Level = level })