local config = {
time = 1000 * 60 * 60, -- 1 hour
skillAmount = 10,
itemUse = 2294,
itemTarget = 2160,
effect = CONST_ME_BATS,
storage = 10040,
exhaustTime = 60,
removeItem = false,
exhaustTable = {},
}
local skill = Condition(CONDITION_ATTRIBUTES)
skill:setParameter(CONDITION_PARAM_TICKS, config.time)
skill:setParameter(CONDITION_PARAM_SKILL_SWORD, config.skillAmount)
local action = Action()
function action.onUse(player, item, fromPos, target, toPos, isHotkey)
local playerGuid = player:getGuid()
local timeAmount = config.exhaustTable[playerGuid]
if timeAmount and timeAmount > os.time() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait " .. (timeAmount - os.time()) .. " seconds.")
return true
end
if target.itemid == config.itemTarget then
if config.removeItem then
item:remove()
end
player:addCondition(skill)
player:getPosition():sendMagicEffect(config.effect)
config.exhaustTable[playerGuid] = os.time() + config.exhaustTime
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Buff has been activated.')
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You can use it only on itemBlaBla')
end
return true
end
action:id(config.itemUse)
action:register()