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

Lua Transform revscriptsys

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
173
Reaction score
13
I tried to pass this to revscript but it gave me many errors and it did not work, can someone help me?
i used otbr tfs 1.3

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

clients_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
 
Solution
try and enjoy it:

data/scripts/allowedClient.lua
Lua:
local function isCorrectClient(player)
    player:registerEvent("allowedClientThink")
    local client = player:getClient()
    return client.os == 5 and client.version >= 1261
end

local creatureEvent = CreatureEvent("allowedClientVersion")
creatureEvent.onLogin = isCorrectClient
creatureEvent:register()

creatureEvent = CreatureEvent("allowedClientThink")
function creatureEvent.onThink(player)
    if not isCorrectClient(player) then
        player:popupFYI("Error Client!")
        addEvent(function (guid)
            local player = Player(guid)
            if not player then
                return
            end

            player:remove()
            end, 100...

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,036
Solutions
102
Reaction score
1,093
Location
London
GitHub
MillhioreBT
This is what Revscript looks like:

data/scripts/file.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()
 
Last edited:
OP
OP
A

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
173
Reaction score
13
This is what Revscript looks like:

data/scripts/file.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

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
    if not table.contains(whitelist, clientType) then
        if table.contains(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

creatureEvent:register()
Should I register it somewhere? Why does he still let me in with any client


This is the original post:
CreatureEvent - [TFS 1.3] block unofficial clients (https://otland.net/threads/tfs-1-3-block-unofficial-clients.270246/)
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,036
Solutions
102
Reaction score
1,093
Location
London
GitHub
MillhioreBT
data/scripts/allowedClient.lua
Lua:
local creatureEvent = CreatureEvent("allowedClientVersion")

function creatureEvent.onLogin(player)
    local client = player:getClient()
    return table.contains({CLIENTOS_WINDOWS, CLIENTOS_LINUX}, client.os) and client.version >= 1260
end

creatureEvent:register()

So now players cannot connect if they are not using the correct system and the correct version
 
OP
OP
A

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
173
Reaction score
13
data/scripts/allowedClient.lua
Lua:
local creatureEvent = CreatureEvent("allowedClientVersion")

function creatureEvent.onLogin(player)
    local client = player:getClient()
    return table.contains({CLIENTOS_WINDOWS, CLIENTOS_LINUX}, client.os) and client.version >= 1260
end

creatureEvent:register()
Lua:
local creatureEvent = CreatureEvent("allowedClientVersion")

function creatureEvent.onLogin(player)
    local client = player:getClient()
    return table.contains({CLIENTOS_WINDOWS, CLIENTOS_LINUX}, client.os) and client.version >= 1261
end

creatureEvent:register()

I tried to place it as you and it does not let me enter with any client, I placed it like this change the 1260 for 1261 and it does not let me enter with any client

In my config.lua I have this like this

Captura.PNG
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,036
Solutions
102
Reaction score
1,093
Location
London
GitHub
MillhioreBT
try this to know what version is your client and system, according to what you see in the console or in the message that will appear when you connect, we will configure the script correctly.
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()
 
OP
OP
A

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
173
Reaction score
13
try this to know what version is your client and system, according to what you see in the console or in the message that will appear when you connect, we will configure the script correctly.
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()
Captura.PNG
Lua:
GM Krotus has logged in. | Client: 12.61
Client OS: 5 / Client version: 1261
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,036
Solutions
102
Reaction score
1,093
Location
London
GitHub
MillhioreBT
View attachment 61219
Lua:
GM Krotus has logged in. | Client: 12.61
Client OS: 5 / Client version: 1261
try
Lua:
local creatureEvent = CreatureEvent("allowedClientVersion")

function creatureEvent.onLogin(player)
    local client = player:getClient()
    return client.os == 5 and client.version >= 1261
end

creatureEvent:register()
;)
 
OP
OP
A

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
173
Reaction score
13
try
Lua:
local creatureEvent = CreatureEvent("allowedClientVersion")

function creatureEvent.onLogin(player)
    local client = player:getClient()
    return client.os == 5 and client.version >= 1261
end

creatureEvent:register()
;)
This did work for me, thank you very much, but I can enter with client 10 or otclient if the character is inside the game, it is very difficult to explain but I will try ..

If you enter with client 12 and you exit and the character is inside you can easily enter with the otclient and it does not kick you
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,036
Solutions
102
Reaction score
1,093
Location
London
GitHub
MillhioreBT
try and enjoy it:

data/scripts/allowedClient.lua
Lua:
local function isCorrectClient(player)
    player:registerEvent("allowedClientThink")
    local client = player:getClient()
    return client.os == 5 and client.version >= 1261
end

local creatureEvent = CreatureEvent("allowedClientVersion")
creatureEvent.onLogin = isCorrectClient
creatureEvent:register()

creatureEvent = CreatureEvent("allowedClientThink")
function creatureEvent.onThink(player)
    if not isCorrectClient(player) then
        player:popupFYI("Error Client!")
        addEvent(function (guid)
            local player = Player(guid)
            if not player then
                return
            end

            player:remove()
            end, 100, player:getGuid())
    end
    return true
end
creatureEvent:register()
 
Solution
OP
OP
A

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
173
Reaction score
13
try and enjoy it:

data/scripts/allowedClient.lua
Lua:
local function isCorrectClient(player)
    player:registerEvent("allowedClientThink")
    local client = player:getClient()
    return client.os == 5 and client.version >= 1261
end

local creatureEvent = CreatureEvent("allowedClientVersion")
creatureEvent.onLogin = isCorrectClient
creatureEvent:register()

creatureEvent = CreatureEvent("allowedClientThink")
function creatureEvent.onThink(player)
    if not isCorrectClient(player) then
        player:popupFYI("Error Client!")
        addEvent(function (guid)
            local player = Player(guid)
            if not player then
                return
            end

            player:remove()
            end, 100, player:getGuid())
    end
    return true
end
creatureEvent:register()
excellent thank you very much
 
Top