• 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+ Use of item with time.

Piifafa

Member
Joined
Apr 16, 2023
Messages
67
Reaction score
16
I would like my item not to be usable again until it expires.

Code:
<action itemid="5498" script="expboostsmall.lua"/>
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    local storageValue = player:getStorageValue(81100)
    
    if storageValue <= os.time() then
        local doubleExpDuration = 30 * 60 -- 30 minutes in seconds
        local newExpEndTime = os.time() + doubleExpDuration
        
        player:setStorageValue(81100, newExpEndTime)
        player:say("You have just activated 30 minutes of Double Experience!", TALKTYPE_MONSTER_SAY)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the daily bonus.")
    end
    
    item:remove()
    return true
end
 
Solution
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    local storageValue = player:getStorageValue(81100)
    
    if storageValue <= os.time() then
        local doubleExpDuration = 30 * 60 -- 30 minutes in seconds
        local newExpEndTime = os.time() + doubleExpDuration
        
        player:setStorageValue(81100, newExpEndTime)
        player:say("You have just activated 30 minutes of Double Experience!", TALKTYPE_MONSTER_SAY)
        item:remove()
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the daily bonus.")
    end
    
    return true
end
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    local storageValue = player:getStorageValue(81100)
    
    if storageValue <= os.time() then
        local doubleExpDuration = 30 * 60 -- 30 minutes in seconds
        local newExpEndTime = os.time() + doubleExpDuration
        
        player:setStorageValue(81100, newExpEndTime)
        player:say("You have just activated 30 minutes of Double Experience!", TALKTYPE_MONSTER_SAY)
        item:remove()
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the daily bonus.")
    end
    
    return true
end
 
Solution
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    local storageValue = player:getStorageValue(81100)
   
    if storageValue <= os.time() then
        local doubleExpDuration = 30 * 60 -- 30 minutes in seconds
        local newExpEndTime = os.time() + doubleExpDuration
       
        player:setStorageValue(81100, newExpEndTime)
        player:say("You have just activated 30 minutes of Double Experience!", TALKTYPE_MONSTER_SAY)
        item:remove()
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the daily bonus.")
    end
   
    return true
end
thank you thank you very much!
 
Back
Top