• 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+ locking for antibot tfs 1.2

Madusa

Active Member
Joined
Sep 8, 2022
Messages
118
Reaction score
32
Location
Egypt
As shown above, search for the antibot system for tfs 1.2
I hope someone finds it for me
Thanks in advance
 
 
I've tried this system and it sucks. It sends the player to the temple and the player can go hunting again and also gain experience without responding to the auto counter.
Also, if the player is in a quest and the antibot wants to check, he will send him to the temple, and this is crazy
On other servers, I see that verification is done and the player is in a position, and if he does not answer the question, he will not get experience
Thank you for trying to help, and I wish you happiness
 
I just remembered, there was an anti-bot system for TFS 1.x, and then I found it on another forum. This system was created by MovieBr.

Create a file in the lib folder with the name antibot.lua

Lua:
ANTIBOT = {
    prefix = "[AntiBot] ",
    questions = {
        {question = "What year did COVID-19 start?", staticAnswer = true, answer = "2019"},
        {question = "What is your current Sword skill?", skill = true, answer = SKILL_SWORD},
        {question = "What is your current Club skill?", skill = true, answer = SKILL_CLUB},
        {question = "What is your current Distance skill?", skill = true, answer = SKILL_DISTANCE},
        {question = "What is your current level?", answer = "level"},
        {question = "What day is it today?", answer = "day"},
    },
    playerQuestion = {},
    messages = {
        time = "You have %s to answer the question.",
        chat = "This chat can only be used during verification.",
        howAnswer = "You should answer only the response, for example: What day is it today? Answer: %d",
        correctAnswer = "You got the question right. Thank you.",
        incorrectAnswer = "You answered incorrectly. You still have %d attempts.",
        logout = "You can't log out while having an active verification.",
    },
    punishment = {
        try = {
            max = 3,
            reason = "Excessive number of attempts.",
            timePunishment = 1, -- In days
            players = {},
        },
        time = {
            maxTime = 180, -- In seconds
            reason = "Did not answer the question within the stipulated time.",
            timePunishment = 2, -- In days
            players = {},
        },
    },
    verification = {40, 60}, -- in minutes
}


function ANTIBOT:addTry(playerId)

    local player = Player(playerId)

    if not player then
        return false
    end

    playerId = player:getId()

    if not ANTIBOT.punishment.try.players[playerId] then
        ANTIBOT.punishment.try.players[playerId] = 0
    end

    ANTIBOT.punishment.try.players[playerId] = ANTIBOT.punishment.try.players[playerId] + 1

    if ANTIBOT.punishment.try.players[playerId] and ANTIBOT.punishment.try.players[playerId] >= ANTIBOT.punishment.try.max then
        sendChannelMessage(13, TALKTYPE_CHANNEL_O, ANTIBOT.prefix .. ANTIBOT.punishment.try.reason)
        ANTIBOT:addPunishment(playerId)
    end
end

function ANTIBOT:time(playerId)
    local player = Player(playerId)

    if not player then
        ANTIBOT:reset(playerId)
        return false
    end

    playerId = player:getId()

    if not ANTIBOT.punishment.time.players[playerId] then
        ANTIBOT.punishment.time.players[playerId] = 0
        ANTIBOT:sendQuestions(playerId)
    end

    addEvent(function()
        if ANTIBOT.punishment.time.players[playerId] and ANTIBOT.punishment.time.players[playerId] >= 0 and ANTIBOT.punishment.time.players[playerId] < ANTIBOT.punishment.time.maxTime then
            ANTIBOT.punishment.time.players[playerId] = ANTIBOT.punishment.time.players[playerId] + 1
            player:sendCancelMessage(ANTIBOT.prefix .. ANTIBOT.messages.time:format(string.diff(ANTIBOT.punishment.time.maxTime - ANTIBOT.punishment.time.players[playerId], true)))
            ANTIBOT:time(playerId)
        end
    end, 1000)

    if ANTIBOT.punishment.time.players[playerId] and ANTIBOT.punishment.time.players[playerId] >= ANTIBOT.punishment.time.maxTime then
        ANTIBOT:addPunishment(playerId)
    end

end

function ANTIBOT:sendQuestions(playerId)

    local player = Player(playerId)

    if not player then
        return false
    end

    playerId = player:getId()

    random = math.random(#ANTIBOT.questions)

    ANTIBOT.playerQuestion[playerId] = random

    player:say("ANTIBOT", TALKTYPE_MONSTER_SAY)
    player:openChannel(13)
    addEvent(sendChannelMessage, 500, 13, TALKTYPE_CHANNEL_O, ANTIBOT.prefix .. ANTIBOT.messages.howAnswer:format(os.date("%d")))
    addEvent(sendChannelMessage, 800, 13, TALKTYPE_CHANNEL_O, ANTIBOT.prefix .. ANTIBOT.questions[random].question)
end

function ANTIBOT:reset(playerId)
    ANTIBOT.punishment.try.players[playerId] = nil
    ANTIBOT.punishment.time.players[playerId] = nil
    ANTIBOT.playerQuestion[playerId] = nil
end

function ANTIBOT:addPunishment(playerId)

    local player = Player(playerId)
    if not player then
        return false
    end

    playerId = player:getId()

    local accountId = getAccountNumberByPlayerName(player:getName())
    if accountId == 0 then
        return false
    end

    local resultId = db.storeQuery("SELECT 1 FROM `account_bans` WHERE `account_id` = " .. accountId)
    if resultId ~= false then
        result.free(resultId)
        return false
    end

    local timeNow = os.time()

    if ANTIBOT.punishment.try.players[playerId] and ANTIBOT.punishment.try.players[playerId] >= ANTIBOT.punishment.try.max then
        db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..
            accountId .. ", " .. db.escapeString(ANTIBOT.prefix .. ANTIBOT.punishment.try.reason) .. ", " .. timeNow .. ", " .. timeNow + (ANTIBOT.punishment.try.timePunishment * 86400) .. ", " .. player:getGuid() .. ")")
    elseif ANTIBOT.punishment.time.players[playerId] and ANTIBOT.punishment.time.players[playerId] >= ANTIBOT.punishment.time.maxTime then
        db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..
            accountId .. ", " .. db.escapeString(ANTIBOT.prefix .. ANTIBOT.punishment.time.reason) .. ", " .. timeNow .. ", " .. timeNow + (ANTIBOT.punishment.time.timePunishment * 86400) .. ", " .. player:getGuid() .. ")")
    end

    ANTIBOT:reset(playerId)
    player:save()
    player:getPosition():sendMagicEffect(CONST_ME_POFF)
    player:remove()
end
In the chachannels/scripts folder create a file called antibot.lua.
Lua:
function onJoin(player)
    if not ANTIBOT.playerQuestion[player:getId()] then
        player:sendTextMessage(5, ANTIBOT.prefix .. ANTIBOT.messages.chat)
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    return true
end

function onLeave(player)
    if ANTIBOT.playerQuestion[player:getId()] then
        return false
    end
    return true
end


function onSpeak(player, type, message)
    if not ANTIBOT.playerQuestion[player:getId()] then
        sendChannelMessage(13, TALKTYPE_CHANNEL_O, ANTIBOT.prefix .. ANTIBOT.messages.chat)
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local question = ANTIBOT.questions[ANTIBOT.playerQuestion[player:getId()]]

    if question.skill then
        correctAnswer = tonumber(player:getSkillLevel(question.answer))
        message = tonumber(message)
    elseif question.answer == "level" then
        correctAnswer = tonumber(player:getLevel())
        message = tonumber(message)
    elseif question.answer == "day" then
        correctAnswer = tonumber(os.date("%d"))
        message = tonumber(message)
    elseif question.staticAnswer then
        message = message:lower()
        correctAnswer = question.answer:lower()
    end

    verification = false

    if message == correctAnswer then
        verification = true
    end

    if verification then
        addEvent(sendChannelMessage, 200, 13, TALKTYPE_CHANNEL_O, ANTIBOT.prefix .. ANTIBOT.messages.correctAnswer)
        ANTIBOT:reset(player:getId())
    else
        ANTIBOT:addTry(player:getId())
        addEvent(function()
            if ANTIBOT.punishment.try.players[player:getId()] and ANTIBOT.punishment.try.players[player:getId()] < ANTIBOT.punishment.try.max and player then
                sendChannelMessage(13, TALKTYPE_CHANNEL_O, ANTIBOT.prefix .. ANTIBOT.messages.incorrectAnswer:format(ANTIBOT.punishment.try.max - ANTIBOT.punishment.try.players[player:getId()]))
            end
        end, 100)
    end

    return true
end
XML:
<channel id="13" name="AntiBot" script="antibot.lua" />
Now in the creaturescripts/scripts folder create a file called antibot.lua.
Lua:
function onLogin(player)

    if player:getAccountType() >= ACCOUNT_TYPE_GAMEMASTER then
        return true
    end

    player:registerEvent("AntiBot")
    checkAnti(player:getId())
    
    return true
end

function checkAnti(playerId)
    local player = Player(playerId)
    if not player then
        return false
    end

    min, max = ANTIBOT.verification[1], ANTIBOT.verification[2]
    random = math.random(min, max)

    addEvent(function()
        ANTIBOT:time(player:getId())
        checkAnti(player:getId())
    end, random * 60 * 1000)
end
XML:
<event type="login" name="AntiBot" script="antibot.lua" />

Now in the logout.lua file in the creaturescripts/scripts folder

before return true add this.

Lua:
if ANTIBOT.punishment.try.players[player:getId()] or ANTIBOT.punishment.time.players[player:getId()] then
    player:sendTextMessage(MESSAGE_INFO_DESCR, ANTIBOT.prefix .. ANTIBOT.messages.logout)
    player:getPosition():sendMagicEffect(CONST_ME_POFF)
    return false
end
ANTIBOT:reset(player:getId())
 
Back
Top