• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X set a time of 2 hours to be able to use the item again

kfalls

New Member
Joined
Jan 11, 2018
Messages
16
Reaction score
1
version 0.3.6 tfs


local config = {

effect = 0, --
textType = 0, --
msg = "Mana Refilled." --

}

function onUse(cid, item, fromPosition, itemEx, toPosition)
doCreatureAddMana(cid, getCreatureMaxMana(cid))
doRemoveItem(item.uid, 1)
doSendMagicEffect(fromPosition, config.effect)
return true
end
 
LUA:
local config = {
    effect = 17,
    cooldownStorage = 45001,
    cooldownTime = 7200 -- 2 hours in seconds
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local currentTime = os.time()
    local lastUsed = getPlayerStorageValue(cid, config.cooldownStorage)
    
    if lastUsed > 0 and currentTime - lastUsed < config.cooldownTime then
        local remainingTime = config.cooldownTime - (currentTime - lastUsed)
        doPlayerSendCancel(cid, "You need to wait " .. math.ceil(remainingTime / 60) .. " minutes before using this item again.")
        return false
    end
    setPlayerStorageValue(cid, config.cooldownStorage, currentTime)
    
    doCreatureAddMana(cid, getCreatureMaxMana(cid))
    doSendMagicEffect(fromPosition, config.effect)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Mana Refilled.")
    doRemoveItem(item.uid, 1)
    return true
end
 
ty .+rep
Post automatically merged:

LUA:
local config = {
    effect = 17,
    cooldownStorage = 45001,
    cooldownTime = 7200 -- 2 hours in seconds
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local currentTime = os.time()
    local lastUsed = getPlayerStorageValue(cid, config.cooldownStorage)
   
    if lastUsed > 0 and currentTime - lastUsed < config.cooldownTime then
        local remainingTime = config.cooldownTime - (currentTime - lastUsed)
        doPlayerSendCancel(cid, "You need to wait " .. math.ceil(remainingTime / 60) .. " minutes before using this item again.")
        return false
    end
    setPlayerStorageValue(cid, config.cooldownStorage, currentTime)
   
    doCreatureAddMana(cid, getCreatureMaxMana(cid))
    doSendMagicEffect(fromPosition, config.effect)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Mana Refilled.")
    doRemoveItem(item.uid, 1)
    return true
end
When a character on the account uses the item, the other characters on the account cannot use the item either and have a cooldown time. Is there a way to fix this?
 
Last edited:
Back
Top