• 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 1.X+ How do I remove the guess exhausted. And provide a new one StorageValue?

UnLucky

New Member
Joined
Jul 15, 2021
Messages
36
Reaction score
1
GitHub
UnLucky
TFS 1.2 Client 8.0 HELP!
How good is it to remove this exhausted :
Code:
local time_in_seconds = 1 -- in seconds

local cooldown_id = 123456
and add this one?
Code:
    if creature:getStorageValue(555551) >= os.time()  ,      creature:setStorageValue(555551, os.time() + 1)

I need Fix this Script
V V V
Lua:
local drunk = Condition(CONDITION_DRUNK)
drunk:setParameter(CONDITION_PARAM_TICKS, 60000)
local poison = Condition(CONDITION_POISON)
poison:setParameter(CONDITION_PARAM_DELAYED, true)
poison:setParameter(CONDITION_PARAM_MINVALUE, -50)
poison:setParameter(CONDITION_PARAM_MAXVALUE, -120)
poison:setParameter(CONDITION_PARAM_STARTVALUE, -5)
poison:setParameter(CONDITION_PARAM_TICKINTERVAL, 4000)
poison:setParameter(CONDITION_PARAM_FORCEUPDATE, true)
local time_in_seconds = 1 -- in seconds
local cooldown_id = 123456
local fluidMessage = {
    [2] = "Aaaah...",
    [3] = "Aah...",
    [4] = "Urgh!",
    [5] = "Mmmh.",
    [7] = "Aaaah...",
    [11] = "Urgh!",
    [13] = "Urgh!",
    [15] = "Aah...",
    [19] = "Urgh!",

}

local distillery = {[5513] = 5469, [5514] = 5470}

function onUse(player, item, fromPosition, target, toPosition, isHotkey, cid, exhaust)
if checkSpellCd(player, cooldown_id, time_in_seconds) == false then return false end -- added line for andu's cooldown system
 

    local targetItemType = ItemType(target.itemid)
    if targetItemType and targetItemType:isFluidContainer() then
        if target.type == 0 and item.type ~= 0 then
            target:transform(target:getId(), item.type)
            item:transform(item:getId(), 0)
            return true
        elseif target.type ~= 0 and item.type == 0 then
            target:transform(target:getId(), 0)
            item:transform(item:getId(), target.type)
            return true
        end
    end

    if target.itemid == 1 then
        if item.type == 0 then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")
        elseif target.uid == player.uid then
       
            if item.type == 7 then
                   
                player:addMana(math.random(70, 150))
                toPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
            end

            if table.contains({3, 15, 43}, item.type) then
                player:addCondition(drunk)
            elseif item.type == 4 then
                player:addCondition(poison)        
               
            elseif item.type == 2 then
                player:addHealth(160)
                toPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
               
            end
            player:say(fluidMessage[item.type] or "Gulp.", TALKTYPE_MONSTER_SAY)
            item:transform(item:getId(), 0)
        else
            Game.createItem(2016, item.type, toPosition):decay()
            item:transform(item:getId(), 0)
        end
    else
        local fluidSource = targetItemType and targetItemType:getFluidSource() or 0
        if fluidSource ~= 0 then
            item:transform(item:getId(), fluidSource)
        elseif table.contains(distillery, target.itemid) then
            local tmp = distillery[target.itemid]
            if tmp then
                item:transform(item:getId(), 0)
            else
                player:sendCancelMessage("You have to process the bunch into the distillery to get rum.")
            end
        elseif item.type == 0 then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")
        else
            if toPosition.x == CONTAINER_POSITION then
                toPosition = player:getPosition()
            end
            Game.createItem(2016, item.type, toPosition):decay()
            item:transform(item:getId(), 0)
        end
    end
    return true
end
 
Change line 28 to:

Lua:
if player:getStorageValue(555551) < os.time() then
    return false
end
player:setStorageValue(555551, os.time() + 1)
 
Change line 28 to:

Lua:
if player:getStorageValue(555551) < os.time() then
    return false
end
player:setStorageValue(555551, os.time() + 1)
I did as you wrote, but now I can't use potion.
Any ideas?

Lua:
local drunk = Condition(CONDITION_DRUNK)
drunk:setParameter(CONDITION_PARAM_TICKS, 60000)
local poison = Condition(CONDITION_POISON)
poison:setParameter(CONDITION_PARAM_DELAYED, true)
poison:setParameter(CONDITION_PARAM_MINVALUE, -50)
poison:setParameter(CONDITION_PARAM_MAXVALUE, -120)
poison:setParameter(CONDITION_PARAM_STARTVALUE, -5)
poison:setParameter(CONDITION_PARAM_TICKINTERVAL, 4000)
poison:setParameter(CONDITION_PARAM_FORCEUPDATE, true)
local fluidMessage = {
    [2] = "Aaaah...",
    [3] = "Aah...",
    [4] = "Urgh!",
    [5] = "Mmmh.",
    [7] = "Aaaah...",
    [11] = "Urgh!",
    [13] = "Urgh!",
    [15] = "Aah...",
    [19] = "Urgh!",

}

local distillery = {[5513] = 5469, [5514] = 5470}

function onUse(player, item, fromPosition, target, toPosition, isHotkey, cid)
if player:getStorageValue(555551) < os.time() then
    return false
end
player:setStorageValue(555551, os.time() + 1)
 

    local targetItemType = ItemType(target.itemid)
    if targetItemType and targetItemType:isFluidContainer() then
        if target.type == 0 and item.type ~= 0 then
            target:transform(target:getId(), item.type)
            item:transform(item:getId(), 0)
            return true
        elseif target.type ~= 0 and item.type == 0 then
            target:transform(target:getId(), 0)
            item:transform(item:getId(), target.type)
            return true
        end
    end

    if target.itemid == 1 then
        if item.type == 0 then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")
        elseif target.uid == player.uid then
        
            if item.type == 7 then 
                    
                player:addMana(math.random(70, 150))
                toPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
            end

            if table.contains({3, 15, 43}, item.type) then
                player:addCondition(drunk)
            elseif item.type == 4 then
                player:addCondition(poison)         
                
            elseif item.type == 2 then
                player:addHealth(160)
                toPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
                
            end
            player:say(fluidMessage[item.type] or "Gulp.", TALKTYPE_MONSTER_SAY)
            item:transform(item:getId(), 0)
        else
            Game.createItem(2016, item.type, toPosition):decay()
            item:transform(item:getId(), 0)
        end
    else
        local fluidSource = targetItemType and targetItemType:getFluidSource() or 0
        if fluidSource ~= 0 then
            item:transform(item:getId(), fluidSource)
        elseif table.contains(distillery, target.itemid) then
            local tmp = distillery[target.itemid]
            if tmp then
                item:transform(item:getId(), 0)
            else
                player:sendCancelMessage("You have to process the bunch into the distillery to get rum.")
            end
        elseif item.type == 0 then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")
        else
            if toPosition.x == CONTAINER_POSITION then
                toPosition = player:getPosition()
            end
            Game.createItem(2016, item.type, toPosition):decay()
            item:transform(item:getId(), 0)
        end
    end
    return true
end
 
Sorry I wrote it wrong, it should be like that:

Lua:
if player:getStorageValue(555551) >= os.time() then
    return false
end
player:setStorageValue(555551, os.time() + 1)
 
Back
Top