kaique2131856
New Member
- Joined
- Apr 25, 2010
- Messages
- 1
- Reaction score
- 0
i triyng make this antibot play a alert when he show, but i don't know how, someone can help me ?
original code:
My edit, but no working
original code:
AntibotWindow = nil
haveTiming = false
local function getTimeInString(interval)
timeTable = {}
timeTable.minute = math.floor((math.fmod(interval, 60*60))/60)
timeTable.second = math.fmod(math.fmod(interval, 60*60),60)
for i, v in pairs(timeTable) do
if tostring(v):len() < 2 then
timeTable = "0"..timeTable
end
end
return timeTable.minute..":"..timeTable.second
end
local function attTimer(timeLeft)
if not g_game.isOnline() or timeLeft == 0 then
haveTiming = false
return
end
AntibotWindow:getChildById("Timer"):setText(getTimeInString(timeLeft))
scheduleEvent(function() attTimer(timeLeft-1) end, 1000)
haveTiming = true
end
function onReceiveQuestion(protocol, opcode, buffer)
if buffer == nil or not buffer then return false end
buffer = string.explode(buffer, ",")
if not haveTiming then
attTimer(buffer[2])
end
AntibotWindow:getChildById("Question"):setText(buffer[1])
AntibotWindow:getChildById("Answer"):setText("")
if not AntibotWindow:isVisible() then
AntibotWindow:show()
end
end
function onTestVisible(protocol, opcode, buffer)
if not AntibotWindow:isVisible() then
AntibotWindow:getChildById("Answer"):setText("")
AntibotWindow:show()
end
if not haveTiming then
attTimer(buffer)
end
end
function init()
ProtocolGame.registerExtendedOpcode(167, onReceiveQuestion)
ProtocolGame.registerExtendedOpcode(168, onTestVisible)
AntibotWindow = g_ui.displayUI('antibot.otui')
connect(g_game, { onGameStart = online,
onGameEnd = offline,
onGameEnd = destroyWindows})
AntibotWindow:hide()
end
function destroyWindows()
AntibotWindow:hide()
end
function terminate()
disconnect(g_game, { onGameStart = online,
onGameEnd = offline,
onGameEnd = destroyWindows})
AntibotWindow:destroy()
end
function toggle()
end
function sendQuestion()
AntibotWindow:hide()
return g_game.talkChannel(1, 0, "!antibot " .. AntibotWindow:getChildById("Answer"):getText())
end
haveTiming = false
local function getTimeInString(interval)
timeTable = {}
timeTable.minute = math.floor((math.fmod(interval, 60*60))/60)
timeTable.second = math.fmod(math.fmod(interval, 60*60),60)
for i, v in pairs(timeTable) do
if tostring(v):len() < 2 then
timeTable = "0"..timeTable
end
end
return timeTable.minute..":"..timeTable.second
end
local function attTimer(timeLeft)
if not g_game.isOnline() or timeLeft == 0 then
haveTiming = false
return
end
AntibotWindow:getChildById("Timer"):setText(getTimeInString(timeLeft))
scheduleEvent(function() attTimer(timeLeft-1) end, 1000)
haveTiming = true
end
function onReceiveQuestion(protocol, opcode, buffer)
if buffer == nil or not buffer then return false end
buffer = string.explode(buffer, ",")
if not haveTiming then
attTimer(buffer[2])
end
AntibotWindow:getChildById("Question"):setText(buffer[1])
AntibotWindow:getChildById("Answer"):setText("")
if not AntibotWindow:isVisible() then
AntibotWindow:show()
end
end
function onTestVisible(protocol, opcode, buffer)
if not AntibotWindow:isVisible() then
AntibotWindow:getChildById("Answer"):setText("")
AntibotWindow:show()
end
if not haveTiming then
attTimer(buffer)
end
end
function init()
ProtocolGame.registerExtendedOpcode(167, onReceiveQuestion)
ProtocolGame.registerExtendedOpcode(168, onTestVisible)
AntibotWindow = g_ui.displayUI('antibot.otui')
connect(g_game, { onGameStart = online,
onGameEnd = offline,
onGameEnd = destroyWindows})
AntibotWindow:hide()
end
function destroyWindows()
AntibotWindow:hide()
end
function terminate()
disconnect(g_game, { onGameStart = online,
onGameEnd = offline,
onGameEnd = destroyWindows})
AntibotWindow:destroy()
end
function toggle()
end
function sendQuestion()
AntibotWindow:hide()
return g_game.talkChannel(1, 0, "!antibot " .. AntibotWindow:getChildById("Answer"):getText())
end
My edit, but no working
AntibotWindow = nil
haveTiming = false
local function getTimeInString(interval)
timeTable = {}
timeTable.minute = math.floor((math.fmod(interval, 60*60))/60)
timeTable.second = math.fmod(math.fmod(interval, 60*60),60)
for i, v in pairs(timeTable) do
if tostring(v):len() < 2 then
timeTable = "0"..timeTable
end
end
return timeTable.minute..":"..timeTable.second
end
local function attTimer(timeLeft)
local alert = false
if not g_game.isOnline() or timeLeft == 0 then
haveTiming = false
return
end
AntibotWindow:getChildById("Timer"):setText(getTimeInString(timeLeft))
scheduleEvent(function() attTimer(timeLeft-1) end, 1000)
haveTiming = true
end
function onReceiveQuestion(protocol, opcode, buffer)
if buffer == nil or not buffer then return false end
buffer = string.explode(buffer, ",")
if not haveTiming then
attTimer(buffer[2])
end
AntibotWindow:getChildById("Question"):setText(buffer[1])
AntibotWindow:getChildById("Answer"):setText("")
if not AntibotWindow:isVisible() then
alert = true
AntibotWindow:show()
end
end
function onTestVisible(protocol, opcode, buffer)
if not AntibotWindow:isVisible() then
AntibotWindow:getChildById("Answer"):setText("")
AntibotWindow:show()
end
if not haveTiming then
attTimer(buffer)
end
end
function init()
g_sounds.preload('alert.ogg')
ProtocolGame.registerExtendedOpcode(167, onReceiveQuestion)
ProtocolGame.registerExtendedOpcode(168, onTestVisible)
AntibotWindow = g_ui.displayUI('antibot.otui')
connect(g_game, { onGameStart = online,
onGameEnd = offline,
onGameEnd = destroyWindows})
AntibotWindow:hide()
end
function destroyWindows()
AntibotWindow:hide()
end
function terminate()
disconnect(g_game, { onGameStart = online,
onGameEnd = offline,
onGameEnd = destroyWindows})
AntibotWindow:destroy()
end
function toggle()
end
function sendQuestion()
AntibotWindow:hide()
return g_game.talkChannel(1, 0, "!antibot " .. AntibotWindow:getChildById("Answer"):getText())
alert = false
end
if alert then
Alarm()
else
stopAlarm()
end
return 800
end
function Alarm()
g_sounds.playMusic('alert.ogg', 0)
end
function stopAlarm()
g_sounds.stopMusic(0)
end
haveTiming = false
local function getTimeInString(interval)
timeTable = {}
timeTable.minute = math.floor((math.fmod(interval, 60*60))/60)
timeTable.second = math.fmod(math.fmod(interval, 60*60),60)
for i, v in pairs(timeTable) do
if tostring(v):len() < 2 then
timeTable = "0"..timeTable
end
end
return timeTable.minute..":"..timeTable.second
end
local function attTimer(timeLeft)
local alert = false
if not g_game.isOnline() or timeLeft == 0 then
haveTiming = false
return
end
AntibotWindow:getChildById("Timer"):setText(getTimeInString(timeLeft))
scheduleEvent(function() attTimer(timeLeft-1) end, 1000)
haveTiming = true
end
function onReceiveQuestion(protocol, opcode, buffer)
if buffer == nil or not buffer then return false end
buffer = string.explode(buffer, ",")
if not haveTiming then
attTimer(buffer[2])
end
AntibotWindow:getChildById("Question"):setText(buffer[1])
AntibotWindow:getChildById("Answer"):setText("")
if not AntibotWindow:isVisible() then
alert = true
AntibotWindow:show()
end
end
function onTestVisible(protocol, opcode, buffer)
if not AntibotWindow:isVisible() then
AntibotWindow:getChildById("Answer"):setText("")
AntibotWindow:show()
end
if not haveTiming then
attTimer(buffer)
end
end
function init()
g_sounds.preload('alert.ogg')
ProtocolGame.registerExtendedOpcode(167, onReceiveQuestion)
ProtocolGame.registerExtendedOpcode(168, onTestVisible)
AntibotWindow = g_ui.displayUI('antibot.otui')
connect(g_game, { onGameStart = online,
onGameEnd = offline,
onGameEnd = destroyWindows})
AntibotWindow:hide()
end
function destroyWindows()
AntibotWindow:hide()
end
function terminate()
disconnect(g_game, { onGameStart = online,
onGameEnd = offline,
onGameEnd = destroyWindows})
AntibotWindow:destroy()
end
function toggle()
end
function sendQuestion()
AntibotWindow:hide()
return g_game.talkChannel(1, 0, "!antibot " .. AntibotWindow:getChildById("Answer"):getText())
alert = false
end
if alert then
Alarm()
else
stopAlarm()
end
return 800
end
function Alarm()
g_sounds.playMusic('alert.ogg', 0)
end
function stopAlarm()
g_sounds.stopMusic(0)
end