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

Multi-Chest script, same chest diff location

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,087
Solutions
15
Reaction score
379
Location
Sweden
YouTube
Joriku
[Tested with 13.21 Canary, running 13.22]
Hi,
wrote a basic multi-chest script which allows you to use the same chest in two different areas. Yes, this is a basic script..

So how it works:
You can now use the same chest, checking the same storage value as the other. So you can find the chest in multiple areas which can only be used once.

1708214313885.png

Installation Guide:
(Put the script into data/scripts/actions or otservbr-data/scripts/actions)
1) Put two chests onto the ground.
2) Put action id: 2000 in both chests.
3) Input 2551 and 2552 unique id's onto the chests.
4) change the storage value or use it as is, keep in mind. You can only use one storage and unique id at a time.
5) change the reward or add more rewards.

Lua:
local action = Action()

-- configurations
local config = {
    chestId = 2472, -- Id of chest, {chestid, secondchestid},
    storage = 2551, -- storage value
    reward = {3043}, -- 3043, crystal coin
}

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- Check if item is a chest of id and storage value is not set
    if item:getId() == config.chestId and player:getStorageValue(config.storage) < 1 then
        player:setStorageValue(config.storage, 1)
        player:addItem(config.reward[1]) -- Give player item from reward
        player:sendCancelMessage("You've found " .. config.reward[1])
        player:getPosition():sendMagicEffect(CONST_ME_BIGCLOUDS)
        print("Found reward")
    elseif player:getStorageValue(config.storage) == 1 then -- Storage exists
        player:sendCancelMessage("Sorry, you cannot claim this chest twice.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        print("elseif message")
    else -- Something else
        player:sendCancelMessage("Something went wrong, please. Contact an administrator regarding your actions.")
        print("Error, chest did not work.. [RandomChestScript]")
    end
    return true
end

action:uid(2551, 2552) -- Allows two creates to use this script
action:register()

Feedback and ideas are more then welcome!
 
Back
Top