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.
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()