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

RevScripts [1.3]Make this script deley to use 1s

Scrollia

Banned User
Joined
Apr 26, 2021
Messages
100
Reaction score
15
How to make it deley to another one use by 1 sec, tryting to avoid spamming?

Lua:
local setting = {
    [25377] = {count = 2},
    [25172] = {count = 1}
}


local tibiaCoin = Action()


function tibiaCoin.onUse(player, item, fromPosition, target, toPosition, isHotkey)
        local foundItem = setting[item.itemid]
            if not(foundItem) then
            return
        end
        player:addTibiaCoins(foundItem.count)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have received '..foundItem.count..' tibia coins.')
        item:remove(1)
        return true
end
for k, v in pairs(setting) do
    tibiaCoin:id(k)
end
tibiaCoin:register()
 
Solution
set storage to player.

example:
Lua:
local setting = {
    [25377] = {count = 2},
    [25172] = {count = 1}
}

local config = {
    usageStorage = 898321,
    nextUseDelay = 1 -- seconds
}

local tibiaCoin = Action()
function tibiaCoin.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(config.usageStorage) > os.time() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'Slow down.')
        return true
    end

    local foundItem = setting[item.itemid]
    if not(foundItem) then
        return true
    end

    player:setStorageValue(config.usageStorage, os.time() + config.nextUseDelay)
    player:addTibiaCoins(foundItem.count)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)...
set storage to player.

example:
Lua:
local setting = {
    [25377] = {count = 2},
    [25172] = {count = 1}
}

local config = {
    usageStorage = 898321,
    nextUseDelay = 1 -- seconds
}

local tibiaCoin = Action()
function tibiaCoin.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(config.usageStorage) > os.time() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'Slow down.')
        return true
    end

    local foundItem = setting[item.itemid]
    if not(foundItem) then
        return true
    end

    player:setStorageValue(config.usageStorage, os.time() + config.nextUseDelay)
    player:addTibiaCoins(foundItem.count)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have received '..foundItem.count..' tibia coins.')
    item:remove(1)
    return true
end
for k, v in pairs(setting) do
    tibiaCoin:id(k)
end
tibiaCoin:register()
 
Solution
Back
Top