therrax
Member
- Joined
- Jul 12, 2012
- Messages
- 262
- Solutions
- 1
- Reaction score
- 11
Hello
I am using CandyBot module on 7.6 vers (armia.toproste.pl). While speaking server command "!mm"(using mana fluid), character becomes exhausted. It looks like he wanted to use them two times.
Maybe instead of function talk() i should call press hotkey or smth? How to fix that? Any suggestions?
Lua code:
I am using CandyBot module on 7.6 vers (armia.toproste.pl). While speaking server command "!mm"(using mana fluid), character becomes exhausted. It looks like he wanted to use them two times.
Maybe instead of function talk() i should call press hotkey or smth? How to fix that? Any suggestions?
Lua code:
Lua:
-- Auto Mana Spell
SupportModule.AutoManaSpell = {}
AutoManaSpell = SupportModule.AutoManaSpell
local nextMana = {}
local settings = {
[RestoreType.cast] = 'AutoManaSpell',
[RestoreType.item] = 'AutoManaItem'
}
function AutoManaSpell.onManaChange(player, mana, maxMana, oldMana, restoreType, tries)
local tries = tries or 10
local Panel = SupportModule.getPanel()
if not Panel:getChildById(settings[restoreType]):isChecked() then
return -- has since been unchecked
end
if restoreType == RestoreType.cast then
local spellText = Panel:getChildById('ManaSpellText'):getText()
local manaValue = Panel:getChildById('ManaBar'):getValue()
local delay = 1100
if player:getManaPercent() < manaValue then
g_game.talk(spellText)
delay = 1100
end
nextMana[RestoreType.cast] = scheduleEvent(function()
local player = g_game.getLocalPlayer()
if not player then return end
mana, maxMana = player:getMana(), player:getMaxMana()
if player:getManaPercent() < manaValue and tries > 0 then
tries = tries - 1
AutoManaSpell.onManaChange(player, mana, maxMana, mana, restoreType, tries)
else
removeEvent(nextMana[RestoreType.cast])
end
end, delay)
end
end
function AutoManaSpell.executeCast(player, mana, maxMana, oldMana)
AutoManaSpell.onManaChange(player, mana, maxMana, oldMana, RestoreType.cast)
end
function AutoManaSpell.ConnectCastListener(listener)
if g_game.isOnline() then
local player = g_game.getLocalPlayer()
addEvent(AutoManaSpell.onManaChange(player, player:getMana(),
player:getMaxMana(), player:getMana(), RestoreType.cast))
end
connect(LocalPlayer, { onManaChange = AutoManaSpell.executeCast })
end
function AutoManaSpell.DisconnectCastListener(listener)
disconnect(LocalPlayer, { onManaChange = AutoManaSpell.executeCast })
end
Last edited: