Saltar a contenido

Funciones de Inventario

InventoryGetItemCount(aIndex, itemIndex, itemLevel)

Cuenta cuántos items específicos (por índice y nivel) hay en el inventario del jugador.

  • Retorna: number
local count = InventoryGetItemCount(aIndex, GET_ITEM(14, 13), 0)
LogAdd(LOG_BLUE, "Player has " .. count .. " Jewels of Bless.")

InventoryDelItemIndex(aIndex, slot)

Elimina un item de un slot específico del inventario.

  • Retorna: boolean
if InventoryDelItemIndex(aIndex, 12) then
    LogAdd(LOG_GREEN, "Item at slot 12 deleted.")
end

InventoryDelItemCount(aIndex, itemIndex, itemLevel, count)

Elimina hasta count items del tipo especificado del inventario.

  • Retorna: boolean
-- Remove 5 Jewels of Bless
InventoryDelItemCount(aIndex, GET_ITEM(14, 13), 0, 5)

InventoryGetFreeSlotCount(aIndex)

Retorna el número de slots libres de 1x1 en el área principal del inventario.

  • Retorna: number
local free = InventoryGetFreeSlotCount(aIndex)
if free < 4 then
    GCNoticeSend(aIndex, 1, "Your inventory is almost full!")
end

InventoryCheckSpaceByItem(aIndex, itemIndex)

Verifica si el inventario tiene espacio suficiente para el item dado (usando sus dimensiones reales).

  • Retorna: boolean
if not InventoryCheckSpaceByItem(aIndex, GET_ITEM(0, 18)) then
    GCNoticeSend(aIndex, 1, "Not enough inventory space.")
end

InventoryCheckSpaceBySize(aIndex, width, height)

Verifica si el inventario tiene un área rectangular libre de width x height.

  • Retorna: boolean
if InventoryCheckSpaceBySize(aIndex, 2, 3) then
    LogAdd(LOG_GREEN, "2x3 space available.")
end

Funciones de Transacción de Inventario

Disponibles cuando CHARACTER_RESTORE_INFO == 0. Proporcionan operaciones atómicas de inventario.

Función Descripción
gObjFixInventoryPointer(aIndex) Restablecer puntero de inventario al primario
gObjSetInventory1Pointer(aIndex) Apuntar al inventario de respaldo 1
gObjSetInventory2Pointer(aIndex) Apuntar al inventario de respaldo 2
gObjFixEventInventoryPointer(aIndex) Restablecer puntero de inventario de eventos
gObjSetEventInventory1Pointer(aIndex) Apuntar al respaldo de eventos 1
gObjSetEventInventory2Pointer(aIndex) Apuntar al respaldo de eventos 2
gObjInventoryTransaction(aIndex) Iniciar transacción de inventario
gObjInventoryCommit(aIndex) Confirmar transacción
gObjInventoryRollback(aIndex) Revertir transacción
gObjInventoryTransaction(aIndex)
-- ... modify inventory ...
if success then
    gObjInventoryCommit(aIndex)
else
    gObjInventoryRollback(aIndex)
end