Hello,
I have something like this:
When you equip item you gain mana and hp per 2s, but I found bug there.
If I dequip and equip this item fast, it looks like double script runs :/ "Dequip" and "equip" is correct order, but you gain example per 1 sec. Why is that?
I have something like this:
Lua:
local runningEvents = {}
local function gainHpAndMana(cid)
local player = Player(cid)
if player then
player:addMana(100)
player:addHealth(150)
runningEvents[1] = addEvent(gainHpAndMana, 2000, player:getId())
end
return true;
end
function onEquip(player, item, slot)
if player:getStorageValue(40005) == -1 or player:getStorageValue(40005) == 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Equip")
player:setStorageValue(40005, 1)
addEvent(gainHpAndMana, 2000, player:getId())
end
return true
end
function onDeEquip(player, item, slot)
stopEvent(runningEvents[1])
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Dequip")
player:setStorageValue(40005, 0)
return true
end
When you equip item you gain mana and hp per 2s, but I found bug there.
If I dequip and equip this item fast, it looks like double script runs :/ "Dequip" and "equip" is correct order, but you gain example per 1 sec. Why is that?