Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
3
Indexable
local price_backpack = 1000
local exhaust_storage = 1111 --change this to an unused storage

function onSay(player, words, param)

    local lastUse = player:getStorageValue(exhaust_storage)
    if lastUse > os.time() then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendCancelMessage("Please wait 10 minutes before using this again!")
        return false
    end

    if player:removeMoney(price_backpack) then
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        player:addItem(2004, 1)
        player:setStorageValue(exhaust_storage, os.time() + 600)
    else
        if player:withdrawMoney(price_backpack) then
            if player:removeMoney(price_backpack) then
                player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
                player:addItem(2004, 1)
                player:setStorageValue(exhaust_storage, os.time() + 600)
            end
        else
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            player:sendCancelMessage("You don't have enought money. Not even in your bank!")
        end
    end

    return true
end