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

C++ Auto connecting otclient to my server

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,433
Solutions
68
Reaction score
1,077
I am trying to get otclient to connect to my server automatically and remove the ip, port, client version, ect. options on otclient.

I have done everything successfully except when I try to log in I get:

Your connection has been lost. Either your network or the server went down. (ERROR 2)

I can connect to the server on a standard tibia client and a non-modded otclient.

This started happening after I changed the RSA keys in modules/gamelib/const.h with the ones for my server.

Before I changed the RSA I received a message about authentication failure.

I have hardcoded the ip, port, ect. in the sources and the entergame.lua.

The only thing I can think of is that the client version may not be right. I "hardcoded" it as 1097.

If anyone has any information on this I would appreciate it!
 
Update....

It is back to invalid authen token

Here is my connect part of otclient...

Code:
function EnterGame.doLogin()
  G.account = enterGame:getChildById('accountNameTextEdit'):getText()
  G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
  G.authenticatorToken = ""
  G.stayLogged = false
  G.host = "104.217.250.174"
  G.port = 7171
  local clientVersion = 1097
  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
 
maybe try this
LUA:
function EnterGame.doLogin()
  G.account = enterGame:getChildById('accountNameTextEdit'):getText()
  G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
  G.authenticatorToken = ""
  G.stayLogged = false
  G.host = "104.217.250.174"
  G.port = 7171
  local clientVersion = 1097

  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)

  g_game.setClientVersion(clientVersion)
  g_game.setProtocolVersion(clientVersion)
  g_game.chooseRsa('otserv')  -- of 'realots', afhankelijk van jouw server type

  if g_things.isLoaded() then
    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 })

    protocolLogin:login(G.host, G.port, G.account, G.password, G.authenticatorToken, G.stayLogged)
  else
    EnterGame.show()
  end
end
 

Similar threads

Back
Top