• 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!

Lua Adding timer on roshamuul bones

liqeen

Active Member
Joined
Nov 26, 2014
Messages
150
Solutions
1
Reaction score
29
Location
Poland
Hello, I was wondering if it is possible to add a timer on the roshamuul bones after clicking on it. So basically when u click on bones they transform into other id and triggers revertBone function then after clicking again the script should send a message when the bones were used, for example 10min.
TFS 1.3

Lua:
local function revertBone(position, itemId, transformId)
    local item = Tile(position):getItemById(itemId)
    if item then
            item:transform(transformId)
        end
end



function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 10999 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You awaken the boss.')
            item:transform(11000, 10999)
            addEvent(revertBone, 2400000, toPosition, 11000, 10999)
            toPosition:sendMagicEffect(3)
            local monster = Game.createMonster('Goliath', Position(2009, 1791, 7))
           
end
end

Thanks for your time.
 
Solution
Do you wanna add exhaustion to clicking the bones?
Lua:
local config = {
    boneUseStorage = 141567,
    boneUseDelay   = 10 * 60 -- 10min
}

local function secondsToReadable(s)
    local hours   = math.floor(s / 3600)
    local minutes = math.floor(math.mod(s, 3600)/60)
    local seconds = math.floor(math.mod(s, 60))
    return (hours   > 0 and (hours   .. ' hour'   .. (hours   > 1 and 's ' or ' ')) or '') ..
           (minutes > 0 and (minutes .. ' minute' .. (minutes > 1 and 's ' or ' ')) or '') ..
           (seconds > 0 and (seconds .. ' second' .. (seconds > 1 and 's ' or ' ')) or '')
end

local function revertBone(position, itemId, transformId)
    local item = Tile(position):getItemById(itemId)
    if item then...
Do you wanna add exhaustion to clicking the bones?
Lua:
local config = {
    boneUseStorage = 141567,
    boneUseDelay   = 10 * 60 -- 10min
}

local function secondsToReadable(s)
    local hours   = math.floor(s / 3600)
    local minutes = math.floor(math.mod(s, 3600)/60)
    local seconds = math.floor(math.mod(s, 60))
    return (hours   > 0 and (hours   .. ' hour'   .. (hours   > 1 and 's ' or ' ')) or '') ..
           (minutes > 0 and (minutes .. ' minute' .. (minutes > 1 and 's ' or ' ')) or '') ..
           (seconds > 0 and (seconds .. ' second' .. (seconds > 1 and 's ' or ' ')) or '')
end

local function revertBone(position, itemId, transformId)
    local item = Tile(position):getItemById(itemId)
    if item then
        item:transform(transformId)
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 10999 then
        local lastUsedStorage = player:setStorageValue(config.boneUseStorage)
        if lastUsedStorage > os.time() then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have to wait ' .. secondsToReadable(lastUsedStorage - os.time()) .. ' to use this again.')
            return true
        end

        player:setStorageValue(config.boneUseStorage, os.time() + config.boneUseDelay)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You awaken the boss.')
        item:transform(11000, 10999)
        toPosition:sendMagicEffect(3)
        Game.createMonster('Goliath', Position(2009, 1791, 7))
        addEvent(revertBone, 2400000, toPosition, 11000, 10999)
    end
end
 
Solution
Do you wanna add exhaustion to clicking the bones?
Lua:
local config = {
    boneUseStorage = 141567,
    boneUseDelay   = 10 * 60 -- 10min
}

local function secondsToReadable(s)
    local hours   = math.floor(s / 3600)
    local minutes = math.floor(math.mod(s, 3600)/60)
    local seconds = math.floor(math.mod(s, 60))
    return (hours   > 0 and (hours   .. ' hour'   .. (hours   > 1 and 's ' or ' ')) or '') ..
           (minutes > 0 and (minutes .. ' minute' .. (minutes > 1 and 's ' or ' ')) or '') ..
           (seconds > 0 and (seconds .. ' second' .. (seconds > 1 and 's ' or ' ')) or '')
end

local function revertBone(position, itemId, transformId)
    local item = Tile(position):getItemById(itemId)
    if item then
        item:transform(transformId)
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 10999 then
        local lastUsedStorage = player:setStorageValue(config.boneUseStorage)
        if lastUsedStorage > os.time() then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have to wait ' .. secondsToReadable(lastUsedStorage - os.time()) .. ' to use this again.')
            return true
        end

        player:setStorageValue(config.boneUseStorage, os.time() + config.boneUseDelay)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You awaken the boss.')
        item:transform(11000, 10999)
        toPosition:sendMagicEffect(3)
        Game.createMonster('Goliath', Position(2009, 1791, 7))
        addEvent(revertBone, 2400000, toPosition, 11000, 10999)
    end
end
Yeah sure about the exhaustion thing, but there seems to be a problem with the previous one, it drops me this error when I click the bones.
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/boss1.lua:onUse
data/actions/scripts/boss1.lua:25: attempt to compare number with boolean
stack traceback:
        [C]: in function '__lt'
        data/actions/scripts/boss1.lua:25: in function <data/actions/scripts/boss1.lua:22>
 
Yeah sure about the exhaustion thing, but there seems to be a problem with the previous one, it drops me this error when I click the bones.
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/boss1.lua:onUse
data/actions/scripts/boss1.lua:25: attempt to compare number with boolean
stack traceback:
        [C]: in function '__lt'
        data/actions/scripts/boss1.lua:25: in function <data/actions/scripts/boss1.lua:22>
change
Lua:
local lastUsedStorage = player:setStorageValue(config.boneUseStorage)
to
Lua:
local lastUsedStorage = player:getStorageValue(config.boneUseStorage)
 
Back
Top