• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Get item from closed container

Pawcio6

Member
Joined
Sep 26, 2009
Messages
143
Solutions
4
Reaction score
15
Hi
I want to create custom otclient slots but when i tried get item with this
Code:
    local item = player:getInventoryItem(InventorySlotExtra)
    skillsWindow:getChildById('itemView'):setItemId(item:getId())
    skillsWindow:getChildById('itemView'):setItem(item)
  local container = g_game.getContainer(skillsWindow:getChildById('itemView').index)
    skillsWindow:getChildById('itemView2'):setItemId(container:getItem(2):getId())
    skillsWindow:getChildById('itemView2'):setItem(container:getItem(2))
    skillsWindow:getChildById('itemView2').position = container:getSlotPosition(2)
it works only when container is open but there is a way to link a item without any player help?
 
Okey im now trying to open container in custom window i made something like this
function onContainerosOpen(container, previousContainer)
local containerWindow
if previousContainer then
containerWindow = previousContainer.window
previousContainer.window = nil
previousContainer.itemsPanel = nil
else
containerWindow = g_ui.createWidget('ContainerWindow', skillsWindow)
containerob = containerWindow
end
containerWindow:setId('containerProffesion')
local containerPanel = containerWindow:getChildById('contentsPanel')
local containerItemWidget = containerWindow:getChildById('containerItemWidget')
containerWindow.onClose = function()
g_game.close(container)
containerWindow:hide()
end

local name = container:getName()
name = name:sub(1,1):upper() .. name:sub(2)
containerWindow:setText(name)

containerItemWidget:setItem(container:getContainerItem())

containerPanel:destroyChildren()
for slot=0,container:getCapacity()-1 do
local itemWidget = g_ui.createWidget('Item', containerPanel)
itemWidget:setId('item' .. slot)
itemWidget:setItem(container:getItem(slot))
itemWidget:setMargin(0)
itemWidget.position = container:getSlotPosition(slot)

if not container:isUnlocked() then
itemWidget:setBorderColor('red')
end
end
container.window = containerWindow
container.itemsPanel = containerPanel

toggleContainerPages(containerWindow, container:hasPages())
refreshContainerPages(container)

local layout = containerPanel:getLayout()
local cellSize = layout:getCellSize()
containerWindow:setContentMinimumHeight(cellSize.height)
containerWindow:setContentMaximumHeight(cellSize.height*layout:getNumLines())

if not previousContainer then
local filledLines = math.max(math.ceil(container:getItemsCount() / layout:getNumColumns()), 1)
containerWindow:setContentHeight(filledLines*cellSize.height)
end
containerWindow:setup()
end
g_game.open(player:getInventoryItem(InventorySlotBack))
scheduleEvent(function()
local container = g_game.getContainer(player:getInventoryItem(InventorySlotBack).index)
if container then
onContainerosOpen(container)
g.game.close(container)
end
end,100)
the containers have different Id but still g.game.close(container) function close the custom windows container. How to get container open on the right panel or there is a way to use g_game.getContainer(player:getInventoryItem(InventorySlotBack).index) without opening?
Also looked for changing the normal container opening changed in game_containers\containers.lua
if g_game.getLocalPlayer() and g_game.getLocalPlayer():getInventoryItem(InventorySlotBack):getId() == container:getId() then
containerWindow = g_ui.createWidget('ContainerWindow', modules.game_interface.getLeftPanel())
else
containerWindow = g_ui.createWidget('ContainerWindow', modules.game_interface.getRightPanel())
end
but it still opening on right panel. Can someone help becouse i dont know much otclient functions.
 
Ok I added new message for opening containers and it works like i want to.
 
Back
Top