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

OTClient How to Change Ip without SetUniqueServer

soviec

New Member
Joined
Jun 7, 2012
Messages
11
Reaction score
1
Hello everyone, how are you?
I downloaded a version of OTclient V8 (already compiled) and i'm having issues to change the IP of my server.
As most of servers do, i need to fix it, removing the TOKEN/SERVER IP/PORT bars inside the red circle, like the image below.

1594267079974.png
I've seen tons of tutorials in several sites and every one of them says to insert the line* below in a file. Sometimes entergame.lua, sometimes init.lua and the list goes on. None of it has been working for me. I'm using it for a 7.72 server, by the way.
* EnterGame.setUniqueServer("YourIpHere", 7171, yourTibiaClientVersion)

Most of the OTclient versions seems to have this line already coded in their entergame.lua, mine doesn't.
To see if anyone can help me, i'm leaving the place where i downloaded the client, my entergame.lua and my whole client_entergame folder.

1. link to where i downloaded the client: OTCv8/otclientv8 (https://github.com/OTCv8/otclientv8/)
2. my folder uploaded in mediafire (it's also attached in the post): client_entergame (http://www.mediafire.com/file/zhue6f13c9j483o/client_entergame.rar/file)
3. My entergame.lua:
EnterGame = { }

-- private variables
local loadBox
local enterGame
local enterGameButton
local clientBox
local protocolLogin
local server = nil
local versionsFound = false

local customServerSelectorPanel
local serverSelectorPanel
local serverSelector
local clientVersionSelector
local serverHostTextEdit
local rememberPasswordBox
local protos = {"740", "760", "772", "792", "800", "810", "854", "860", "870", "961", "1077", "1090", "1096", "1098", "1099", "1100"}

local checkedByUpdater = {}

-- private functions
local function onProtocolError(protocol, message, errorCode)
if errorCode then
return EnterGame.onError(message)
end
return EnterGame.onLoginError(message)
end

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

local function onCharacterList(protocol, characters, account, otui)
if 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)
else
EnterGame.clearAccountFields()
end

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

if loadBox then
loadBox:destroy()
loadBox = nil
end

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

g_settings.save()
end

local function onUpdateNeeded(protocol, signature)
return EnterGame.onError(tr('Your client needs updating, try redownloading it.'))
end

local function parseFeatures(features)
for feature_id, value in pairs(features) do
if value == "1" or value == "true" or value == true then
g_game.enableFeature(feature_id)
else
g_game.disableFeature(feature_id)
end
end
end

local function validateThings(things)
local incorrectThings = ""
local missingFiles = false
local versionForMissingFiles = 0
if things ~= nil then
local thingsNode = {}
for thingtype, thingdata in pairs(things) do
thingsNode[thingtype] = thingdata[1]
if not g_resources.fileExists("/things/" .. thingdata[1]) then
incorrectThings = incorrectThings .. "Missing file: " .. thingdata[1] .. "\n"
missingFiles = true
versionForMissingFiles = thingdata[1]:split("/")[1]
else
local localChecksum = g_resources.fileChecksum("/things/" .. thingdata[1]):lower()
if localChecksum ~= thingdata[2]:lower() and #thingdata[2] > 1 then
if g_resources.isLoadedFromArchive() then -- ignore checksum if it's test/debug version
incorrectThings = incorrectThings .. "Invalid checksum of file: " .. thingdata[1] .. " (is " .. localChecksum .. ", should be " .. thingdata[2]:lower() .. ")\n"
end
end
end
end
g_settings.setNode("things", thingsNode)
else
g_settings.setNode("things", {})
end
if missingFiles then

incorrectThings = incorrectThings .. "\nYou should open data/things and create directory " .. versionForMissingFiles ..
".\nIn this directory (data/things/" .. versionForMissingFiles .. ") you should put missing\nfiles (Tibia.dat and Tibia.spr) " ..
"from correct Tibia version."
end
return incorrectThings
end

local function onHTTPResult(data, err)
if err then
return EnterGame.onError(err)
end
if data['error'] and #data['error'] > 0 then
return EnterGame.onLoginError(data['error'])
end

local characters = data["characters"]
local account = data["account"]
local session = data["session"]

local version = data["version"]
local things = data["things"]
local customProtocol = data["customProtocol"]

local features = data["features"]
local settings = data["settings"]
local rsa = data["rsa"]
local eviewproxies = data["proxies"]

local incorrectThings = validateThings(things)
if #incorrectThings > 0 then
g_logger.info(incorrectThings)
return EnterGame.onError(incorrectThings)
end

-- custom protocol
g_game.setCustomProtocolVersion(0)
if customProtocol ~= nil then
customProtocol = tonumber(customProtocol)
if customProtocol ~= nil and customProtocol > 0 then
g_game.setCustomProtocolVersion(customProtocol)
end
end

-- force player settings
if settings ~= nil then
for option, value in pairs(settings) do
modules.client_options.setOption(option, value, true)
end
end

-- version
G.clientVersion = version
g_game.setClientVersion(version)
g_game.setProtocolVersion(g_game.getClientProtocolVersion(version))
g_game.setCustomOs(-1) -- disable

if rsa ~= nil then
g_game.setRsa(rsa)
end

if features ~= nil then
parseFeatures(features)
end

if session ~= nil and session:len() > 0 then
onSessionKey(nil, session)
end

-- proxies
if g_proxy then
g_proxy.clear()
if proxies then
for i, proxy in ipairs(proxies) do
g_proxy.addProxy(proxy["host"], tonumber(proxy["port"]), tonumber(proxy["priority"]))
end
end
end

onCharacterList(nil, characters, account, nil)
end


-- public functions
function EnterGame.init()
if USE_NEW_ENERGAME then return end
enterGame = g_ui.displayUI('entergame')

serverSelectorPanel = enterGame:getChildById('serverSelectorPanel')
customServerSelectorPanel = enterGame:getChildById('customServerSelectorPanel')

serverSelector = serverSelectorPanel:getChildById('serverSelector')
rememberPasswordBox = enterGame:getChildById('rememberPasswordBox')
serverHostTextEdit = customServerSelectorPanel:getChildById('serverHostTextEdit')
clientVersionSelector = customServerSelectorPanel:getChildById('clientVersionSelector')

if Servers ~= nil then
for name,server in pairs(Servers) do
serverSelector:addOption(name)
end
end
if serverSelector:getOptionsCount() == 0 or ALLOW_CUSTOM_SERVERS then
serverSelector:addOption(tr("Another"))
end
for i,proto in pairs(protos) do
clientVersionSelector:addOption(proto)
end

if serverSelector:getOptionsCount() == 1 then
enterGame:setHeight(enterGame:getHeight() - serverSelectorPanel:getHeight())
serverSelectorPanel:setOn(false)
end

local account = g_crypt.decrypt(g_settings.get('account'))
local password = g_crypt.decrypt(g_settings.get('password'))
local server = g_settings.get('server')
local host = g_settings.get('host')
local clientVersion = g_settings.get('client-version')

if serverSelector:isOption(server) then
serverSelector:setCurrentOption(server, false)
if Servers == nil or Servers[server] == nil then
serverHostTextEdit:setText(host)
end
clientVersionSelector:setOption(clientVersion)
else
server = ""
host = ""
end

enterGame:getChildById('accountPasswordTextEdit'):setText(password)
enterGame:getChildById('accountNameTextEdit'):setText(account)
rememberPasswordBox:setChecked(#account > 0)

g_keyboard.bindKeyDown('Ctrl+G', EnterGame.openWindow)

if g_game.isOnline() then
return EnterGame.hide()
end

scheduleEvent(function()
EnterGame.show()
end, 100)
end

function EnterGame.terminate()
if not enterGame then return end
g_keyboard.unbindKeyDown('Ctrl+G')

enterGame:destroy()
if loadBox then
loadBox:destroy()
loadBox = nil
end
if protocolLogin then
protocolLogin:cancelLogin()
protocolLogin = nil
end
EnterGame = nil
end

function EnterGame.show()
if not enterGame then return end
enterGame:show()
enterGame:raise()
enterGame:focus()
enterGame:getChildById('accountNameTextEdit'):focus()
end

function EnterGame.hide()
if not enterGame then return end
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.clearAccountFields()
enterGame:getChildById('accountNameTextEdit'):clearText()
enterGame:getChildById('accountPasswordTextEdit'):clearText()
enterGame:getChildById('accountTokenTextEdit'):clearText()
enterGame:getChildById('accountNameTextEdit'):focus()
g_settings.remove('account')
g_settings.remove('password')
end

function EnterGame.onServerChange()
server = serverSelector:getText()
if server == tr("Another") then
if not customServerSelectorPanel:isOn() then
serverHostTextEdit:setText("")
customServerSelectorPanel:setOn(true)
enterGame:setHeight(enterGame:getHeight() + customServerSelectorPanel:getHeight())
end
elseif customServerSelectorPanel:isOn() then
enterGame:setHeight(enterGame:getHeight() - customServerSelectorPanel:getHeight())
customServerSelectorPanel:setOn(false)
end
if Servers and Servers[server] ~= nil then
serverHostTextEdit:setText(Servers[server])
end
end

function EnterGame.doLogin()
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.account = enterGame:getChildById('accountNameTextEdit'):getText()
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
G.authenticatorToken = enterGame:getChildById('accountTokenTextEdit'):getText()
G.stayLogged = true
G.server = serverSelector:getText():trim()
G.host = serverHostTextEdit:getText()
G.clientVersion = tonumber(clientVersionSelector:getText())

if not rememberPasswordBox:isChecked() then
g_settings.set('account', G.account)
g_settings.set('password', G.password)
end
g_settings.set('host', G.host)
g_settings.set('server', G.server)
g_settings.set('client-version', G.clientVersion)
g_settings.save()

if G.host:find("http") ~= nil then
return EnterGame.doLoginHttp()
end

local server_params = G.host:split(":")
local server_ip = server_params[1]
local server_port = 7171
if #server_params >= 2 then
server_port = tonumber(server_params[2])
end
if #server_params >= 3 then
G.clientVersion = tonumber(server_params[3])
end
if type(server_ip) ~= 'string' or server_ip:len() <= 3 or not server_port or not G.clientVersion then
return EnterGame.onError("Invalid server, it should be in format IP:pORT or it should be http url to login script")
end

local things = {
data = {G.clientVersion .. "/Tibia.dat", ""},
sprites = {G.clientVersion .. "/Tibia.spr", ""},
}

local incorrectThings = validateThings(things)
if #incorrectThings > 0 then
g_logger.error(incorrectThings)
if Updater and not checkedByUpdater[G.clientVersion] then
checkedByUpdater[G.clientVersion] = true
return Updater.check({
version = G.clientVersion,
host = G.host
})
else
return EnterGame.onError(incorrectThings)
end
end

protocolLogin = ProtocolLogin.create()
protocolLogin.onLoginError = onProtocolError
protocolLogin.onSessionKey = onSessionKey
protocolLogin.onCharacterList = onCharacterList
protocolLogin.onUpdateNeeded = onUpdateNeeded

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

-- if you have custom rsa or protocol edit it here
g_game.setClientVersion(G.clientVersion)
g_game.setProtocolVersion(g_game.getClientProtocolVersion(G.clientVersion))
g_game.setCustomProtocolVersion(0)
g_game.setCustomOs(-1) -- disable
g_game.chooseRsa(G.host)
if #server_params <= 3 and not g_game.getFeature(GameExtendedOpcode) then
g_game.setCustomOs(2) -- set os to windows if opcodes are disabled
end

-- extra features from init.lua
for i = 4, #server_params do
g_game.enableFeature(tonumber(server_params))
end

-- proxies
if g_proxy then
g_proxy.clear()
end

if modules.game_things.isLoaded() then
g_logger.info("Connecting to: " .. server_ip .. ":" .. server_port)
protocolLogin:login(server_ip, server_port, G.account, G.password, G.authenticatorToken, G.stayLogged)
else
loadBox:destroy()
loadBox = nil
EnterGame.show()
end
end

function EnterGame.doLoginHttp()
if G.host == nil or G.host:len() < 10 then
return EnterGame.onError("Invalid server url: " .. G.host)
end

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

local data = {
account = G.account,
password = G.password,
token = G.authenticatorToken,
version = APP_VERSION,
uid = G.UUID
}
HTTP.postJSON(G.host, data, onHTTPResult)
EnterGame.hide()
end

function EnterGame.onError(err)
if loadBox then
loadBox:destroy()
loadBox = nil
end
local errorBox = displayErrorBox(tr('Login Error'), err)
errorBox.onOk = EnterGame.show
end

function EnterGame.onLoginError(err)
if loadBox then
loadBox:destroy()
loadBox = nil
end
local errorBox = displayErrorBox(tr('Login Error'), err)
errorBox.onOk = EnterGame.show
if err:lower():find("invalid") or err:lower():find("not correct") or err:lower():find("or password") then
EnterGame.clearAccountFields()
end
end




Anyway guys, this is it. I really hope someone can help me. Thanks in advance, you're a amazing community! Cya
 

Attachments

  • client_entergame.rar
    8.8 KB · Views: 39 · VirusTotal
Solution
@soviec
Man, i can help you.
EnterGame.otui Delete 2 functions with Token ( ur screenshots. )
and going now EnterGame.lua

Find G.authenticatorToken = enterGame:getChildById('accountTokenTextEdit'):getText()
and Edit to --G.authenticatorToken = enterGame:getChildById('accountTokenTextEdit'):getText()

Find enterGame:getChildById('accountTokenTextEdit'):clearText()
and Edit to --enterGame:getChildById('accountTokenTextEdit'):clearText()

Find protocolLogin:login(server_ip, server_port, G.account, G.password, G.authenticatorToken, G.stayLogged)
and Edit to protocolLogin:login(server_ip, server_port, G.account, G.password, G.stayLogged)

Done
Solved ur problem here.
1.png
To remove the IP:pORT then change this line to false:

Add your server ip here:
Like this;
Lua:
Servers = {
myserver = "myopentibiaserver.net:7171:772",
-- serverName ="ipAddress:port:version"
}

Remove these lines associated with the token:
 
To remove the IP:pORT then change this line to false:

Add your server ip here:
Like this;
Lua:
Servers = {
myserver = "myopentibiaserver.net:7171:772",
-- serverName ="ipAddress:port:version"
}

Remove these lines associated with the token:


Hi, imkingran. First of all, i want to thank you for the answer. The IP + Server name part work 100%. Thanks again for that


About the token modification, I got some kind of bug with it. Please, if you dont mind, check this out:
When I remove the Menu label associated with TOKEN, the "login" button (in-game) no longer works.
I'll show you 3 screenshots of what happens when I change the menu label.

1. with full text edit/menu label on
1594271097378.png

2. removing bottom parte (text edit)
1594271171738.png
3. removing all the text edit and menu label
1594271193702.png


Do you have any idea what might be going on? xD Because I have none.

Thanks, mate!
 
@soviec
Man, i can help you.
EnterGame.otui Delete 2 functions with Token ( ur screenshots. )
and going now EnterGame.lua

Find G.authenticatorToken = enterGame:getChildById('accountTokenTextEdit'):getText()
and Edit to --G.authenticatorToken = enterGame:getChildById('accountTokenTextEdit'):getText()

Find enterGame:getChildById('accountTokenTextEdit'):clearText()
and Edit to --enterGame:getChildById('accountTokenTextEdit'):clearText()

Find protocolLogin:login(server_ip, server_port, G.account, G.password, G.authenticatorToken, G.stayLogged)
and Edit to protocolLogin:login(server_ip, server_port, G.account, G.password, G.stayLogged)

Done
Solved ur problem here.
1.png
 
Solution
I'm getting this error in the canary... when a player tries to connect through the mobile client.

Canary version 13.1

[2023-18-01 18:28:00.848] [warning] [ProtocolGame::eek:nRecvFirstMessage] - RSA Decrypt Failed
 
Back
Top