• 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!

WASD and INVENTORY question

ArqNova

New Member
Joined
Oct 19, 2015
Messages
8
Reaction score
0
HI
I want set a different background on inventory for eachvocation (later,for a storage)
Then i made this :
game_inventory.lua
InventorySlotStyles = {
[InventorySlotHead] = "HeadSlot",
[InventorySlotNeck] = "NeckSlot",
[InventorySlotBack] = "BackSlot",
[InventorySlotBody] = "BodySlot",
[InventorySlotRight] = "RightSlot",
[InventorySlotLeft] = "LeftSlot",
[InventorySlotLeg] = "LegSlot",
[InventorySlotFeet] = "FeetSlot",
[InventorySlotFinger] = "FingerSlot",
[InventorySlotAmmo] = "AmmoSlot"
}

Backgrounds =
{
[0] = { path = '/images/inventory/Anbu_INV.png', id = 'background_noth'},
[1] = { path = '/images/inventory/Human_inv.png', id = 'background_human'},
[2] = { path = '/images/inventory/Orc_inv.png', id = 'background_orc'},
[3] = { path = '/images/inventory/Elf_inv.png', id = 'background_elf'},
[4] = { path = '/images/inventory/Dwarf_inv.png', id = 'background_dwarf'},
[5] = { path = '/images/inventory/Undead_inv.png', id = 'background_undead'},
[6] = { path = '/images/inventory/Minotaur_inv.png', id = 'background_minotaur'},
}

inventoryWindow = nil
inventoryPanel = nil
inventoryButton = nil

function init()
connect(LocalPlayer, { onInventoryChange = onInventoryChange })
connect(g_game, { onGameStart = refresh })
connect(g_game, { onGameEnd = offline })
ProtocolGame.registerExtendedOpcode(60, test)
g_keyboard.bindKeyDown('Ctrl+I', toggle)

inventoryButton = modules.client_topmenu.addRightGameToggleButton('inventoryButton', tr('Inventory') .. ' (Ctrl+I)', '/images/topbuttons/inventory', toggle)
inventoryButton:setOn(true)

inventoryWindow = g_ui.loadUI('inventory', modules.game_interface.getRightPanel())
inventoryWindow:disableResize()
inventoryPanel = inventoryWindow:getChildById('contentsPanel')

-- local itemWidget = inventoryPanel:getChildById('slot10')
--itemWidget:setVisible(false)

refresh()
inventoryWindow:setup()
refresh()
inventoryWindow:close()
inventoryButton:setOn(false)

end

function terminate()
disconnect(LocalPlayer, { onInventoryChange = onInventoryChange })
disconnect(g_game, { onGameStart = refresh })

g_keyboard.unbindKeyDown('Ctrl+I')

inventoryWindow:destroy()
inventoryButton:destroy()
end

function offline()
inventoryButton:setOn(false)
inventoryWindow:close()
end

function refresh()
local player = g_game.getLocalPlayer()
for i = InventorySlotFirst, InventorySlotPurse do
if g_game.isOnline() then
onInventoryChange(player, i, player:getInventoryItem(i))
else
onInventoryChange(player, i, nil)
end
end
end

function toggle()
if inventoryButton:isOn() then
inventoryWindow:close()
inventoryButton:setOn(false)
else
inventoryWindow:eek:pen()
inventoryButton:setOn(true)
end
refresh()
end

function onMiniWindowClose()
inventoryButton:setOn(false)
end

function test(protocol, opcode, buffer)
local player = g_game.getLocalPlayer()
if g_game.isOnline() then
local vocation = tonumber(buffer)
if(vocation ~= 0) then
inventoryWindow:setImageSource(Backgrounds[vocation].path)
end
end
end
-- hooked events
function onInventoryChange(player, slot, item, oldItem)

if slot >= InventorySlotPurse then return end
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
if not itemWidget then return end
if item then
itemWidget:setStyle('Item')
itemWidget:setItem(item)
else
itemWidget:setStyle(InventorySlotStyles[slot])
itemWidget:setItem(nil)
end
end

Client part
doSendPlayerExtendedOpcode(cid, 60, getPlayerVocation(cid))

but in terminal appears it :

ERROR: command failed: C++ call failed: LUA ERROR: attempt to cast a 'number' lua value to 'stdext::shared_object_ptr<ProtocolGame>'
stack traceback:
[C]: ?
[C]: in function 'sendExtendedOpcode'
:1: in main chunk
[C]: in function 'pcall'
/client_terminal/terminal.lua:346: in function 'executeCommand'
/client_terminal/terminal.lua:101: in function </client_terminal/terminal.lua:99>
[C]: in function 'pcall'
/corelib/util.lua:301: in function </corelib/util.lua:299>
(tail call): ?
stack traceback:
[C]: ?
[C]: in function 'sendExtendedOpcode'
:1: in main chunk
[C]: in function 'pcall'
/client_terminal/terminal.lua:346: in function 'executeCommand'
/client_terminal/terminal.lua:101: in function </client_terminal/terminal.lua:99>
[C]: in function 'pcall'
/corelib/util.lua:301: in function </corelib/util.lua:299>
(tail call): ?

HOW CAN I SOLVE IT ?

-----------

WASD -
someone can give me some tips, if is possible, how can i let WASD mode default, then if u press enter, the textwindow unlock and you can writte, and when press enter again it sends the written msg and block chat again, backing to WASD. Like in WoW. I already tried change console.lua but nothing.

THX
 
According to the source the doSendPlayerExtendedOpcode(cid, opcode, buffer), where buffer is a string not an integer.
So try
Code:
doSendPlayerExtendedOpcode( cid, 60, tostring( getPlayerVocation(cid) ) )
 
According to the source the doSendPlayerExtendedOpcode(cid, opcode, buffer), where buffer is a string not an integer.
So try
Code:
doSendPlayerExtendedOpcode( cid, 60, tostring( getPlayerVocation(cid) ) )
nothing ..
 
Back
Top