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

CreatureEvent [TFS 1.3] Best Free Anti-Bot System -- Notations & Auto-Ban

Shadow_

Veteran OT User
Joined
Jun 2, 2018
Messages
921
Solutions
30
Reaction score
346
just told myself why don't share it, maybe its coding is not good enough because i wrote it a year ago, but it works perfectly, if you want to change the effect choose effect easy to see between another effects like this flaming orcs.
in creaturescripts/scripts/antibot.lua
add this script:
Lua:
-- Anti-Bot System by Carcoo (Shadow_)
local symbols = {"*", "^", "¿", "%", "&", "$"}
local timeToKick = 2 * 60 --2 minutes
local killStorage = 94727
local codeStorage = 94728
local kickStorage = 94729
local timesStorage = 94731
local storageForNotations = 94736
local notations = 10
local minMonstersToCheck = 600
local maxMonstersToCheck = 700
local random = math.random(minMonstersToCheck, maxMonstersToCheck)
function onKill(player, target)
    if (not player:isPlayer()) or player:getGroup():getAccess() then
             player:setStorageValue(killStorage, 0)
        return true
    end

    if player:getStorageValue(kickStorage) > 1 and os.time() >= player:getStorageValue(kickStorage) then
        local tmp = {killStorage, kickStorage, timesStorage, codeStorage}
        for i = 1, #tmp do
            player:setStorageValue(tmp[i], 0)
    end
        local timeNow = os.time()
    if (isPlayer(cid) == FALSE) then
               return true
        end
        if player:getStorageValue(storageForNotations) < notations then
            if player:getStorageValue(storageForNotations) ~= -1 then
                player:setStorageValue(storageForNotations, math.max(player:getStorageValue(storageForNotations) + 1))
            else
                player:setStorageValue(storageForNotations, 1)
            end
            player:teleportTo(player:getTown():getTemplePosition())
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('You have been penalized and received a notation. Remember that after receiving 5 notations you will be banned. You currently have %d notations.', math.max(player:getStorageValue(storageForNotations))))
        else
            player:teleportTo(player:getTown():getTemplePosition())
            db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..getAccountNumberByPlayerName(player:getName())..", "..db.escapeString(ANTI_BOT_SYSTEM.messages.reason.msg)..", "..timeNow..", "..timeNow + (ANTI_BOT_SYSTEM.config.banDays * 86400) ..", 1)")
            player:remove()
        end
        return true
    end
     if target:isPlayer() then
         return true
     end
     local stor = player:getStorageValue(killStorage)+1
     if stor < random then
         player:setStorageValue(killStorage, stor)
     end
     if (stor +1) >= random then
        (player:getPosition()):sendMagicEffect(171)
        player:say("[ANTI-BOT]", TALKTYPE_MONSTER_SAY)
        local code, set = "", 0
        set = math.random(1, 100000)
        local s, e = 1, 1
        for i = 1, string.len(set) do
            code = (code == "" and string.sub(set, s, e) or code .. symbols[math.random(#symbols)] .. string.sub(set, s, e))
            s, e = s + 1, e + 1
        end
        player:setStorageValue(codeStorage, set)
        player:setStorageValue(kickStorage, os.time() + timeToKick)
        player:setStorageValue(killStorage, 0)
        player:say(""..player:getStorageValue(codeStorage).."", TALKTYPE_MONSTER_SAY)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "[Anti-Bot]: Please say !antibot followed by your code without symbols.")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Here is your code!  !antibot "..player:getStorageValue(codeStorage).." Type in the numbers without symbols.")
    end
    return true
     end
and antibot2.lua
Lua:
-- Anti-Bot System by Carcoo (Shadow_)
local killStorage = 94727
local codeStorage = 94728
local kickStorage = 94729
local timesStorage = 94731
local storageForNotations = 94736
local notations = 10
local banDays = 1
local reason = "Botting."

function onThink(player, interval)
    if player:getStorageValue(kickStorage) > 1 and os.time() >= player:getStorageValue(kickStorage) then
        local tmp = {killStorage, kickStorage, timesStorage, codeStorage}
        for i = 1, #tmp do
            player:setStorageValue(tmp[i], 0)
    end
        local timeNow = os.time()
        if (not player:isPlayer()) then
           return true
        end
        if player:getStorageValue(storageForNotations) < notations then
            if player:getStorageValue(storageForNotations) ~= -1 then
                player:setStorageValue(storageForNotations, math.max(player:getStorageValue(storageForNotations) + 1))
            else
                player:setStorageValue(storageForNotations, 1)
            end
            player:teleportTo(player:getTown():getTemplePosition())
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('You have been penalized and received a notation. Remember that after receiving 5 notations you will be banned. You currently have %d notations.', math.max(player:getStorageValue(storageForNotations))))
        else
            player:teleportTo(player:getTown():getTemplePosition())
            db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..getAccountNumberByPlayerName(player:getName())..", "..db.escapeString(reason)..", "..timeNow..", "..timeNow + (banDays * 86400) ..", 1)")
            player:remove()
        end
        return true
    end
    return true
    end
in login.lua add those lines near the end.
Lua:
    player:registerEvent("Antibot")
    player:registerEvent("Antibot2")
and in creaturescripts.xml add those lines too.
Code:
    <event type="kill" name="Antibot" script="antibot.lua" />
    <event type="think" name="Antibot2" script="antibot2.lua" />
now in data/talkactions/scripts
create new file with name antibot.lua and add this code inside.
Lua:
-- Anti-Bot System by Carcoo (Shadow_)
local killStorage = 94727
local codeStorage = 94728
local kickStorage = 94729
local timesStorage = 94731
local times = 10
local symbols = {"*", "^", "¿", "%", "&", "$"}
local storageForNotations = 94736
local notations = 5
local banDays = 1
local reason = "Botting."

function onSay(player, words, param)

    if player:getStorageValue(codeStorage) == 0 then
        player:sendCancelMessage("Not yet.")
        return false
    elseif tonumber(param) == tonumber(player:getStorageValue(codeStorage)) then
        player:setStorageValue(codeStorage, 0)
        player:setStorageValue(kickStorage, 0)
        player:setStorageValue(timesStorage, 0)
        player:say('Correct Answer',TALKTYPE_MONSTER_SAY)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[Antibot]: Enjoy your time!")
        return false
    else
        if player:getStorageValue(timesStorage) < 0 then player:setStorageValue(timesStorage, 0) end

        player:setStorageValue(timesStorage, player:getStorageValue(timesStorage) + 1)
        if player:getStorageValue(timesStorage) == times then
            player:setStorageValue(codeStorage, 0)
            player:setStorageValue(kickStorage, 0)
            player:setStorageValue(timesStorage, 0)

        local timeNow = os.time()
        if (isPlayer(cid) == FALSE) then
           return true
        end
        if player:getStorageValue(storageForNotations) < notations then
            if player:getStorageValue(storageForNotations) ~= -1 then
                player:setStorageValue(storageForNotations, math.max(player:getStorageValue(storageForNotations) + 1))
            else
                player:setStorageValue(storageForNotations, 1)
            end
            player:teleportTo(player:getTown():getTemplePosition())
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('You have been penalized and received a notation. Remember that after receiving 5 notations you will be banned. You currently have %d notations.', math.max(player:getStorageValue(storageForNotations))))
        else
            player:teleportTo(player:getTown():getTemplePosition())
            db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..getAccountNumberByPlayerName(player:getName())..", "..db.escapeString(reason)..", "..timeNow..", "..timeNow + (banDays * 86400) ..", 1)")
            player:remove()
        end
            return false
        else
          player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[Antibot]: You have " .. times - player:getStorageValue(timesStorage) .. " opportunities to try it again.")
          player:say('Incorrect Answer',TALKTYPE_MONSTER_SAY)
          player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Here is your code!  !antibot "..player:getStorageValue(codeStorage).." Type in the numbers without symbols.")
            return false
        end
    end
    return false
end
and another file with name botnotations.lua and add this code inside it :
Lua:
    function onSay(player, words, param)
            player:sendTextMessage(TALKTYPE_MONSTER_SAY, "You have".. player:getStorageValue(94735).." botting notations.")
        return false
    end
and in talkactions.xml
Code:
    <talkaction words="!antibot" separator=" " script="antibot.lua"/>
    <talkaction words="!notations" script="notations.lua"/>
so you are done, now if you want to configure:
auto-ban options -- goto this file data/creaturescripts/antibot2.lua and in /talkactions/antibot.lua
monsters killed to start anti-bot check up -- goto this file data/creaturescripts/antibot.lua
Note : always keep the storages the same between the 3 files ( i know it is better to do a config but didn't bother as it works good ).
 

Night Wolf

I don't bite.
Joined
Feb 10, 2008
Messages
477
Solutions
6
Reaction score
731
This is a good alternative against total afk cavebots but unfortunately this won't avoid assisted botting and neither pixel bots that can be adapted to read the message and type this command.

Making simple calculations or asking different questions could avoid pixel bots just checking if the message is received and copying/pasting the content to avoid the antibot detection.

For other scenarios, we would require a lot of data to 'learn' to classify who is botting and who isn't.
 
OP
OP
Shadow_

Shadow_

Veteran OT User
Joined
Jun 2, 2018
Messages
921
Solutions
30
Reaction score
346
This is a good alternative against total afk cavebots but unfortunately this won't avoid assisted botting and neither pixel bots that can be adapted to read the message and type this command.

Making simple calculations or asking different questions could avoid pixel bots just checking if the message is received and copying/pasting the content to avoid the antibot detection.

For other scenarios, we would require a lot of data to 'learn' to classify who is botting and who isn't.
true, i found it could be easily get the code between those things i was adding between the code (%^&), so honestly i removed them, annoyed my eyes for useless reason they already can pass through the system with encrypting the number or without.

anyway best bot protection is through client so this can be made through OTClient modules or something more protective, just let this be the start ^^
 

damian00912

New Member
Joined
Sep 11, 2009
Messages
87
Reaction score
4
When i Use this on tfs 1.2 that's everythink working but after login is writing over chat on center this white text:

could not retrieve game compedium tibia

someone can help?
 
OP
OP
Shadow_

Shadow_

Veteran OT User
Joined
Jun 2, 2018
Messages
921
Solutions
30
Reaction score
346
When i Use this on tfs 1.2 that's everythink working but after login is writing over chat on center this white text:

could not retrieve game compedium tibia

someone can help?
can you do a gif even a screenshot ?
 

Hayvosh

Member
Joined
Feb 7, 2019
Messages
33
Solutions
2
Reaction score
7
Location
Sweden
Hello @Shadow_ I implemented your anti-bot on my server and just have a question regarding this :

Lua:
local timeToKick = 10 * 60 --10 minutes

Is this to be considered as AFK timer?
I was training while watching a bit of youtube and had been kicked to temple with a notation.
There is a afk timer already set in the config.lua of the server.
Or is this timeToKick something else?
 

Hayvosh

Member
Joined
Feb 7, 2019
Messages
33
Solutions
2
Reaction score
7
Location
Sweden
Also another question, I have this implemented in Nekiros 1.5 downgrade for client 7.72 but for some reason it crashes the client when it tries to send questions to players. Could this be modified to work with 7.72 as well?
 
Top