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

TFS 1.X+ Checking Client Type

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,731
Solutions
7
Reaction score
536
Location
Canada
Sources: TFS 1.5 - 8.6 Downgrade
Client: OTCv8

When using the code below both OTC and Default Tibia Clients get the message when it should only be sending to the Tibia Clients.

print("Client: "..player:getClient().os)
OTCv8 returns - Client: 2
Tibia client returns - Client: 2

Code:
--[[
    available clients to whitelist:
    CLIENTOS_LINUX
    CLIENTOS_WINDOWS
    CLIENTOS_FLASH
    CLIENTOS_OTCLIENT_LINUX
    CLIENTOS_OTCLIENT_WINDOWS
    CLIENTOS_OTCLIENT_MAC
]]

-- config
local whitelist = {CLIENTOS_OTCLIENT_WINDOWS, CLIENTOS_OTCLIENT_LINUX, CLIENTOS_OTCLIENT_MAC}
local msg = "This game client is not supported on the server."
-- end config


-- do not touch
local tibiaClient = {CLIENTOS_WINDOWS, CLIENTOS_LINUX}

function onLogin(player)
    player:registerEvent("clientControl")
    return true
end

function onThink(player, interval)
    local clientType = player:getClient().os
    if not isInArray(whitelist, clientType) then
        if isInArray(tibiaClient, clientType) then
            -- tibia client
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
        else
            -- ot client (set xp bonus)
        end
    end
    return true
end

Checked sources and we have:
Code:
enum OperatingSystem_t : uint8_t {
    CLIENTOS_NONE = 0,

    CLIENTOS_LINUX = 1,
    CLIENTOS_WINDOWS = 2,
    CLIENTOS_FLASH = 3,

    CLIENTOS_OTCLIENT_LINUX = 10,
    CLIENTOS_OTCLIENT_WINDOWS = 11,
    CLIENTOS_OTCLIENT_MAC = 12,
};

Also in core/player.lua
Code:
function Player.isUsingOtClient(self)
    return self:getClient().os >= CLIENTOS_OTCLIENT_LINUX
end


Tried modifying the script for this and I still get messages on both OTC and Default Client which makes sense since both
Code:
function onThink(player, interval)
        if player:getClient().os == CLIENTOS_WINDOWS then
            -- tibia client
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
        else
            -- ot client
        end
    return true
end


Solution: In OTCv8 go to /modules/gamefeatures/gamefeatures.lua and change:
Code:
---g_game.enableFeature(GameExtendedOpcode)
to
Code:
g_game.enableFeature(GameExtendedOpcode)

Client will start to print "20"
 
Last edited:
Back
Top