• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent [TFS 1.3] block unofficial clients

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,327
Solutions
27
Reaction score
2,703
Location
Poland
This script allows you to prevent players from playing clients that aren't whitelisted by the script
preview:
G2qtkg1.png


creaturescripts.xml:
XML:
    <event type="login" name="clientControlLogin" script="client_control.lua" />
    <event type="think" name="clientControl" interval="5000" script="client_control.lua" />

creaturescripts/scripts/client_control.lua:
LUA:
--[[
    available clients to whitelist:
    CLIENTOS_LINUX
    CLIENTOS_WINDOWS
    CLIENTOS_FLASH
    CLIENTOS_OTCLIENT_LINUX
    CLIENTOS_OTCLIENT_WINDOWS
    CLIENTOS_OTCLIENT_MAC
]]

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


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

local function forceLogout(cid)
    local player = Player(cid)
   
    if player then
        local tile = player:getTile()
        if not (tile:hasFlag(TILESTATE_NOLOGOUT) or (player:hasCondition(CONDITION_INFIGHT) and not tile:hasFlag(TILESTATE_PROTECTIONZONE))) then
            player:remove()
        end
    end
end

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
            local m = ModalWindow()
            m:setTitle("Error")
            m:setMessage(msg)
            m:addButton(1, "ok")
            m:sendToPlayer(player)
        else
            -- ot client
            local m = NetworkMessage()
            m:addByte(0x14)
            m:addString(msg)
            m:sendToPlayer(player)
        end
       
        addEvent(forceLogout, 100, player:getId())      
    end
    return true
end
 
Thanks! for my flash client.. uussefull! 👏 dont need to code the sources! 🔥

LUA:
local whitelist = {CLIENTOS_FLASH}
 
when i add in whitelist CLIENTOS_OTCLIENTV8_WINDOWS or linux or mac it still kicks me from it, it is already added in my source files
 
I tried it on my server which is based on tfs 1.2 but it doesn't seem to work. When I set: local whitelist = {CLIENTOS_WINDOWS}, in whitelist, I can still log in normally using OtclientV8. What if I resolve to "CLIENTOS_OTCLIENT_WINDOWS"

is:


"
Sasuke has logged in.

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/client_control.lua:eek:nThink
data/creaturescripts/scripts/client_control.lua:41: attempt to call global 'ModalWindow' (a nil value)
stack traceback:
[C]: in function 'ModalWindow'
data/creaturescripts/scripts/client_control.lua:41: in function <data/creaturescripts/scripts/client_control.lua:36>
"
 
This script allows you to prevent players from playing clients that aren't whitelisted by the script
preview:
G2qtkg1.png


creaturescripts.xml:
XML:
    <event type="login" name="clientControlLogin" script="client_control.lua" />
    <event type="think" name="clientControl" interval="5000" script="client_control.lua" />

creaturescripts/scripts/client_control.lua:
LUA:
--[[
    available clients to whitelist:
    CLIENTOS_LINUX
    CLIENTOS_WINDOWS
    CLIENTOS_FLASH
    CLIENTOS_OTCLIENT_LINUX
    CLIENTOS_OTCLIENT_WINDOWS
    CLIENTOS_OTCLIENT_MAC
]]

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


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

local function forceLogout(cid)
    local player = Player(cid)
  
    if player then
        local tile = player:getTile()
        if not (tile:hasFlag(TILESTATE_NOLOGOUT) or (player:hasCondition(CONDITION_INFIGHT) and not tile:hasFlag(TILESTATE_PROTECTIONZONE))) then
            player:remove()
        end
    end
end

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
            local m = ModalWindow()
            m:setTitle("Error")
            m:setMessage(msg)
            m:addButton(1, "ok")
            m:sendToPlayer(player)
        else
            -- ot client
            local m = NetworkMessage()
            m:addByte(0x14)
            m:addString(msg)
            m:sendToPlayer(player)
        end
      
        addEvent(forceLogout, 100, player:getId())     
    end
    return true
end

Can anyone do this revscriptsys?
 
Revscript way:

data/scripts/blockClient.lua
LUA:
--[[
    available clients to whitelist:
    CLIENTOS_LINUX
    CLIENTOS_WINDOWS
    CLIENTOS_FLASH
    CLIENTOS_OTCLIENT_LINUX
    CLIENTOS_OTCLIENT_WINDOWS
    CLIENTOS_OTCLIENT_MAC
]]

-- config
local msg = "This game client is not supported on the server."
local allowedClients = {CLIENTOS_WINDOWS, CLIENTOS_LINUX}

local creatureEvent = CreatureEvent("clientControlOnLogin")

function creatureEvent.onLogin(player)
    player:registerEvent("clientControlOnThink")
    return true
end

creatureEvent:register()

creatureEvent = CreatureEvent("clientControlOnThink")

function creatureEvent.onThink(player, interval)
    local clientType = player:getClient().os
    local allowedClient = allowedClients[clientType]
    if not allowedClient then
        if table.contains({CLIENTOS_WINDOWS, CLIENTOS_LINUX}, clientType) then
            -- tibia client
            local m = ModalWindow()
            m:setTitle("Error")
            m:setMessage(msg)
            m:addButton(1, "ok")
            m:sendToPlayer(player)
            addEvent(function (pid)
                local player = Player(pid)
                if player then
                    local tile = player:getTile()
                    if not (tile:hasFlag(TILESTATE_NOLOGOUT) or (player:hasCondition(CONDITION_INFIGHT) and not tile:hasFlag(TILESTATE_PROTECTIONZONE))) then
                        player:remove()
                    end
                end
            end, 100, player:getId())
        else
            -- ot client
            local m = NetworkMessage()
            m:addByte(0x14)
            m:addString(msg)
            m:sendToPlayer(player)
        end
    end
    return true
end

creatureEvent:register()

Only clients that are on the list of allowedClients are the ones you can enter the game with him
Notes: for some strange reason OTCv8 indicates that the system is CLIENTOS_WINDOWS instead of CLIENTOS_OTCLIENT_WINDOWS on windows, so keep this in mind
 
Revscript way:

data/scripts/blockClient.lua
LUA:
--[[
    available clients to whitelist:
    CLIENTOS_LINUX
    CLIENTOS_WINDOWS
    CLIENTOS_FLASH
    CLIENTOS_OTCLIENT_LINUX
    CLIENTOS_OTCLIENT_WINDOWS
    CLIENTOS_OTCLIENT_MAC
]]

-- config
local msg = "This game client is not supported on the server."
local allowedClients = {CLIENTOS_WINDOWS, CLIENTOS_LINUX}

local creatureEvent = CreatureEvent("clientControlOnLogin")

function creatureEvent.onLogin(player)
    player:registerEvent("clientControlOnThink")
    return true
end

creatureEvent:register()

creatureEvent = CreatureEvent("clientControlOnThink")

function creatureEvent.onThink(player, interval)
    local clientType = player:getClient().os
    local allowedClient = allowedClients[clientType]
    if not allowedClient then
        if table.contains({CLIENTOS_WINDOWS, CLIENTOS_LINUX}, clientType) then
            -- tibia client
            local m = ModalWindow()
            m:setTitle("Error")
            m:setMessage(msg)
            m:addButton(1, "ok")
            m:sendToPlayer(player)
            addEvent(function (pid)
                local player = Player(pid)
                if player then
                    local tile = player:getTile()
                    if not (tile:hasFlag(TILESTATE_NOLOGOUT) or (player:hasCondition(CONDITION_INFIGHT) and not tile:hasFlag(TILESTATE_PROTECTIONZONE))) then
                        player:remove()
                    end
                end
            end, 100, player:getId())
        else
            -- ot client
            local m = NetworkMessage()
            m:addByte(0x14)
            m:addString(msg)
            m:sendToPlayer(player)
        end
    end
    return true
end

creatureEvent:register()

Only clients that are on the list of allowedClients are the ones you can enter the game with him
Notes: for some strange reason OTCv8 indicates that the system is CLIENTOS_WINDOWS instead of CLIENTOS_OTCLIENT_WINDOWS on windows, so keep this in mind
Which client should I put on the list so that they can only use client 12.61?
 
The problem is when i enable g_game.enableFeature(GameExtendedOpcode) in Otclient it doesn't allow me to login using OTC.
 
Hello everyone,
@Sarah Wesker - I have a question about your sentence: "Notes: for some strange reason OTCv8 indicates that the system is CLIENTOS_WINDOWS instead of CLIENTOS_OTCLIENT_WINDOWS on windows, so keep this in mind"
Is it possible to edit this script to recognize somehow the OTClient? I'm working on a project and I would like players to use my Cipsoft Client, not the OTC (i know that it can be hacked easly propably, but maybe it will discourage people from trying OTClient - which of course have bot etc included. I will try to change RSA and other things later to secure client even more - but this script would be nice for start).
In my files (TFS 1.5 772) players can use OTClient and Cipsoft Client with this script, so using it is pointless I think, because it is not blocking anything atm.

With this test lines:

LUA:
local creatureEvent = CreatureEvent("allowedClientVersion")

function creatureEvent.onLogin(player)
    local client = player:getClient()
    local msg = string.format("Client OS: %d / Client version: %d", client.os, client.version)
    print(msg)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
    --return table.contains({CLIENTOS_WINDOWS, CLIENTOS_LINUX}, client.os) and client.version >= 1261
    return true
end

creatureEvent:register()

I gets this output (one login try is from Cipsoft Client and second from OTClient)

Code:
Goverando has logged in.
Client OS: 2 / Client version: 772
Goverando has logged out.
Goverando has logged in.
Client OS: 2 / Client version: 772
Goverando has logged out.

Thanks in advance for help :)
 
Last edited:
Back
Top