eyez
Member
- Joined
- Oct 11, 2016
- Messages
- 129
- Reaction score
- 19
I have this action
And it should add a bonus for player for 2 hours, but instead its over after kill the first monster, i mean, in few seconds.
Anybody know what is wrong?
Code:
function ExpBackNormal_EndVoucher(cid, bonus)
local rates = getPlayerRates(cid)[8] - bonus
doPlayerSetExperienceRate(cid, rates)
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getCreatureCondition(cid, CONDITION_INFIGHT) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can not use this item in fight!")
return true
end
local exhaustedvoucher = 3024775
if(os.time() < getCreatureStorage(cid, exhaustedvoucher)) then
doPlayerSendCancel(cid, "You can only use it once every 20 hours! You will be able to use this item again on: " .. os.date("%B", getPlayerStorageValue(cid, exhaustedvoucher)) .. "-" .. os.date("%d", getPlayerStorageValue(cid, exhaustedvoucher)) .. "-" .. os.date("%Y", getPlayerStorageValue(cid, exhaustedvoucher)) .. " " .. os.date("%X", getPlayerStorageValue(cid, exhaustedvoucher)) .. ".")
return true
end
-- add 50% exp bonus for 1 hour
local bonus
if(item.itemid == 11402) then
bonus = 0.5
elseif(item.itemid == 11401) then
bonus = 0.3
end
local rates = getPlayerRates(cid)[8] + bonus
doPlayerSetExperienceRate(cid, rates)
addEvent(ExpBackNormal_EndVoucher, 2*60*60*1000, cid, bonus) -- 2 hours
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Now you have your EXP bonus for 2 hours.")
doRemoveItem(item.uid)
doCreatureSetStorage(cid, exhaustedvoucher, os.time() + (20*60*60*1000)) -- 24 hours
doSendMagicEffect(getCreaturePosition(cid), 14)
return true
end
And it should add a bonus for player for 2 hours, but instead its over after kill the first monster, i mean, in few seconds.
Anybody know what is wrong?