• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

otclient packets information

Darius93

Active Member
Joined
Oct 16, 2022
Messages
88
Reaction score
27
Hello, I have a problem.


How can I send a signal from OTClient to TFS that this is my OTClient?


I added code to a module:
LUA:
MyClientId = {}

local OPCODE_MYCLIENT = 50
local PAYLOAD = "MYCLIENT"

local function sendHello()
  if not g_game.isOnline() then
    g_logger.info("[game_myclientid] not online")
    return
  end

  local proto = g_game.getProtocolGame()
  if not proto then
    g_logger.error("[game_myclientid] no protocol")
    return
  end

  g_logger.info("[game_myclientid] sending extended opcode " .. OPCODE_MYCLIENT)
  proto:sendExtendedOpcode(OPCODE_MYCLIENT, PAYLOAD)
end

function init()
  g_logger.info("[game_myclientid] INIT")

  connect(g_game, {
    onGameStart = function()
      g_logger.info("[game_myclientid] onGameStart")
      addEvent(sendHello, 200)
    end
  })
end

function terminate()
  g_logger.info("[game_myclientid] TERMINATE")
  MyClientId = nil
end

Everything sends correctly and works fine, but unfortunately it’s a bit too late — after logging in, I receive the first packets from the server, and only after that does it send the information that I’m using my OTClient.

Does anyone know how I can achieve this?
 
Solution
Tibia login packet already contains 'operating system', which is set to 10+ value, when OTClient connects (real Tibia client use 0-7):
Which is read by TFS:
Which you can read in Lua in onLogin event using player:getClient():
ex.:
LUA:
function onLogin(player)
  local playerClient = player:getClient()
  local playerOperatingSystem = playerClient["os"]
  if playerOperatingSystem >= CLIENTOS_OTCLIENT_LINUX then
    print("onLogin: using OTClient", playerOperatingSystem)
  else
    print("onLogin: using Tibia client", playerOperatingSystem)
  end

  return true
end
TFS know these clients ( forgottenserver/src/enums.h at 5b3b0d7460f377a599d5d7df6627e3a1c9fc7e46 · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/5b3b0d7460f377a599d5d7df6627e3a1c9fc7e46/src/enums.h#L133-L148) ):
LUA:
CLIENTOS_NONE = 0
CLIENTOS_LINUX = 1
CLIENTOS_WINDOWS = 2
CLIENTOS_FLASH = 3
CLIENTOS_QT_LINUX = 4
CLIENTOS_QT_WINDOWS = 5
CLIENTOS_QT_MAC = 6
CLIENTOS_QT_LINUX2 = 7
CLIENTOS_OTCLIENT_LINUX = 10
CLIENTOS_OTCLIENT_WINDOWS = 11
CLIENTOS_OTCLIENT_MAC = 12
OTClient uses 10+ version (OTCv8 may send 20+ version), so you can use 'operating system' to detect OTClient.
 
You know what, I just want it so that when someone is using my OTClient, my server knows that it’s mine.
And when they are using a different OTClient, the server does nothing about it.


C++:
void ProtocolGame::AddOutfit(NetworkMessage& msg, const Outfit_t& outfit)
{
    msg.add<uint16_t>(outfit.lookType);

    if (outfit.lookType != 0) {
        msg.addByte(outfit.lookHead);
        msg.addByte(outfit.lookBody);
        msg.addByte(outfit.lookLegs);
        msg.addByte(outfit.lookFeet);
        msg.addByte(outfit.lookAddons);
    }
    else {
        msg.addItemId(outfit.lookTypeEx);
    }
    if (player->isMyOtClient()) {
            std::cout << "isMyOtClient = true" << std::endl;
    }
}

And it works fine, but my client sends the signal too late
 
Solution

Similar threads

Replies
3
Views
372
Back
Top