Lua Looking for special chest script

gohamvsgoku

Member
Joined
Aug 21, 2017
Messages
150
Reaction score
6
Hello guys
I need help to create a chest script that give for player 2000 of exp or 3000 of exp random when use, but with interval of 10 minutes to use again the chest, someone can help with this script? I have forgotten server 1.x
 

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,244
Solutions
71
Reaction score
545
Location
Hell
try
Lua:
local config = {
    delayStorage = 43912,
    delayTime = 10 * 60, -- 10min
    expMin = 2000,
    expMax = 3000
}

function onUse(player, item, fromPosition, itemEx, toPosition)
    local storage = player:getStorageValue(config.delayStorage)
    if storage > os.time() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You may only use this chest every 10min.')
        return true
    end

    local exp = math.random(config.expMin, config.expMax)
    player:addExperience(exp)
    player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You have received ' .. exp .. ' experience.')
    player:setStorageValue(config.delayStorage, config.delayTime + os.time())
    return true
end
 
Top