Ir para conteúdo
  • 0

[Help] 3 Ajudas Necessárias


lucasguzella

Pergunta

Olá galera, estou precisando de três ajudas com meu client, e queria saber se é tranquilo pra editar na pasta mesmo (eu não sei mexer muito bem)

OBS: Uso OTclient-master e não posso trocar de client agora pois já editei muita coisa nela que queria e ficaria meio dificil!

 

 

RESOLVIDO

Qualquer potion quando usado na hotkeys em si mesmo funciona normalmente, porém quando clicado na BP e clicado em você não esta funcionando! (após meses editando client só reparei isso hoje)

 

O trade do meu client quando baixei veio editado, daquele estilo 'OTClient', porém ele é muito bugado, acredito que isso seja no game_playertrade certo? Se alguém puder me ajudar, mesmo com um trade simples (o Normal), estaria agradecido, mas se alguém quiser colocar um trade bem complexo estilo SAO (Sword Art Online, que é meu server) agradeceria ainda mais!

 

Esse eu acredito ser o mais tranquilo.. Acredito ser em client_entergame..

Atualmente no meu servidor abrir o client aparece:

Account Name

Password

Server IP -- Gostaria que tivesse o IP Fixo, sem poder muda-lo

Porta -- Porta fixa, sem poder mudar (e se alguem puder me disser se a porta não precisa ser obrigatoriamente a 7171/7172, agradeceria)

Protocolo -- Protocolo fixo sem poder mudar

 

 

 

Resumindo:

1º - Alteração na Potion Servidor (ingame) RESOLVIDO

2º - Alteração no trade (ingame)

3º - Alteração no login (client)

 

 

 

Quem puder ajudar, e por favor.. Não matem o tópico, como mataram na aba de script e eu fiquei semanas tendo que resolver sozinho..

 

 

 

 

 

 

EDIT:
4º Ajuda

Gostaria de tirar uma skill (não é editar uma skill preste atenção), meu servidor vai ser composto de apenas Swords, por tanto tirar o Axe, Club, é necessário!

 

Editado por lucasguzella
Link para o comentário
Compartilhar em outros sites

10 respostass a esta questão

Posts Recomendados

  • 0

Alguem pode me ajudar pelo menos só com a ? Nem potion, nem corda esta funcionando, o famoso use with..

Eu to achando ridiculo o xTibia ultimamente, sinceramente precisa de uma mudança.. Antigamente era um dos melhores sites de ajuda com OT Server, e agora todos os topicos deixando em branco, vocês estão fodasse pra quem precisa de ajuda..

Sinceramente eu sempre considerei esse site e fiquei até triste quando ele fico off (sim eu lembro), agora se continuar desse modo vai dar na mesma coisa!

Link para o comentário
Compartilhar em outros sites

  • 0

Alguem pode me ajudar pelo menos só com a ? Nem potion, nem corda esta funcionando, o famoso use with..

 

Eu to achando ridiculo o xTibia ultimamente, sinceramente precisa de uma mudança.. Antigamente era um dos melhores sites de ajuda com OT Server, e agora todos os topicos deixando em branco, vocês estão fodasse pra quem precisa de ajuda..

Sinceramente eu sempre considerei esse site e fiquei até triste quando ele fico off (sim eu lembro), agora se continuar desse modo vai dar na mesma coisa!

Ninguem aqui ganha salário para ajudar retardado que nem você que quer tudo na boca, as pessoas que ajudam o forum fazem isso por pura vontade de contribuir com a comunidade, para que a mesma evolua, não como igual membros que nem você sangue-sugas sem fim, que nem mesmo sabe o significado de comunidade.

Então quer respostas o google ta aí pra isso... detalhe eu ia tirar suas duvidas mas quando fui escrever e vi seu post, até dei risada shaushua

Link para o comentário
Compartilhar em outros sites

  • 0

@
Cara eu simplesmente falei a verdade.. Sempre ajudei quem eu podia no forum! Mais fazer o que né..
Eu apenas tentei me expressar, sim eu já ajudei e não recebi salario, não custa nada alguem fazer o mesmo certo?

Se você levou pro pessoal, ai já não é comigo '-'


@@Drakopoulos
Primeiramente, obrigado por tentar :D

Game_interface:

 

WALK_STEPS_RETRY = 10

gameRootPanel = nil
gameMapPanel = nil
gameRightPanel = nil
gameLeftPanel = nil
gameBottomPanel = nil
logoutButton = nil
mouseGrabberWidget = nil
countWindow = nil
logoutWindow = nil
exitWindow = nil
bottomSplitter = nil
limitedZoom = false
currentViewMode = 0
smartWalkDirs = {}
smartWalkDir = nil
walkFunction = nil
function init()
g_ui.importStyle('styles/countwindow')
connect(g_game, {
onGameStart = onGameStart,
onGameEnd = onGameEnd,
onLoginAdvice = onLoginAdvice,
}, true)
gameRootPanel = g_ui.displayUI('gameinterface')
gameRootPanel:hide()
gameRootPanel:lower()
gameRootPanel.onGeometryChange = updateStretchShrink
gameRootPanel.onFocusChange = stopSmartWalk
mouseGrabberWidget = gameRootPanel:getChildById('mouseGrabber')
mouseGrabberWidget.onMouseRelease = onMouseGrabberRelease
bottomSplitter = gameRootPanel:getChildById('bottomSplitter')
gameMapPanel = gameRootPanel:getChildById('gameMapPanel')
gameRightPanel = gameRootPanel:getChildById('gameRightPanel')
gameLeftPanel = gameRootPanel:getChildById('gameLeftPanel')
gameBottomPanel = gameRootPanel:getChildById('gameBottomPanel')
connect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })
logoutButton = modules.client_topmenu.addLeftButton('logoutButton', tr('Exit'),
'/images/topbuttons/logout', tryLogout, true)
setupViewMode(0)
bindKeys()
load()
if g_game.isOnline() then
show()
end
end
function bindKeys()
gameRootPanel:setAutoRepeatDelay(250)
bindWalkKey('Up', North)
bindWalkKey('Right', East)
bindWalkKey('Down', South)
bindWalkKey('Left', West)
bindWalkKey('Numpad8', North)
bindWalkKey('Numpad9', NorthEast)
bindWalkKey('Numpad6', East)
bindWalkKey('Numpad3', SouthEast)
bindWalkKey('Numpad2', South)
bindWalkKey('Numpad1', SouthWest)
bindWalkKey('Numpad4', West)
bindWalkKey('Numpad7', NorthWest)
g_keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Down', function() g_game.turn(South) changeWalkDir(South) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Left', function() g_game.turn(West) changeWalkDir(West) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Numpad8', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Numpad6', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Numpad2', function() g_game.turn(South) changeWalkDir(South) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Numpad4', function() g_game.turn(West) changeWalkDir(West) end, gameRootPanel)
g_keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+=', function() gameMapPanel:zoomIn() end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+-', function() gameMapPanel:zoomOut() end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+Q', function() tryLogout(false) end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+L', function() tryLogout(false) end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+W', function() g_map.cleanTexts() modules.game_textmessage.clearMessages() end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+.', nextViewMode, gameRootPanel)
end
function bindWalkKey(key, dir)
g_keyboard.bindKeyDown(key, function() changeWalkDir(dir) end, gameRootPanel, true)
g_keyboard.bindKeyUp(key, function() changeWalkDir(dir, true) end, gameRootPanel, true)
g_keyboard.bindKeyPress(key, function() smartWalk(dir) end, gameRootPanel)
end
function unbindWalkKey(key)
g_keyboard.unbindKeyDown(key, gameRootPanel)
g_keyboard.unbindKeyUp(key, gameRootPanel)
g_keyboard.unbindKeyPress(key, gameRootPanel)
end
function terminate()
save()
hide()
stopSmartWalk()
disconnect(g_game, {
onGameStart = onGameStart,
onGameEnd = onGameEnd,
onLoginAdvice = onLoginAdvice
})
disconnect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })
logoutButton:destroy()
gameRootPanel:destroy()
end
function onGameStart()
show()
-- open tibia has delay in auto walking
if not g_game.isOfficialTibia() then
g_game.enableFeature(GameForceFirstAutoWalkStep)
else
g_game.disableFeature(GameForceFirstAutoWalkStep)
end
end
function onGameEnd()
setupViewMode(0)
hide()
end
function show()
connect(g_app, { onClose = tryExit })
modules.client_background.hide()
gameRootPanel:show()
gameRootPanel:focus()
gameMapPanel:followCreature(g_game.getLocalPlayer())
setupViewMode(0)
updateStretchShrink()
logoutButton:setTooltip(tr('Logout'))
addEvent(function()
if not limitedZoom or g_game.isGM() then
gameMapPanel:setMaxZoomOut(513)
gameMapPanel:setLimitVisibleRange(false)
else
gameMapPanel:setMaxZoomOut(11)
gameMapPanel:setLimitVisibleRange(true)
end
end)
end
function hide()
disconnect(g_app, { onClose = tryExit })
logoutButton:setTooltip(tr('Exit'))
if logoutWindow then
logoutWindow:destroy()
logoutWindow = nil
end
if exitWindow then
exitWindow:destroy()
exitWindow = nil
end
if countWindow then
countWindow:destroy()
countWindow = nil
end
gameRootPanel:hide()
modules.client_background.show()
end
function save()
local settings = {}
settings.splitterMarginBottom = bottomSplitter:getMarginBottom()
g_settings.setNode('game_interface', settings)
end
function load()
local settings = g_settings.getNode('game_interface')
if settings then
if settings.splitterMarginBottom then
bottomSplitter:setMarginBottom(settings.splitterMarginBottom)
end
end
end
function onLoginAdvice(message)
displayInfoBox(tr("For Your Information"), message)
end
function forceExit()
g_game.cancelLogin()
scheduleEvent(exit, 10)
return true
end
function tryExit()
if exitWindow then
return true
end
local exitFunc = function() g_game.safeLogout() forceExit() end
local logoutFunc = function() g_game.safeLogout() exitWindow:destroy() exitWindow = nil end
local cancelFunc = function() exitWindow:destroy() exitWindow = nil end
exitWindow = displayGeneralBox(tr('Exit'), tr("If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character."),
{ { text=tr('Force Exit'), callback=exitFunc },
{ text=tr('Logout'), callback=logoutFunc },
{ text=tr('Cancel'), callback=cancelFunc },
anchor=AnchorHorizontalCenter }, logoutFunc, cancelFunc)
return true
end
function tryLogout(prompt)
if type(prompt) ~= "boolean" then
prompt = true
end
if not g_game.isOnline() then
exit()
return
end
if logoutWindow then
return
end
local msg, yesCallback
if not g_game.isConnectionOk() then
msg = 'Your connection is failing, if you logout now your character will be still online, do you want to force logout?'
yesCallback = function()
g_game.forceLogout()
if logoutWindow then
logoutWindow:destroy()
logoutWindow=nil
end
end
else
msg = 'Are you sure you want to logout?'
yesCallback = function()
g_game.safeLogout()
if logoutWindow then
logoutWindow:destroy()
logoutWindow=nil
end
end
end
local noCallback = function()
logoutWindow:destroy()
logoutWindow=nil
end
if prompt then
logoutWindow = displayGeneralBox(tr('Logout'), tr(msg), {
{ text=tr('Yes'), callback=yesCallback },
{ text=tr('No'), callback=noCallback },
anchor=AnchorHorizontalCenter}, yesCallback, noCallback)
else
yesCallback()
end
end
function stopSmartWalk()
smartWalkDirs = {}
smartWalkDir = nil
end
function changeWalkDir(dir, pop)
while table.removevalue(smartWalkDirs, dir) do end
if pop then
if #smartWalkDirs == 0 then
stopSmartWalk()
return
end
else
table.insert(smartWalkDirs, 1, dir)
end
smartWalkDir = smartWalkDirs[1]
if modules.client_options.getOption('smartWalk') and #smartWalkDirs > 1 then
for _,d in pairs(smartWalkDirs) do
if (smartWalkDir == North and d == West) or (smartWalkDir == West and d == North) then
smartWalkDir = NorthWest
break
elseif (smartWalkDir == North and d == East) or (smartWalkDir == East and d == North) then
smartWalkDir = NorthEast
break
elseif (smartWalkDir == South and d == West) or (smartWalkDir == West and d == South) then
smartWalkDir = SouthWest
break
elseif (smartWalkDir == South and d == East) or (smartWalkDir == East and d == South) then
smartWalkDir = SouthEast
break
end
end
end
end
function smartWalk(dir)
if g_keyboard.getModifiers() == KeyboardNoModifier then
local func = walkFunction
if not func then
if modules.client_options.getOption('dashWalk') then
func = g_game.dashWalk
else
func = g_game.walk
end
end
local dire = smartWalkDir or dir
func(dire)
return true
end
return false
end
function updateStretchShrink()
if modules.client_options.getOption('dontStretchShrink') and not alternativeView then
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
-- Set gameMapPanel size to height = 11 * 32 + 2
bottomSplitter:setMarginBottom(bottomSplitter:getMarginBottom() + (gameMapPanel:getHeight() - 32 * 11) - 10)
end
end
function onMouseGrabberRelease(self, mousePosition, mouseButton)
if selectedThing == nil then return false end
if mouseButton == MouseLeftButton then
local clickedWidget = gameRootPanel:recursiveGetChildByPos(mousePosition, false)
if clickedWidget then
if selectedType == 'use' then
onUseWith(clickedWidget, mousePosition)
elseif selectedType == 'trade' then
onTradeWith(clickedWidget, mousePosition)
end
end
end
selectedThing = nil
g_mouse.popCursor('target')
self:ungrabMouse()
return true
end
function onUseWith(clickedWidget, mousePosition)
if clickedWidget:getClassName() == 'UIMap' then
local tile = clickedWidget:getTile(mousePosition)
if tile then
g_game.useWith(selectedThing, tile:getTopMultiUseThing())
end
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
g_game.useWith(selectedThing, clickedWidget:getItem())
elseif clickedWidget:getClassName() == 'UICreatureButton' then
local creature = clickedWidget:getCreature()
if creature then
g_game.useWith(selectedThing, creature)
end
end
end
function onTradeWith(clickedWidget, mousePosition)
if clickedWidget:getClassName() == 'UIMap' then
local tile = clickedWidget:getTile(mousePosition)
if tile then
g_game.requestTrade(selectedThing, tile:getTopCreature())
end
end
end
function startUseWith(thing)
if not thing then return end
if g_ui.isMouseGrabbed() then
if selectedThing then
selectedThing = thing
selectedType = 'use'
end
return
end
selectedType = 'use'
selectedThing = thing
mouseGrabberWidget:grabMouse()
g_mouse.pushCursor('target')
end
function startTradeWith(thing)
if not thing then return end
if g_ui.isMouseGrabbed() then
if selectedThing then
selectedThing = thing
selectedType = 'trade'
end
return
end
selectedType = 'trade'
selectedThing = thing
mouseGrabberWidget:grabMouse()
g_mouse.pushCursor('target')
end
function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
if not g_game.isOnline() then return end
local menu = g_ui.createWidget('PopupMenu')
local classic = modules.client_options.getOption('classicControl')
local shortcut = nil
if not classic then shortcut = '(Shift)' else shortcut = nil end
if lookThing then
menu:addOption(tr('Look'), function() g_game.look(lookThing) end, shortcut)
end
if not classic then shortcut = '(Ctrl)' else shortcut = nil end
if useThing then
if useThing:isContainer() then
if useThing:getParentContainer() then
menu:addOption(tr('Open'), function() g_game.open(useThing, useThing:getParentContainer()) end, shortcut)
menu:addOption(tr('Open in new window'), function() g_game.open(useThing) end)
else
menu:addOption(tr('Open'), function() g_game.open(useThing) end, shortcut)
end
else
if useThing:isMultiUse() then
menu:addOption(tr('Use with ...'), function() startUseWith(useThing) end, shortcut)
else
menu:addOption(tr('Use'), function() g_game.use(useThing) end, shortcut)
end
end
if useThing:isRotateable() then
menu:addOption(tr('Rotate'), function() g_game.rotate(useThing) end)
end
end
if lookThing and not lookThing:isCreature() and not lookThing:isNotMoveable() and lookThing:isPickupable() then
menu:addSeparator()
menu:addOption(tr('Trade with ...'), function() startTradeWith(lookThing) end)
end
if lookThing then
local parentContainer = lookThing:getParentContainer()
if parentContainer and parentContainer:hasParent() then
menu:addOption(tr('Move up'), function() g_game.moveToParentContainer(lookThing, lookThing:getCount()) end)
end
end
if creatureThing then
local localPlayer = g_game.getLocalPlayer()
menu:addSeparator()
if creatureThing:isLocalPlayer() then
menu:addOption(tr('Set Outfit'), function() g_game.requestOutfit() end)
if g_game.getFeature(GamePlayerMounts) then
if not localPlayer:isMounted() then
menu:addOption(tr('Mount'), function() localPlayer:mount() end)
else
menu:addOption(tr('Dismount'), function() localPlayer:dismount() end)
end
end
if creatureThing:isPartyMember() then
if creatureThing:isPartyLeader() then
if creatureThing:isPartySharedExperienceActive() then
menu:addOption(tr('Disable Shared Experience'), function() g_game.partyShareExperience(false) end)
else
menu:addOption(tr('Enable Shared Experience'), function() g_game.partyShareExperience(true) end)
end
end
menu:addOption(tr('Leave Party'), function() g_game.partyLeave() end)
end
else
local localPosition = localPlayer:getPosition()
if not classic then shortcut = '(Alt)' else shortcut = nil end
if creatureThing:getPosition().z == localPosition.z then
if g_game.getAttackingCreature() ~= creatureThing then
menu:addOption(tr('Attack'), function() g_game.attack(creatureThing) end, shortcut)
else
menu:addOption(tr('Stop Attack'), function() g_game.cancelAttack() end, shortcut)
end
if g_game.getFollowingCreature() ~= creatureThing then
menu:addOption(tr('Follow'), function() g_game.follow(creatureThing) end)
else
menu:addOption(tr('Stop Follow'), function() g_game.cancelFollow() end)
end
end
if creatureThing:isPlayer() then
menu:addSeparator()
local creatureName = creatureThing:getName()
menu:addOption(tr('Message to %s', creatureName), function() g_game.openPrivateChannel(creatureName) end)
if modules.game_console.getOwnPrivateTab() then
menu:addOption(tr('Invite to private chat'), function() g_game.inviteToOwnChannel(creatureName) end)
menu:addOption(tr('Exclude from private chat'), function() g_game.excludeFromOwnChannel(creatureName) end) -- [TODO] must be removed after message's popup labels been implemented
end
if not localPlayer:hasVip(creatureName) then
menu:addOption(tr('Add to VIP list'), function() g_game.addVip(creatureName) end)
end
if modules.game_console.isIgnored(creatureName) then
menu:addOption(tr('Unignore') .. ' ' .. creatureName, function() modules.game_console.removeIgnoredPlayer(creatureName) end)
else
menu:addOption(tr('Ignore') .. ' ' .. creatureName, function() modules.game_console.addIgnoredPlayer(creatureName) end)
end
local localPlayerShield = localPlayer:getShield()
local creatureShield = creatureThing:getShield()
if localPlayerShield == ShieldNone or localPlayerShield == ShieldWhiteBlue then
if creatureShield == ShieldWhiteYellow then
menu:addOption(tr('Join %s\'s Party', creatureThing:getName()), function() g_game.partyJoin(creatureThing:getId()) end)
else
menu:addOption(tr('Invite to Party'), function() g_game.partyInvite(creatureThing:getId()) end)
end
elseif localPlayerShield == ShieldWhiteYellow then
if creatureShield == ShieldWhiteBlue then
menu:addOption(tr('Revoke %s\'s Invitation', creatureThing:getName()), function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
end
elseif localPlayerShield == ShieldYellow or localPlayerShield == ShieldYellowSharedExp or localPlayerShield == ShieldYellowNoSharedExpBlink or localPlayerShield == ShieldYellowNoSharedExp then
if creatureShield == ShieldWhiteBlue then
menu:addOption(tr('Revoke %s\'s Invitation', creatureThing:getName()), function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
elseif creatureShield == ShieldBlue or creatureShield == ShieldBlueSharedExp or creatureShield == ShieldBlueNoSharedExpBlink or creatureShield == ShieldBlueNoSharedExp then
menu:addOption(tr('Pass Leadership to %s', creatureThing:getName()), function() g_game.partyPassLeadership(creatureThing:getId()) end)
else
menu:addOption(tr('Invite to Party'), function() g_game.partyInvite(creatureThing:getId()) end)
end
end
end
end
if modules.game_ruleviolation.hasWindowAccess() and creatureThing:isPlayer() then
menu:addSeparator()
menu:addOption(tr('Rule Violation'), function() modules.game_ruleviolation.show(creatureThing:getName()) end)
end
menu:addSeparator()
menu:addOption(tr('Copy Name'), function() g_window.setClipboardText(creatureThing:getName()) end)
end
menu:display(menuPosition)
end
function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing, attackCreature)
local keyboardModifiers = g_keyboard.getModifiers()
if not modules.client_options.getOption('classicControl') then
if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
createThingMenu(menuPosition, lookThing, useThing, creatureThing)
return true
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.look(lookThing)
return true
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
if useThing:isContainer() then
if useThing:getParentContainer() then
g_game.open(useThing, useThing:getParentContainer())
else
g_game.open(useThing)
end
return true
elseif useThing:isMultiUse() then
startUseWith(useThing)
return true
else
g_game.use(useThing)
return true
end
return true
elseif attackCreature and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.attack(attackCreature)
return true
elseif creatureThing and creatureThing:getPosition().z == autoWalkPos.z and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.attack(creatureThing)
return true
end
-- classic control
else
if useThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton and not g_mouse.isPressed(MouseLeftButton) then
local player = g_game.getLocalPlayer()
if attackCreature and attackCreature ~= player then
g_game.attack(attackCreature)
return true
elseif creatureThing and creatureThing ~= player and creatureThing:getPosition().z == autoWalkPos.z then
g_game.attack(creatureThing)
return true
elseif useThing:isContainer() then
if useThing:getParentContainer() then
g_game.open(useThing, useThing:getParentContainer())
return true
else
g_game.open(useThing)
return true
end
elseif useThing:isMultiUse() then
startUseWith(useThing)
return true
else
g_game.use(useThing)
return true
end
return true
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.look(lookThing)
return true
elseif lookThing and ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
g_game.look(lookThing)
return true
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
createThingMenu(menuPosition, lookThing, useThing, creatureThing)
return true
elseif attackCreature and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.attack(attackCreature)
return true
elseif creatureThing and creatureThing:getPosition().z == autoWalkPos.z and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.attack(creatureThing)
return true
end
end
local player = g_game.getLocalPlayer()
player:stopAutoWalk()
if autoWalkPos and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
player:autoWalk(autoWalkPos)
return true
end
return false
end
function moveStackableItem(item, toPos)
if countWindow then
return
end
if g_keyboard.isCtrlPressed() then
g_game.move(item, toPos, item:getCount())
return
elseif g_keyboard.isShiftPressed() then
g_game.move(item, toPos, 1)
return
end
local count = item:getCount()
countWindow = g_ui.createWidget('CountWindow', rootWidget)
local itembox = countWindow:getChildById('item')
local scrollbar = countWindow:getChildById('countScrollBar')
itembox:setItemId(item:getId())
itembox:setItemCount(count)
scrollbar:setMaximum(count)
scrollbar:setMinimum(1)
scrollbar:setValue(count)
local spinbox = countWindow:getChildById('spinBox')
spinbox:setMaximum(count)
spinbox:setMinimum(0)
spinbox:setValue(0)
spinbox:hideButtons()
spinbox:focus()
spinbox.firstEdit = true
local spinBoxValueChange = function(self, value)
spinbox.firstEdit = false
scrollbar:setValue(value)
end
spinbox.onValueChange = spinBoxValueChange
local check = function()
if spinbox.firstEdit then
spinbox:setValue(spinbox:getMaximum())
spinbox.firstEdit = false
end
end
g_keyboard.bindKeyPress("Up", function() check() spinbox:up() end, spinbox)
g_keyboard.bindKeyPress("Down", function() check() spinbox:down() end, spinbox)
g_keyboard.bindKeyPress("Right", function() check() spinbox:up() end, spinbox)
g_keyboard.bindKeyPress("Left", function() check() spinbox:down() end, spinbox)
g_keyboard.bindKeyPress("PageUp", function() check() spinbox:setValue(spinbox:getValue()+10) end, spinbox)
g_keyboard.bindKeyPress("PageDown", function() check() spinbox:setValue(spinbox:getValue()-10) end, spinbox)
scrollbar.onValueChange = function(self, value)
itembox:setItemCount(value)
spinbox.onValueChange = nil
spinbox:setValue(value)
spinbox.onValueChange = spinBoxValueChange
end
local okButton = countWindow:getChildById('buttonOk')
local moveFunc = function()
g_game.move(item, toPos, itembox:getItemCount())
okButton:getParent():destroy()
countWindow = nil
end
local cancelButton = countWindow:getChildById('buttonCancel')
local cancelFunc = function()
cancelButton:getParent():destroy()
countWindow = nil
end
countWindow.onEnter = moveFunc
countWindow.onEscape = cancelFunc
okButton.onClick = moveFunc
cancelButton.onClick = cancelFunc
end
function getRootPanel()
return gameRootPanel
end
function getMapPanel()
return gameMapPanel
end
function getRightPanel()
return gameRightPanel
end
function getLeftPanel()
return gameLeftPanel
end
function getBottomPanel()
return gameBottomPanel
end
function onLeftPanelVisibilityChange(leftPanel, visible)
if not visible and g_game.isOnline() then
local children = leftPanel:getChildren()
for i=1,#children do
children:setParent(gameRightPanel)
end
end
end
function nextViewMode()
setupViewMode((currentViewMode + 1) % 3)
end
function setupViewMode(mode)
if mode == currentViewMode then
gameMapPanel:setKeepAspectRatio(true)
gameMapPanel:setLimitVisibleRange(false)
gameMapPanel:setZoom(11)
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
gameMapPanel:setKeepAspectRatio(false)
gameMapPanel:setLimitVisibleRange(true)
gameMapPanel:setZoom(11)
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
local limit = limitedZoom and not g_game.isGM()
gameMapPanel:setLimitVisibleRange(limit)
gameMapPanel:setZoom(11)
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
gameMapPanel:fill('parent')
gameRootPanel:fill('parent')
gameLeftPanel:setImageColor('alpha')
gameRightPanel:setImageColor('alpha')
gameLeftPanel:setMarginTop(modules.client_topmenu.getTopMenu() :getHeight() - gameLeftPanel:getPaddingTop())
gameRightPanel:setMarginTop(modules.client_topmenu.getTopMenu() :getHeight() - gameRightPanel:getPaddingTop())
gameLeftPanel:setOn(true)
gameLeftPanel:setVisible(true)
gameRightPanel:setOn(true)
gameMapPanel:setOn(true)
gameBottomPanel:setImageColor('#ffffff88')
modules.client_topmenu.getTopMenu():setImageColor('#ffffff66')
if not limit then
g_game.changeMapAwareRange(24, 20)
end
end
currentViewMode = mode
end
function limitZoom()
limitedZoom = true
end

 

 

Entergame:

 

EnterGame = { }

-- private variables
local loadBox
local enterGame
local motdWindow
local motdButton
local enterGameButton
local clientBox
local protocolLogin
local motdEnabled = true
-- private functions
local function onError(protocol, message, errorCode)
if loadBox then
loadBox:destroy()
loadBox = nil
end
if not errorCode then
EnterGame.clearAccountFields()
end
local errorBox = displayErrorBox(tr('Login Error'), message)
connect(errorBox, { onOk = EnterGame.show })
end
local function onMotd(protocol, motd)
G.motdNumber = tonumber(motd:sub(0, motd:find("\n")))
G.motdMessage = motd:sub(motd:find("\n") + 1, #motd)
if motdEnabled then
motdButton:show()
end
end
local function onSessionKey(protocol, sessionKey)
G.sessionKey = sessionKey
end
local function onCharacterList(protocol, characters, account, otui)
-- Try add server to the server list
ServerList.add(G.host, G.port, g_game.getClientVersion())
-- Save 'Stay logged in' setting
g_settings.set('staylogged', enterGame:getChildById('stayLoggedBox'):isChecked())
if enterGame:getChildById('rememberPasswordBox'):isChecked() then
local account = g_crypt.encrypt(G.account)
local password = g_crypt.encrypt(G.password)
g_settings.set('account', account)
g_settings.set('password', password)
ServerList.setServerAccount(G.host, account)
ServerList.setServerPassword(G.host, password)
g_settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
else
-- reset server list account/password
ServerList.setServerAccount(G.host, '')
ServerList.setServerPassword(G.host, '')
EnterGame.clearAccountFields()
end
loadBox:destroy()
loadBox = nil
for _, characterInfo in pairs(characters) do
if characterInfo.previewState and characterInfo.previewState ~= PreviewState.Default then
characterInfo.worldName = characterInfo.worldName .. ', Preview'
end
end
CharacterList.create(characters, account, otui)
CharacterList.show()
if motdEnabled then
local lastMotdNumber = g_settings.getNumber("motd")
if G.motdNumber and G.motdNumber ~= lastMotdNumber then
g_settings.set("motd", motdNumber)
motdWindow = displayInfoBox(tr('Message of the day'), G.motdMessage)
connect(motdWindow, { onOk = function() CharacterList.show() motdWindow = nil end })
CharacterList.hide()
end
end
end
local function onUpdateNeeded(protocol, signature)
loadBox:destroy()
loadBox = nil
if EnterGame.updateFunc then
local continueFunc = EnterGame.show
local cancelFunc = EnterGame.show
EnterGame.updateFunc(signature, continueFunc, cancelFunc)
else
local errorBox = displayErrorBox(tr('Update needed'), tr('Your client needs updating, try redownloading it.'))
connect(errorBox, { onOk = EnterGame.show })
end
end
-- public functions
function EnterGame.init()
enterGame = g_ui.displayUI('entergame')
enterGameButton = modules.client_topmenu.addLeftButton('enterGameButton', tr('Login') .. ' (Ctrl + G)', '/images/topbuttons/login', EnterGame.openWindow)
motdButton = modules.client_topmenu.addLeftButton('motdButton', tr('Message of the day'), '/images/topbuttons/motd', EnterGame.displayMotd)
motdButton:hide()
g_keyboard.bindKeyDown('Ctrl+G', EnterGame.openWindow)
if motdEnabled and G.motdNumber then
motdButton:show()
end
local account = g_settings.get('account')
local password = g_settings.get('password')
local host = g_settings.get('host')
local port = g_settings.get('port')
local stayLogged = g_settings.getBoolean('staylogged')
local autologin = g_settings.getBoolean('autologin')
local clientVersion = g_settings.getInteger('client-version')
if clientVersion == 0 then clientVersion = 1074 end
if port == nil or port == 0 then port = 7171 end
EnterGame.setAccountName(account)
EnterGame.setPassword(password)
enterGame:getChildById('serverHostTextEdit'):setText(host)
enterGame:getChildById('serverPortTextEdit'):setText(port)
enterGame:getChildById('autoLoginBox'):setChecked(autologin)
enterGame:getChildById('stayLoggedBox'):setChecked(stayLogged)
clientBox = enterGame:getChildById('clientComboBox')
for _, proto in pairs(g_game.getSupportedClients()) do
clientBox:addOption(proto)
end
clientBox:setCurrentOption(clientVersion)
EnterGame.toggleAuthenticatorToken(clientVersion, true)
EnterGame.toggleStayLoggedBox(clientVersion, true)
connect(clientBox, { onOptionChange = EnterGame.onClientVersionChange })
enterGame:hide()
if g_app.isRunning() and not g_game.isOnline() then
enterGame:show()
end
end
function EnterGame.firstShow()
EnterGame.show()
local account = g_crypt.decrypt(g_settings.get('account'))
local password = g_crypt.decrypt(g_settings.get('password'))
local host = g_settings.get('host')
local autologin = g_settings.getBoolean('autologin')
if #host > 0 and #password > 0 and #account > 0 and autologin then
addEvent(function()
if not g_settings.getBoolean('autologin') then return end
EnterGame.doLogin()
end)
end
end
function EnterGame.terminate()
g_keyboard.unbindKeyDown('Ctrl+G')
disconnect(clientBox, { onOptionChange = EnterGame.onClientVersionChange })
enterGame:destroy()
enterGame = nil
enterGameButton:destroy()
enterGameButton = nil
clientBox = nil
if motdWindow then
motdWindow:destroy()
motdWindow = nil
end
if motdButton then
motdButton:destroy()
motdButton = nil
end
if loadBox then
loadBox:destroy()
loadBox = nil
end
if protocolLogin then
protocolLogin:cancelLogin()
protocolLogin = nil
end
EnterGame = nil
end
function EnterGame.show()
if loadBox then return end
enterGame:show()
enterGame:raise()
enterGame:focus()
end
function EnterGame.hide()
enterGame:hide()
end
function EnterGame.openWindow()
if g_game.isOnline() then
CharacterList.show()
elseif not g_game.isLogging() and not CharacterList.isVisible() then
EnterGame.show()
end
end
function EnterGame.setAccountName(account)
local account = g_crypt.decrypt(account)
enterGame:getChildById('accountNameTextEdit'):setText(account)
enterGame:getChildById('accountNameTextEdit'):setCursorPos(-1)
enterGame:getChildById('rememberPasswordBox'):setChecked(#account > 0)
end
function EnterGame.setPassword(password)
local password = g_crypt.decrypt(password)
enterGame:getChildById('accountPasswordTextEdit'):setText(password)
end
function EnterGame.clearAccountFields()
enterGame:getChildById('accountNameTextEdit'):clearText()
enterGame:getChildById('accountPasswordTextEdit'):clearText()
enterGame:getChildById('authenticatorTokenTextEdit'):clearText()
enterGame:getChildById('accountNameTextEdit'):focus()
g_settings.remove('account')
g_settings.remove('password')
end
function EnterGame.toggleAuthenticatorToken(clientVersion, init)
local enabled = (clientVersion >= 1072)
if enabled == enterGame.authenticatorEnabled then
return
end
enterGame:getChildById('authenticatorTokenLabel'):setOn(enabled)
enterGame:getChildById('authenticatorTokenTextEdit'):setOn(enabled)
local newHeight = enterGame:getHeight()
local newY = enterGame:getY()
if enabled then
newY = newY - enterGame.authenticatorHeight
newHeight = newHeight + enterGame.authenticatorHeight
else
newY = newY + enterGame.authenticatorHeight
newHeight = newHeight - enterGame.authenticatorHeight
end
if not init then
enterGame:breakAnchors()
enterGame:setY(newY)
enterGame:bindRectToParent()
end
enterGame:setHeight(newHeight)
enterGame.authenticatorEnabled = enabled
end
function EnterGame.toggleStayLoggedBox(clientVersion, init)
local enabled = (clientVersion >= 1074)
if enabled == enterGame.stayLoggedBoxEnabled then
return
end
enterGame:getChildById('stayLoggedBox'):setOn(enabled)
local newHeight = enterGame:getHeight()
local newY = enterGame:getY()
if enabled then
newY = newY - enterGame.stayLoggedBoxHeight
newHeight = newHeight + enterGame.stayLoggedBoxHeight
else
newY = newY + enterGame.stayLoggedBoxHeight
newHeight = newHeight - enterGame.stayLoggedBoxHeight
end
if not init then
enterGame:breakAnchors()
enterGame:setY(newY)
enterGame:bindRectToParent()
end
enterGame:setHeight(newHeight)
enterGame.stayLoggedBoxEnabled = enabled
end
function EnterGame.onClientVersionChange(comboBox, text, data)
local clientVersion = tonumber(text)
EnterGame.toggleAuthenticatorToken(clientVersion)
EnterGame.toggleStayLoggedBox(clientVersion)
end
function EnterGame.doLogin()
G.account = enterGame:getChildById('accountNameTextEdit'):getText()
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
G.authenticatorToken = enterGame:getChildById('authenticatorTokenTextEdit'):getText()
G.stayLogged = enterGame:getChildById('stayLoggedBox'):isChecked()
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
local clientVersion = tonumber(clientBox:getText())
EnterGame.hide()
if g_game.isOnline() then
local errorBox = displayErrorBox(tr('Login Error'), tr('Cannot login while already in game.'))
connect(errorBox, { onOk = EnterGame.show })
return
end
g_settings.set('host', G.host)
g_settings.set('port', G.port)
g_settings.set('client-version', clientVersion)
protocolLogin = ProtocolLogin.create()
protocolLogin.onLoginError = onError
protocolLogin.onMotd = onMotd
protocolLogin.onSessionKey = onSessionKey
protocolLogin.onCharacterList = onCharacterList
protocolLogin.onUpdateNeeded = onUpdateNeeded
loadBox = displayCancelBox(tr('Please wait'), tr('Connecting to login server...'))
connect(loadBox, { onCancel = function(msgbox)
loadBox = nil
protocolLogin:cancelLogin()
EnterGame.show()
end })
g_game.setClientVersion(clientVersion)
g_game.setProtocolVersion(g_game.getClientProtocolVersion(clientVersion))
g_game.chooseRsa(G.host)
if modules.game_things.isLoaded() then
protocolLogin:login(G.host, G.port, G.account, G.password, G.authenticatorToken, G.stayLogged)
else
loadBox:destroy()
loadBox = nil
EnterGame.show()
end
end
function EnterGame.displayMotd()
if not motdWindow then
motdWindow = displayInfoBox(tr('Message of the day'), G.motdMessage)
motdWindow.onOk = function() motdWindow = nil end
end
end
function EnterGame.setDefaultServer(host, port, protocol)
local hostTextEdit = enterGame:getChildById('serverHostTextEdit')
local portTextEdit = enterGame:getChildById('serverPortTextEdit')
local clientLabel = enterGame:getChildById('clientLabel')
local accountTextEdit = enterGame:getChildById('accountNameTextEdit')
local passwordTextEdit = enterGame:getChildById('accountPasswordTextEdit')
local authenticatorTokenTextEdit = enterGame:getChildById('authenticatorTokenTextEdit')
if hostTextEdit:getText() ~= host then
hostTextEdit:setText(host)
portTextEdit:setText(port)
clientBox:setCurrentOption(protocol)
accountTextEdit:setText('')
passwordTextEdit:setText('')
authenticatorTokenTextEdit:setText('')
end
end
function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeight)
local hostTextEdit = enterGame:getChildById('serverHostTextEdit')
hostTextEdit:setText(host)
hostTextEdit:setVisible(false)
hostTextEdit:setHeight(0)
local portTextEdit = enterGame:getChildById('serverPortTextEdit')
portTextEdit:setText(port)
portTextEdit:setVisible(false)
portTextEdit:setHeight(0)
local authenticatorTokenTextEdit = enterGame:getChildById('authenticatorTokenTextEdit')
authenticatorTokenTextEdit:setText('')
authenticatorTokenTextEdit:setOn(false)
local authenticatorTokenLabel = enterGame:getChildById('authenticatorTokenLabel')
authenticatorTokenLabel:setOn(false)
local stayLoggedBox = enterGame:getChildById('stayLoggedBox')
stayLoggedBox:setChecked(false)
stayLoggedBox:setOn(false)
clientBox:setCurrentOption(protocol)
clientBox:setVisible(false)
clientBox:setHeight(0)
local serverLabel = enterGame:getChildById('serverLabel')
serverLabel:setVisible(false)
serverLabel:setHeight(0)
local portLabel = enterGame:getChildById('portLabel')
portLabel:setVisible(false)
portLabel:setHeight(0)
local clientLabel = enterGame:getChildById('clientLabel')
clientLabel:setVisible(false)
clientLabel:setHeight(0)
local serverListButton = enterGame:getChildById('serverListButton')
serverListButton:setVisible(false)
serverListButton:setHeight(0)
serverListButton:setWidth(0)
local rememberPasswordBox = enterGame:getChildById('rememberPasswordBox')
rememberPasswordBox:setMarginTop(-8)
if not windowWidth then windowWidth = 236 end
enterGame:setWidth(windowWidth)
if not windowHeight then windowHeight = 210 end
enterGame:setHeight(windowHeight)
end
function EnterGame.setServerInfo(message)
local label = enterGame:getChildById('serverInfoLabel')
label:setText(message)
end
function EnterGame.disableMotd()
motdEnabled = false
motdButton:hide()
end

 

Editado por lucasguzella
Link para o comentário
Compartilhar em outros sites

  • 0

A 1ª alteração, troque o seu gameinterface.lua por esse. Deve resolver o problema.

 

WALK_STEPS_RETRY = 10

gameRootPanel = nil
gameMapPanel = nil
gameRightPanel = nil
gameLeftPanel = nil
gameBottomPanel = nil
logoutButton = nil
mouseGrabberWidget = nil
countWindow = nil
logoutWindow = nil
exitWindow = nil
bottomSplitter = nil
limitedZoom = false
currentViewMode = 0
smartWalkDirs = {}
smartWalkDir = nil
walkFunction = nil
hookedMenuOptions = {}

function init()
g_ui.importStyle('styles/countwindow')

connect(g_game, {
onGameStart = onGameStart,
onGameEnd = onGameEnd,
onLoginAdvice = onLoginAdvice,
}, true)

-- Call load AFTER game window has been created and
-- resized to a stable state, otherwise the saved
-- settings can get overridden by false onGeometryChange
-- events
connect(g_app, {
onRun = load,
onExit = save
})

gameRootPanel = g_ui.displayUI('gameinterface')
gameRootPanel:hide()
gameRootPanel:lower()
gameRootPanel.onGeometryChange = updateStretchShrink
gameRootPanel.onFocusChange = stopSmartWalk

mouseGrabberWidget = gameRootPanel:getChildById('mouseGrabber')
mouseGrabberWidget.onMouseRelease = onMouseGrabberRelease

bottomSplitter = gameRootPanel:getChildById('bottomSplitter')
gameMapPanel = gameRootPanel:getChildById('gameMapPanel')
gameRightPanel = gameRootPanel:getChildById('gameRightPanel')
gameLeftPanel = gameRootPanel:getChildById('gameLeftPanel')
gameBottomPanel = gameRootPanel:getChildById('gameBottomPanel')
connect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })

logoutButton = modules.client_topmenu.addLeftButton('logoutButton', tr('Exit'),
'/images/topbuttons/logout', tryLogout, true)

setupViewMode(currentViewMode+1)

bindKeys()

if g_game.isOnline() then
show()
end
end

function bindKeys()
gameRootPanel:setAutoRepeatDelay(200)

bindWalkKey('Up', North)
bindWalkKey('Right', East)
bindWalkKey('Down', South)
bindWalkKey('Left', West)
bindWalkKey('Numpad8', North)
bindWalkKey('Numpad9', NorthEast)
bindWalkKey('Numpad6', East)
bindWalkKey('Numpad3', SouthEast)
bindWalkKey('Numpad2', South)
bindWalkKey('Numpad1', SouthWest)
bindWalkKey('Numpad4', West)
bindWalkKey('Numpad7', NorthWest)

g_keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Down', function() g_game.turn(South) changeWalkDir(South) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Left', function() g_game.turn(West) changeWalkDir(West) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Numpad8', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Numpad6', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Numpad2', function() g_game.turn(South) changeWalkDir(South) end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+Numpad4', function() g_game.turn(West) changeWalkDir(West) end, gameRootPanel)
g_keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+=', function() gameMapPanel:zoomIn() end, gameRootPanel)
g_keyboard.bindKeyPress('Ctrl+-', function() gameMapPanel:zoomOut() end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+Q', function() tryLogout(false) end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+L', function() tryLogout(false) end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+W', function() g_map.cleanTexts() modules.game_textmessage.clearMessages() end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+.', nextViewMode, gameRootPanel)
end

function bindWalkKey(key, dir)
g_keyboard.bindKeyDown(key, function() changeWalkDir(dir) end, gameRootPanel, true)
g_keyboard.bindKeyUp(key, function() changeWalkDir(dir, true) end, gameRootPanel, true)
g_keyboard.bindKeyPress(key, function() smartWalk(dir) end, gameRootPanel)
end

function unbindWalkKey(key)
g_keyboard.unbindKeyDown(key, gameRootPanel)
g_keyboard.unbindKeyUp(key, gameRootPanel)
g_keyboard.unbindKeyPress(key, gameRootPanel)
end

function terminate()
hide()

hookedMenuOptions = {}

stopSmartWalk()

disconnect(g_game, {
onGameStart = onGameStart,
onGameEnd = onGameEnd,
onLoginAdvice = onLoginAdvice
})

disconnect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })

logoutButton:destroy()
gameRootPanel:destroy()
end

function onGameStart()
show()

-- open tibia has delay in auto walking
if not g_game.isOfficialTibia() then
g_game.enableFeature(GameForceFirstAutoWalkStep)
else
g_game.disableFeature(GameForceFirstAutoWalkStep)
end
end

function onGameEnd()
setupViewMode(0)
hide()
end

function show()
connect(g_app, { onClose = tryExit })
modules.client_background.hide()
gameRootPanel:show()
gameRootPanel:focus()
gameMapPanel:followCreature(g_game.getLocalPlayer())
setupViewMode(currentViewMode+1)
updateStretchShrink()
logoutButton:setTooltip(tr('Logout'))

addEvent(function()
if not limitedZoom or g_game.isGM() then
gameMapPanel:setMaxZoomOut(513)
gameMapPanel:setLimitVisibleRange(false)
else
gameMapPanel:setMaxZoomOut(11)
gameMapPanel:setLimitVisibleRange(true)
end
end)
end

function hide()
disconnect(g_app, { onClose = tryExit })
logoutButton:setTooltip(tr('Exit'))

if logoutWindow then
logoutWindow:destroy()
logoutWindow = nil
end
if exitWindow then
exitWindow:destroy()
exitWindow = nil
end
if countWindow then
countWindow:destroy()
countWindow = nil
end
gameRootPanel:hide()
modules.client_background.show()
end

function save()
local settings = {}
settings.splitterMarginBottom = bottomSplitter:getMarginBottom()
g_settings.setNode('game_interface', settings)
end

function load()
local settings = g_settings.getNode('game_interface')
if settings then
if settings.splitterMarginBottom then
bottomSplitter:setMarginBottom(settings.splitterMarginBottom)
end
end
end

function onLoginAdvice(message)
displayInfoBox(tr("For Your Information"), message)
end

function forceExit()
g_game.cancelLogin()
scheduleEvent(exit, 10)
return true
end

function tryExit()
if exitWindow then
return true
end

local exitFunc = function() g_game.safeLogout() forceExit() end
local logoutFunc = function() g_game.safeLogout() exitWindow:destroy() exitWindow = nil end
local cancelFunc = function() exitWindow:destroy() exitWindow = nil end

exitWindow = displayGeneralBox(tr('Exit'), tr("If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character."),
{ { text=tr('Force Exit'), callback=exitFunc },
{ text=tr('Logout'), callback=logoutFunc },
{ text=tr('Cancel'), callback=cancelFunc },
anchor=AnchorHorizontalCenter }, logoutFunc, cancelFunc)

return true
end

function tryLogout(prompt)
if type(prompt) ~= "boolean" then
prompt = true
end
if not g_game.isOnline() then
exit()
return
end

if logoutWindow then
return
end

local msg, yesCallback
if not g_game.isConnectionOk() then
msg = 'Your connection is failing, if you logout now your character will be still online, do you want to force logout?'

yesCallback = function()
g_game.forceLogout()
if logoutWindow then
logoutWindow:destroy()
logoutWindow=nil
end
end
else
msg = 'Are you sure you want to logout?'

yesCallback = function()
g_game.safeLogout()
if logoutWindow then
logoutWindow:destroy()
logoutWindow=nil
end
end
end

local noCallback = function()
logoutWindow:destroy()
logoutWindow=nil
end

if prompt then
logoutWindow = displayGeneralBox(tr('Logout'), tr(msg), {
{ text=tr('Yes'), callback=yesCallback },
{ text=tr('No'), callback=noCallback },
anchor=AnchorHorizontalCenter}, yesCallback, noCallback)
else
yesCallback()
end
end

function stopSmartWalk()
smartWalkDirs = {}
smartWalkDir = nil
end

function changeWalkDir(dir, pop)
while table.removevalue(smartWalkDirs, dir) do end
if pop then
if #smartWalkDirs == 0 then
stopSmartWalk()
return
end
else
table.insert(smartWalkDirs, 1, dir)
end

smartWalkDir = smartWalkDirs[1]
if modules.client_options.getOption('smartWalk') and #smartWalkDirs > 1 then
for _,d in pairs(smartWalkDirs) do
if (smartWalkDir == North and d == West) or (smartWalkDir == West and d == North) then
smartWalkDir = NorthWest
break
elseif (smartWalkDir == North and d == East) or (smartWalkDir == East and d == North) then
smartWalkDir = NorthEast
break
elseif (smartWalkDir == South and d == West) or (smartWalkDir == West and d == South) then
smartWalkDir = SouthWest
break
elseif (smartWalkDir == South and d == East) or (smartWalkDir == East and d == South) then
smartWalkDir = SouthEast
break
end
end
end
end

function smartWalk(dir)
if g_keyboard.getModifiers() == KeyboardNoModifier then
local func = walkFunction
if not func then
if modules.client_options.getOption('dashWalk') then
func = g_game.dashWalk
else
func = g_game.walk
end
end
local dire = smartWalkDir or dir
func(dire)
return true
end
return false
end

function updateStretchShrink()
if modules.client_options.getOption('dontStretchShrink') and not alternativeView then
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })

-- Set gameMapPanel size to height = 11 * 32 + 2
bottomSplitter:setMarginBottom(bottomSplitter:getMarginBottom() + (gameMapPanel:getHeight() - 32 * 11) - 10)
end
end

function onMouseGrabberRelease(self, mousePosition, mouseButton)
if selectedThing == nil then return false end
if mouseButton == MouseLeftButton then
local clickedWidget = gameRootPanel:recursiveGetChildByPos(mousePosition, false)
if clickedWidget then
if selectedType == 'use' then
onUseWith(clickedWidget, mousePosition)
elseif selectedType == 'trade' then
onTradeWith(clickedWidget, mousePosition)
end
end
end

selectedThing = nil
g_mouse.popCursor('target')
self:ungrabMouse()
return true
end

function onUseWith(clickedWidget, mousePosition)
if clickedWidget:getClassName() == 'UIGameMap' then
local tile = clickedWidget:getTile(mousePosition)
if tile then
if selectedThing:isFluidContainer() or selectedThing:isMultiUse() then
g_game.useWith(selectedThing, tile:getTopMultiUseThing())
else
g_game.useWith(selectedThing, tile:getTopUseThing())
end
end
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
g_game.useWith(selectedThing, clickedWidget:getItem())
elseif clickedWidget:getClassName() == 'UICreatureButton' then
local creature = clickedWidget:getCreature()
if creature then
g_game.useWith(selectedThing, creature)
end
end
end

function onTradeWith(clickedWidget, mousePosition)
if clickedWidget:getClassName() == 'UIGameMap' then
local tile = clickedWidget:getTile(mousePosition)
if tile then
g_game.requestTrade(selectedThing, tile:getTopCreature())
end
end
end

function startUseWith(thing)
if not thing then return end
if g_ui.isMouseGrabbed() then
if selectedThing then
selectedThing = thing
selectedType = 'use'
end
return
end
selectedType = 'use'
selectedThing = thing
mouseGrabberWidget:grabMouse()
g_mouse.pushCursor('target')
end

function startTradeWith(thing)
if not thing then return end
if g_ui.isMouseGrabbed() then
if selectedThing then
selectedThing = thing
selectedType = 'trade'
end
return
end
selectedType = 'trade'
selectedThing = thing
mouseGrabberWidget:grabMouse()
g_mouse.pushCursor('target')
end

function isMenuHookCategoryEmpty(category)
if category then
for _,opt in pairs(category) do
if opt then return false end
end
end
return true
end

function addMenuHook(category, name, callback, condition, shortcut)
if not hookedMenuOptions[category] then
hookedMenuOptions[category] = {}
end
hookedMenuOptions[category][name] = {
callback = callback,
condition = condition,
shortcut = shortcut
}
end

function removeMenuHook(category, name)
if not name then
hookedMenuOptions[category] = {}
else
hookedMenuOptions[category][name] = nil
end
end

function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
if not g_game.isOnline() then return end

local menu = g_ui.createWidget('PopupMenu')
menu:setGameMenu(true)

local classic = modules.client_options.getOption('classicControl')
local shortcut = nil

if not classic then shortcut = '(Shift)' else shortcut = nil end
if lookThing then
menu:addOption(tr('Look'), function() g_game.look(lookThing) end, shortcut)
end

if not classic then shortcut = '(Ctrl)' else shortcut = nil end
if useThing then
if useThing:isContainer() then
if useThing:getParentContainer() then
menu:addOption(tr('Open'), function() g_game.open(useThing, useThing:getParentContainer()) end, shortcut)
menu:addOption(tr('Open in new window'), function() g_game.open(useThing) end)
else
menu:addOption(tr('Open'), function() g_game.open(useThing) end, shortcut)
end
else
if useThing:isMultiUse() then
menu:addOption(tr('Use with ...'), function() startUseWith(useThing) end, shortcut)
else
menu:addOption(tr('Use'), function() g_game.use(useThing) end, shortcut)
end
end

if useThing:isRotateable() then
menu:addOption(tr('Rotate'), function() g_game.rotate(useThing) end)
end

if g_game.getFeature(GameBrowseField) and useThing:getPosition().x ~= 0xffff then
menu:addOption(tr('Browse Field'), function() g_game.browseField(useThing:getPosition()) end)
end
end

if lookThing and not lookThing:isCreature() and not lookThing:isNotMoveable() and lookThing:isPickupable() then
menu:addSeparator()
menu:addOption(tr('Trade with ...'), function() startTradeWith(lookThing) end)
end

if lookThing then
local parentContainer = lookThing:getParentContainer()
if parentContainer and parentContainer:hasParent() then
menu:addOption(tr('Move up'), function() g_game.moveToParentContainer(lookThing, lookThing:getCount()) end)
end
end

if creatureThing then
local localPlayer = g_game.getLocalPlayer()
menu:addSeparator()

if creatureThing:isLocalPlayer() then
menu:addOption(tr('Set Outfit'), function() g_game.requestOutfit() end)

if g_game.getFeature(GamePlayerMounts) then
if not localPlayer:isMounted() then
menu:addOption(tr('Mount'), function() localPlayer:mount() end)
else
menu:addOption(tr('Dismount'), function() localPlayer:dismount() end)
end
end

if creatureThing:isPartyMember() then
if creatureThing:isPartyLeader() then
if creatureThing:isPartySharedExperienceActive() then
menu:addOption(tr('Disable Shared Experience'), function() g_game.partyShareExperience(false) end)
else
menu:addOption(tr('Enable Shared Experience'), function() g_game.partyShareExperience(true) end)
end
end
menu:addOption(tr('Leave Party'), function() g_game.partyLeave() end)
end

else
local localPosition = localPlayer:getPosition()
if not classic then shortcut = '(Alt)' else shortcut = nil end
if creatureThing:getPosition().z == localPosition.z then
if g_game.getAttackingCreature() ~= creatureThing then
menu:addOption(tr('Attack'), function() g_game.attack(creatureThing) end, shortcut)
else
menu:addOption(tr('Stop Attack'), function() g_game.cancelAttack() end, shortcut)
end

if g_game.getFollowingCreature() ~= creatureThing then
menu:addOption(tr('Follow'), function() g_game.follow(creatureThing) end)
else
menu:addOption(tr('Stop Follow'), function() g_game.cancelFollow() end)
end
end

if creatureThing:isPlayer() then
menu:addSeparator()
local creatureName = creatureThing:getName()
menu:addOption(tr('Message to %s', creatureName), function() g_game.openPrivateChannel(creatureName) end)
if modules.game_console.getOwnPrivateTab() then
menu:addOption(tr('Invite to private chat'), function() g_game.inviteToOwnChannel(creatureName) end)
menu:addOption(tr('Exclude from private chat'), function() g_game.excludeFromOwnChannel(creatureName) end) -- [TODO] must be removed after message's popup labels been implemented
end
if not localPlayer:hasVip(creatureName) then
menu:addOption(tr('Add to VIP list'), function() g_game.addVip(creatureName) end)
end

if modules.game_console.isIgnored(creatureName) then
menu:addOption(tr('Unignore') .. ' ' .. creatureName, function() modules.game_console.removeIgnoredPlayer(creatureName) end)
else
menu:addOption(tr('Ignore') .. ' ' .. creatureName, function() modules.game_console.addIgnoredPlayer(creatureName) end)
end

local localPlayerShield = localPlayer:getShield()
local creatureShield = creatureThing:getShield()

if localPlayerShield == ShieldNone or localPlayerShield == ShieldWhiteBlue then
if creatureShield == ShieldWhiteYellow then
menu:addOption(tr('Join %s\'s Party', creatureThing:getName()), function() g_game.partyJoin(creatureThing:getId()) end)
else
menu:addOption(tr('Invite to Party'), function() g_game.partyInvite(creatureThing:getId()) end)
end
elseif localPlayerShield == ShieldWhiteYellow then
if creatureShield == ShieldWhiteBlue then
menu:addOption(tr('Revoke %s\'s Invitation', creatureThing:getName()), function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
end
elseif localPlayerShield == ShieldYellow or localPlayerShield == ShieldYellowSharedExp or localPlayerShield == ShieldYellowNoSharedExpBlink or localPlayerShield == ShieldYellowNoSharedExp then
if creatureShield == ShieldWhiteBlue then
menu:addOption(tr('Revoke %s\'s Invitation', creatureThing:getName()), function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
elseif creatureShield == ShieldBlue or creatureShield == ShieldBlueSharedExp or creatureShield == ShieldBlueNoSharedExpBlink or creatureShield == ShieldBlueNoSharedExp then
menu:addOption(tr('Pass Leadership to %s', creatureThing:getName()), function() g_game.partyPassLeadership(creatureThing:getId()) end)
else
menu:addOption(tr('Invite to Party'), function() g_game.partyInvite(creatureThing:getId()) end)
end
end
end
end

if modules.game_ruleviolation.hasWindowAccess() and creatureThing:isPlayer() then
menu:addSeparator()
menu:addOption(tr('Rule Violation'), function() modules.game_ruleviolation.show(creatureThing:getName()) end)
end

menu:addSeparator()
menu:addOption(tr('Copy Name'), function() g_window.setClipboardText(creatureThing:getName()) end)
end

-- hooked menu options
for _,category in pairs(hookedMenuOptions) do
if not isMenuHookCategoryEmpty(category) then
menu:addSeparator()
for name,opt in pairs(category) do
if opt and opt.condition(menuPosition, lookThing, useThing, creatureThing) then
menu:addOption(name, function() opt.callback(menuPosition,
lookThing, useThing, creatureThing) end, opt.shortcut)
end
end
end
end

menu:display(menuPosition)
end

function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing, attackCreature)
local keyboardModifiers = g_keyboard.getModifiers()

if not modules.client_options.getOption('classicControl') then
if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
createThingMenu(menuPosition, lookThing, useThing, creatureThing)
return true
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.look(lookThing)
return true
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
if useThing:isContainer() then
if useThing:getParentContainer() then
g_game.open(useThing, useThing:getParentContainer())
else
g_game.open(useThing)
end
return true
elseif useThing:isMultiUse() then
startUseWith(useThing)
return true
else
g_game.use(useThing)
return true
end
return true
elseif attackCreature and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.attack(attackCreature)
return true
elseif creatureThing and creatureThing:getPosition().z == autoWalkPos.z and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.attack(creatureThing)
return true
end

-- classic control
else
if useThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton and not g_mouse.isPressed(MouseLeftButton) then
local player = g_game.getLocalPlayer()
if attackCreature and attackCreature ~= player then
g_game.attack(attackCreature)
return true
elseif creatureThing and creatureThing ~= player and creatureThing:getPosition().z == autoWalkPos.z then
g_game.attack(creatureThing)
return true
elseif useThing:isContainer() then
if useThing:getParentContainer() then
g_game.open(useThing, useThing:getParentContainer())
return true
else
g_game.open(useThing)
return true
end
elseif useThing:isMultiUse() then
startUseWith(useThing)
return true
else
g_game.use(useThing)
return true
end
return true
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.look(lookThing)
return true
elseif lookThing and ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
g_game.look(lookThing)
return true
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
createThingMenu(menuPosition, lookThing, useThing, creatureThing)
return true
elseif attackCreature and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.attack(attackCreature)
return true
elseif creatureThing and creatureThing:getPosition().z == autoWalkPos.z and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
g_game.attack(creatureThing)
return true
end
end


local player = g_game.getLocalPlayer()
player:stopAutoWalk()

if autoWalkPos and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
player:autoWalk(autoWalkPos)
return true
end

return false
end

function moveStackableItem(item, toPos)
if countWindow then
return
end
if g_keyboard.isCtrlPressed() then
g_game.move(item, toPos, item:getCount())
return
elseif g_keyboard.isShiftPressed() then
g_game.move(item, toPos, 1)
return
end
local count = item:getCount()

countWindow = g_ui.createWidget('CountWindow', rootWidget)
local itembox = countWindow:getChildById('item')
local scrollbar = countWindow:getChildById('countScrollBar')
itembox:setItemId(item:getId())
itembox:setItemCount(count)
scrollbar:setMaximum(count)
scrollbar:setMinimum(1)
scrollbar:setValue(count)

local spinbox = countWindow:getChildById('spinBox')
spinbox:setMaximum(count)
spinbox:setMinimum(0)
spinbox:setValue(0)
spinbox:hideButtons()
spinbox:focus()
spinbox.firstEdit = true

local spinBoxValueChange = function(self, value)
spinbox.firstEdit = false
scrollbar:setValue(value)
end
spinbox.onValueChange = spinBoxValueChange

local check = function()
if spinbox.firstEdit then
spinbox:setValue(spinbox:getMaximum())
spinbox.firstEdit = false
end
end
g_keyboard.bindKeyPress("Up", function() check() spinbox:up() end, spinbox)
g_keyboard.bindKeyPress("Down", function() check() spinbox:down() end, spinbox)
g_keyboard.bindKeyPress("Right", function() check() spinbox:up() end, spinbox)
g_keyboard.bindKeyPress("Left", function() check() spinbox:down() end, spinbox)
g_keyboard.bindKeyPress("PageUp", function() check() spinbox:setValue(spinbox:getValue()+10) end, spinbox)
g_keyboard.bindKeyPress("PageDown", function() check() spinbox:setValue(spinbox:getValue()-10) end, spinbox)

scrollbar.onValueChange = function(self, value)
itembox:setItemCount(value)
spinbox.onValueChange = nil
spinbox:setValue(value)
spinbox.onValueChange = spinBoxValueChange
end

local okButton = countWindow:getChildById('buttonOk')
local moveFunc = function()
g_game.move(item, toPos, itembox:getItemCount())
okButton:getParent():destroy()
countWindow = nil
end
local cancelButton = countWindow:getChildById('buttonCancel')
local cancelFunc = function()
cancelButton:getParent():destroy()
countWindow = nil
end

countWindow.onEnter = moveFunc
countWindow.onEscape = cancelFunc

okButton.onClick = moveFunc
cancelButton.onClick = cancelFunc
end

function getRootPanel()
return gameRootPanel
end

function getMapPanel()
return gameMapPanel
end

function getRightPanel()
return gameRightPanel
end

function getLeftPanel()
return gameLeftPanel
end

function getBottomPanel()
return gameBottomPanel
end

function onLeftPanelVisibilityChange(leftPanel, visible)
if not visible and g_game.isOnline() then
local children = leftPanel:getChildren()
for i=1,#children do
children:setParent(gameRightPanel)
end
end
end

function nextViewMode()
setupViewMode((currentViewMode + 1) % 3)
end

function setupViewMode(mode)
if mode == currentViewMode then return end

if currentViewMode == 2 then
gameMapPanel:addAnchor(AnchorLeft, 'gameLeftPanel', AnchorRight)
gameMapPanel:addAnchor(AnchorRight, 'gameRightPanel', AnchorLeft)
gameMapPanel:addAnchor(AnchorBottom, 'gameBottomPanel', AnchorTop)
gameRootPanel:addAnchor(AnchorTop, 'topMenu', AnchorBottom)
gameLeftPanel:setOn(modules.client_options.getOption('showLeftPanel'))
gameLeftPanel:setImageColor('white')
gameRightPanel:setImageColor('white')
gameLeftPanel:setMarginTop(0)
gameRightPanel:setMarginTop(0)
gameBottomPanel:setImageColor('white')
modules.client_topmenu.getTopMenu():setImageColor('white')
g_game.changeMapAwareRange(18, 14)
end

if mode == 0 then
gameMapPanel:setKeepAspectRatio(true)
gameMapPanel:setLimitVisibleRange(false)
gameMapPanel:setZoom(11)
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
elseif mode == 1 then
gameMapPanel:setKeepAspectRatio(false)
gameMapPanel:setLimitVisibleRange(true)
gameMapPanel:setZoom(11)
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
elseif mode == 2 then
local limit = limitedZoom and not g_game.isGM()
gameMapPanel:setLimitVisibleRange(limit)
gameMapPanel:setZoom(11)
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
gameMapPanel:fill('parent')
gameRootPanel:fill('parent')
gameLeftPanel:setImageColor('alpha')
gameRightPanel:setImageColor('alpha')
gameLeftPanel:setMarginTop(modules.client_topmenu.getTopMenu()
:getHeight() - gameLeftPanel:getPaddingTop())
gameRightPanel:setMarginTop(modules.client_topmenu.getTopMenu()
:getHeight() - gameRightPanel:getPaddingTop())
gameLeftPanel:setOn(true)
gameLeftPanel:setVisible(true)
gameRightPanel:setOn(true)
gameMapPanel:setOn(true)
gameBottomPanel:setImageColor('#ffffff88')
modules.client_topmenu.getTopMenu():setImageColor('#ffffff66')
if not limit then
g_game.changeMapAwareRange(24, 20)
end
end

currentViewMode = mode
end

function limitZoom()
limitedZoom = true
end



3ª Alteração, troque seu entergame.lua e entergame.otui por esses..
entergame.lua

EnterGame = { }

-- private variables
local loadBox
local enterGame
local motdWindow
local motdButton
local enterGameButton
local clientBox
local protocolLogin
local motdEnabled = true

-- private functions
local function onError(protocol, message, errorCode)
if loadBox then
loadBox:destroy()
loadBox = nil
end

if not errorCode then
EnterGame.clearAccountFields()
end

local errorBox = displayErrorBox(tr('Login Error'), message)
connect(errorBox, { onOk = EnterGame.show })
end

local function onMotd(protocol, motd)
G.motdNumber = tonumber(motd:sub(0, motd:find("\n")))
G.motdMessage = motd:sub(motd:find("\n") + 1, #motd)
if motdEnabled then
motdButton:show()
end
end

local function onSessionKey(protocol, sessionKey)
G.sessionKey = sessionKey
end

local function onCharacterList(protocol, characters, account, otui)
-- Try add server to the server list
ServerList.add(G.host, G.port, g_game.getClientVersion())

-- Save 'Stay logged in' setting
g_settings.set('staylogged', enterGame:getChildById('stayLoggedBox'):isChecked())

if enterGame:getChildById('rememberPasswordBox'):isChecked() then
local account = g_crypt.encrypt(G.account)
local password = g_crypt.encrypt(G.password)

g_settings.set('account', account)
g_settings.set('password', password)

ServerList.setServerAccount(G.host, account)
ServerList.setServerPassword(G.host, password)

g_settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
else
-- reset server list account/password
ServerList.setServerAccount(G.host, '')
ServerList.setServerPassword(G.host, '')

EnterGame.clearAccountFields()
end

loadBox:destroy()
loadBox = nil

for _, characterInfo in pairs(characters) do
if characterInfo.previewState and characterInfo.previewState ~= PreviewState.Default then
characterInfo.worldName = characterInfo.worldName .. ', Preview'
end
end

CharacterList.create(characters, account, otui)
CharacterList.show()

if motdEnabled then
local lastMotdNumber = g_settings.getNumber("motd")
if G.motdNumber and G.motdNumber ~= lastMotdNumber then
g_settings.set("motd", G.motdNumber)
motdWindow = displayInfoBox(tr('Message of the day'), G.motdMessage)
connect(motdWindow, { onOk = function() CharacterList.show() motdWindow = nil end })
CharacterList.hide()
end
end
end

local function onUpdateNeeded(protocol, signature)
loadBox:destroy()
loadBox = nil

if EnterGame.updateFunc then
local continueFunc = EnterGame.show
local cancelFunc = EnterGame.show
EnterGame.updateFunc(signature, continueFunc, cancelFunc)
else
local errorBox = displayErrorBox(tr('Update needed'), tr('Your client needs updating, try redownloading it.'))
connect(errorBox, { onOk = EnterGame.show })
end
end

-- public functions
function EnterGame.init()
enterGame = g_ui.displayUI('entergame')
enterGameButton = modules.client_topmenu.addLeftButton('enterGameButton', tr('Login') .. ' (Ctrl + G)', '/images/topbuttons/login', EnterGame.openWindow)
motdButton = modules.client_topmenu.addLeftButton('motdButton', tr('Message of the day'), '/images/topbuttons/motd', EnterGame.displayMotd)
motdButton:hide()
g_keyboard.bindKeyDown('Ctrl+G', EnterGame.openWindow)

if motdEnabled and G.motdNumber then
motdButton:show()
end

local account = g_settings.get('account')
local password = g_settings.get('password')
local host = g_settings.get('host')
local port = g_settings.get('port')
local stayLogged = g_settings.getBoolean('staylogged')
local autologin = g_settings.getBoolean('autologin')
local clientVersion = g_settings.getInteger('client-version')
if clientVersion == 0 then clientVersion = 1074 end

if port == nil or port == 0 then port = 7171 end

EnterGame.setAccountName(account)
EnterGame.setPassword(password)

enterGame:getChildById('serverHostTextEdit'):setText(host)
enterGame:getChildById('serverPortTextEdit'):setText(port)
enterGame:getChildById('autoLoginBox'):setChecked(autologin)
enterGame:getChildById('stayLoggedBox'):setChecked(stayLogged)

clientBox = enterGame:getChildById('clientComboBox')
for _, proto in pairs(g_game.getSupportedClients()) do
clientBox:addOption(proto)
end
clientBox:setCurrentOption(clientVersion)

EnterGame.toggleAuthenticatorToken(clientVersion, true)
EnterGame.toggleStayLoggedBox(clientVersion, true)
connect(clientBox, { onOptionChange = EnterGame.onClientVersionChange })

enterGame:hide()

if g_app.isRunning() and not g_game.isOnline() then
enterGame:show()
end
ip =
EnterGame.setUniqueServer("127.0.0.1", 7171, 854, 270, 210)
end

function EnterGame.firstShow()
EnterGame.show()

local account = g_crypt.decrypt(g_settings.get('account'))
local password = g_crypt.decrypt(g_settings.get('password'))
local host = g_settings.get('host')
local autologin = g_settings.getBoolean('autologin')
if #host > 0 and #password > 0 and #account > 0 and autologin then
addEvent(function()
if not g_settings.getBoolean('autologin') then return end
EnterGame.doLogin()
end)
end
end

function EnterGame.terminate()
g_keyboard.unbindKeyDown('Ctrl+G')
disconnect(clientBox, { onOptionChange = EnterGame.onClientVersionChange })
enterGame:destroy()
enterGame = nil
enterGameButton:destroy()
enterGameButton = nil
clientBox = nil
if motdWindow then
motdWindow:destroy()
motdWindow = nil
end
if motdButton then
motdButton:destroy()
motdButton = nil
end
if loadBox then
loadBox:destroy()
loadBox = nil
end
if protocolLogin then
protocolLogin:cancelLogin()
protocolLogin = nil
end
EnterGame = nil
end

function EnterGame.show()
if loadBox then return end
enterGame:show()
enterGame:raise()
enterGame:focus()
end

function EnterGame.hide()
enterGame:hide()
end

function EnterGame.openWindow()
if g_game.isOnline() then
CharacterList.show()
elseif not g_game.isLogging() and not CharacterList.isVisible() then
EnterGame.show()
end
end

function EnterGame.setAccountName(account)
local account = g_crypt.decrypt(account)
enterGame:getChildById('accountNameTextEdit'):setText(account)
enterGame:getChildById('accountNameTextEdit'):setCursorPos(-1)
enterGame:getChildById('rememberPasswordBox'):setChecked(#account > 0)
end

function EnterGame.setPassword(password)
local password = g_crypt.decrypt(password)
enterGame:getChildById('accountPasswordTextEdit'):setText(password)
end

function EnterGame.clearAccountFields()
enterGame:getChildById('accountNameTextEdit'):clearText()
enterGame:getChildById('accountPasswordTextEdit'):clearText()
enterGame:getChildById('authenticatorTokenTextEdit'):clearText()
enterGame:getChildById('accountNameTextEdit'):focus()
g_settings.remove('account')
g_settings.remove('password')
end

function EnterGame.toggleAuthenticatorToken(clientVersion, init)
local enabled = (clientVersion >= 1072)
if enabled == enterGame.authenticatorEnabled then
return
end

enterGame:getChildById('authenticatorTokenLabel'):setOn(enabled)
enterGame:getChildById('authenticatorTokenTextEdit'):setOn(enabled)

local newHeight = enterGame:getHeight()
local newY = enterGame:getY()
if enabled then
newY = newY - enterGame.authenticatorHeight
newHeight = newHeight + enterGame.authenticatorHeight
else
newY = newY + enterGame.authenticatorHeight
newHeight = newHeight - enterGame.authenticatorHeight
end

if not init then
enterGame:breakAnchors()
enterGame:setY(newY)
enterGame:bindRectToParent()
end
enterGame:setHeight(newHeight)

enterGame.authenticatorEnabled = enabled
end

function EnterGame.toggleStayLoggedBox(clientVersion, init)
local enabled = (clientVersion >= 1074)
if enabled == enterGame.stayLoggedBoxEnabled then
return
end

enterGame:getChildById('stayLoggedBox'):setOn(enabled)

local newHeight = enterGame:getHeight()
local newY = enterGame:getY()
if enabled then
newY = newY - enterGame.stayLoggedBoxHeight
newHeight = newHeight + enterGame.stayLoggedBoxHeight
else
newY = newY + enterGame.stayLoggedBoxHeight
newHeight = newHeight - enterGame.stayLoggedBoxHeight
end

if not init then
enterGame:breakAnchors()
enterGame:setY(newY)
enterGame:bindRectToParent()
end
enterGame:setHeight(newHeight)

enterGame.stayLoggedBoxEnabled = enabled
end

function EnterGame.onClientVersionChange(comboBox, text, data)
local clientVersion = tonumber(text)
EnterGame.toggleAuthenticatorToken(clientVersion)
EnterGame.toggleStayLoggedBox(clientVersion)
end

function EnterGame.doLogin()
G.account = enterGame:getChildById('accountNameTextEdit'):getText()
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
G.authenticatorToken = enterGame:getChildById('authenticatorTokenTextEdit'):getText()
G.stayLogged = enterGame:getChildById('stayLoggedBox'):isChecked()
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
local clientVersion = tonumber(clientBox:getText())
EnterGame.hide()

if g_game.isOnline() then
local errorBox = displayErrorBox(tr('Login Error'), tr('Cannot login while already in game.'))
connect(errorBox, { onOk = EnterGame.show })
return
end

g_settings.set('host', G.host)
g_settings.set('port', G.port)
g_settings.set('client-version', clientVersion)

protocolLogin = ProtocolLogin.create()
protocolLogin.onLoginError = onError
protocolLogin.onMotd = onMotd
protocolLogin.onSessionKey = onSessionKey
protocolLogin.onCharacterList = onCharacterList
protocolLogin.onUpdateNeeded = onUpdateNeeded

loadBox = displayCancelBox(tr('Please wait'), tr('Connecting to login server...'))
connect(loadBox, { onCancel = function(msgbox)
loadBox = nil
protocolLogin:cancelLogin()
EnterGame.show()
end })

g_game.setClientVersion(clientVersion)
g_game.setProtocolVersion(g_game.getClientProtocolVersion(clientVersion))
g_game.chooseRsa(G.host)

if modules.game_things.isLoaded() then
protocolLogin:login(G.host, G.port, G.account, G.password, G.authenticatorToken, G.stayLogged)
else
loadBox:destroy()
loadBox = nil
EnterGame.show()
end
end

function EnterGame.displayMotd()
if not motdWindow then
motdWindow = displayInfoBox(tr('Message of the day'), G.motdMessage)
motdWindow.onOk = function() motdWindow = nil end
end
end

function EnterGame.setDefaultServer(host, port, protocol)
local hostTextEdit = enterGame:getChildById('serverHostTextEdit')
local portTextEdit = enterGame:getChildById('serverPortTextEdit')
local clientLabel = enterGame:getChildById('clientLabel')
local accountTextEdit = enterGame:getChildById('accountNameTextEdit')
local passwordTextEdit = enterGame:getChildById('accountPasswordTextEdit')
local authenticatorTokenTextEdit = enterGame:getChildById('authenticatorTokenTextEdit')

if hostTextEdit:getText() ~= host then
hostTextEdit:setText(host)
portTextEdit:setText(port)
clientBox:setCurrentOption(protocol)
accountTextEdit:setText('')
passwordTextEdit:setText('')
authenticatorTokenTextEdit:setText('')
end
end

function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeight)
local hostTextEdit = enterGame:getChildById('serverHostTextEdit')
hostTextEdit:setText(host)
hostTextEdit:setVisible(false)
hostTextEdit:setHeight(0)
local portTextEdit = enterGame:getChildById('serverPortTextEdit')
portTextEdit:setText(port)
portTextEdit:setVisible(false)
portTextEdit:setHeight(0)

local authenticatorTokenTextEdit = enterGame:getChildById('authenticatorTokenTextEdit')
authenticatorTokenTextEdit:setText('')
authenticatorTokenTextEdit:setOn(false)
local authenticatorTokenLabel = enterGame:getChildById('authenticatorTokenLabel')
authenticatorTokenLabel:setOn(false)

local stayLoggedBox = enterGame:getChildById('stayLoggedBox')
stayLoggedBox:setChecked(false)
stayLoggedBox:setOn(false)

clientBox:setCurrentOption(protocol)
clientBox:setVisible(false)
clientBox:setHeight(0)

local serverLabel = enterGame:getChildById('serverLabel')
serverLabel:setVisible(false)
serverLabel:setHeight(0)
local portLabel = enterGame:getChildById('portLabel')
portLabel:setVisible(false)
portLabel:setHeight(0)
local clientLabel = enterGame:getChildById('clientLabel')
clientLabel:setVisible(false)
clientLabel:setHeight(0)

local serverListButton = enterGame:getChildById('serverListButton')
serverListButton:setVisible(false)
serverListButton:setHeight(0)
serverListButton:setWidth(0)

local rememberPasswordBox = enterGame:getChildById('rememberPasswordBox')
rememberPasswordBox:setMarginTop(-8)

if not windowWidth then windowWidth = 236 end
enterGame:setWidth(windowWidth)
if not windowHeight then windowHeight = 210 end
enterGame:setHeight(windowHeight)
end

function EnterGame.setServerInfo(message)
local label = enterGame:getChildById('serverInfoLabel')
label:setText(message)
end

function EnterGame.disableMotd()
motdEnabled = false
motdButton:hide()
end

 

 

entergame.otui

EnterGameWindow < MainWindow

!text: tr('Enter Game')
size: 236 298

EnterGameButton < Button
width: 64

ServerListButton < UIButton
size: 17 17
image-source: /images/topbuttons/minimap
image-color: #ffffffff

$hover !disabled:
image-color: #ffffff99

$pressed:
image-color: #ffffff44

$disabled:
image-color: #ffffff55

EnterGameWindow
id: enterGame
&authenticatorEnabled: false
&authenticatorHeight: 44
&stayLoggedBoxEnabled: false
&stayLoggedBoxHeight: 24
@onEnter: EnterGame.doLogin()

MenuLabel
!text: tr('Account name')
anchors.left: parent.left
anchors.top: parent.top
text-auto-resize: true

PasswordTextEdit
id: accountNameTextEdit
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 2

MenuLabel
!text: tr('Password')
anchors.left: prev.left
anchors.top: prev.bottom
margin-top: 8
text-auto-resize: true

PasswordTextEdit
id: accountPasswordTextEdit
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 2

MenuLabel
id: authenticatorTokenLabel
!text: tr('Authenticator Token')
anchors.left: prev.left
anchors.top: prev.bottom
text-auto-resize: true
margin-top: -12
visible: false

$on:
visible: true
margin-top: 8

TextEdit
id: authenticatorTokenTextEdit
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: -22
visible: false
max-length: 8

$on:
visible: true
margin-top: 2

CheckBox
id: stayLoggedBox
!text: tr('Stay logged during session')
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 6
margin-top: -16
visible: false

$on:
visible: true
margin-top: 8

HorizontalSeparator
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 8

MenuLabel
id: serverLabel
!text: tr('Server')
anchors.left: prev.left
anchors.top: prev.bottom
margin-top: 8
text-auto-resize: true

ServerListButton
id: serverListButton
!tooltip: tr('Server list')
anchors.right: parent.right
anchors.top: serverLabel.bottom
margin-top: 3
@onClick: ServerList.show()

TextEdit
id: serverHostTextEdit
!tooltip: tr('Make sure that your client uses\nthe correct game client version')
anchors.left: parent.left
anchors.right: serverListButton.left
anchors.top: serverLabel.bottom
margin-top: 2
margin-right: 4

MenuLabel
id: clientLabel
!text: tr('Client Version')
anchors.left: parent.left
anchors.top: serverHostTextEdit.bottom
text-auto-resize: true
margin-right: 10
margin-top: 8

ComboBox
id: clientComboBox
anchors.left: parent.left
anchors.right: parent.horizontalCenter
anchors.top: clientLabel.bottom
margin-top: 2
margin-right: 3
width: 90
menu-scroll: true
menu-height: 125
menu-scroll-step: 25

MenuLabel
id: portLabel
!text: tr('Port')
anchors.left: serverPortTextEdit.left
anchors.top: serverHostTextEdit.bottom
margin-top: 8
text-auto-resize: true

TextEdit
id: serverPortTextEdit
text: 7171
anchors.right: parent.right
anchors.left: parent.horizontalCenter
anchors.top: clientComboBox.top
margin-left: 3

CheckBox
id: rememberPasswordBox
!text: tr('Remember password')
!tooltip: tr('Remember account and password when starts client')
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 10
@onCheckChange: self:getParent():getChildById('autoLoginBox'):setEnabled(self:isChecked())

CheckBox
id: autoLoginBox
enabled: false
!text: tr('Auto login')
!tooltip: tr('Open charlist automatically when starting client')
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 2

HorizontalSeparator
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 6

EnterGameButton
!text: tr('Ok')
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 4
@onClick: EnterGame.doLogin()

Label
id: serverInfoLabel
font: verdana-11px-rounded
anchors.top: prev.top
anchors.left: parent.left
margin-top: 5
color: green
text-auto-resize: true



Para vc colocar seu ip, procure por EnterGame.setUniqueServer irá ter "127.0.0.1" só mudar para o seu.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...