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

RevScripts Bot check system

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,339
Solutions
68
Reaction score
1,024
I am working on a botcheck system. I can't figure out why the TextEdit creatureevent is only being called once.

The system should show a text dialog and the player writes the answer inside the text box.

If I type the correct answer the first time it works properly.
If I type the wrong answer first it works properly.

When I type the wrong answer again or type the correct answer after the first attempt it does nothing. It seems like the onTextEdit event only calls once when it should do it everytime.

Lua:
local BotSystem_TextEdit = CreatureEvent("BotSystem_TextEdit")
function BotSystem_TextEdit.onTextEdit(player, item, text)
    if item.itemid == 1811 and BOTCHECKED_PLAYERS[player:getName()] then
        if text:find(BOTCHECKED_PLAYERS[player:getName()].answer) then
            BOTCHECKED_PLAYERS[player:getName()] = nil
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Bot check passed.")
            return true
        else
            local num1 = math.random(5)
            local num2 = math.random(5)
            local num3 = math.random(5)
            local ans = num1+num2+num3
           
            player:showTextDialog(1811, "What is the answer: "..num1.."+"..num2.."+"..num3.."?\n", true, 100)
            BOTCHECKED_PLAYERS[player:getName()].answer = ans
        end
    end
    return true
end
BotSystem_TextEdit:register()
 
Solution
Thanks for helping. I just changed it so the window is created again outside of the TextEdit event. It is working now. Weird stuff with TFS sometimes.
Start printing stuff, and see if it's breaking somewhere.
Sometimes things aren't happening as you expect them too.

Lua:
function BotSystem_TextEdit.onTextEdit(player, item, text)
    print("-----")
    print(item.itemid)
    print(text)
    print(player:getName())
    if BOTCHECKED_PLAYERS[player:getName()] then
        print(BOTCHECKED_PLAYERS[player:getName()].answer)
    else
        print("This player has no bot check running.")
    end
 
I did, after the first one nothing happens at all.
try making the next text an addEvent, so it triggers after this textEdit is completed? 🤷‍♂️

Lua:
local function showTextDialog(playerId, text)
    local player = Player(playerId)
    if not player then
        return
    end
    player:showTextDialog(1811, text, true, 100)
end

addEvent(showTextDialog, 100, player:getId(), "What is the answer: "..num1.."+"..num2.."+"..num3.."?\n")
 
Thanks for helping. I just changed it so the window is created again outside of the TextEdit event. It is working now. Weird stuff with TFS sometimes.
 
Solution
Thanks for helping. I just changed it so the window is created again outside of the TextEdit event. It is working now. Weird stuff with TFS sometimes.
From my experience: do not use system like that.
If your OTS is popular, someone will create bot that hide that window (from user view) and fill answer. I will just annoy normal players. Botters won't even see it.
 
Back
Top