Udun
Well-Known Member
- Joined
- Jan 5, 2012
- Messages
- 199
- Solutions
- 2
- Reaction score
- 69
Hi guys! I'm having problems with this script. TFS 1.2, Tibia 10.98
Should do this:
The player use a shovel (or any item of your election) and you can make a hole in any ground (grass, desert, snow etc.) could be a custom "hole" item, and you can hide items inside like a depot, then after a X time the hole will decay to the gound that was before and the char can back later and take the buried stuff, it means, all the grounds of the server could be a potential depot or a place to hide things (lootbags, weapons, corpses, gp, etc) without need to go to the dp
Thanks alot!
Should do this:
The player use a shovel (or any item of your election) and you can make a hole in any ground (grass, desert, snow etc.) could be a custom "hole" item, and you can hide items inside like a depot, then after a X time the hole will decay to the gound that was before and the char can back later and take the buried stuff, it means, all the grounds of the server could be a potential depot or a place to hide things (lootbags, weapons, corpses, gp, etc) without need to go to the dp
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray({4526}, itemEx.itemid) then -- object ground ID that triggers the action
local player = Player(cid)
local storageKey = "holeStorage_" .. itemEx.uid
if player:getStorageValue(storageKey) ~= 1 then
-- create a new container and put it inside the hole
local container = player:getPlayerSlotItem(2594) -- container ID
if not container then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "There's not enough room for more items.")
return true
end
for i = 1, container:getCapacity() do
container:addItem(10) -- add the ammount if slots inside the container
end
doTransformItem(itemEx.uid, 8249) -- hole ID
doTileAddItem(fromPosition, container:getId(), 1, container) -- puts container inside the hole
player:setStorageValue(storageKey, container:getId()) -- storage ID of cointainer in the container chatacter system
addEvent(function()
-- Recover the objects in the container and eliminate it
local holeContainer = Container(player:getStorageValue(storageKey))
if holeContainer then
for _, item in ipairs(holeContainer:getItems()) do
player:addItemEx(item, false) -- Add the objects to the character
end
holeContainer:remove()
end
-- Return the hole to a normal gound item and eliminates the storage
doTransformItem(itemEx.uid, 4526) -- original ground ID
local holeItems = getTileItemsByType(fromPosition, ITEM_TYPE_HOLE)
for i = 1, #holeItems do
local item = holeItems[i]
doSendMagicEffect(item:getPosition(), CONST_ME_POFF) -- effect when hole dissapear
item:remove()
end
player:setStorageValue(storageKey, -1)
end, 10000) -- Milisenconds "10000 = 10 seconds to the hole gets closed
return true
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You already have created a hole here. Use the shovel again to recover your objects.")
end
end
return true
end
Thanks alot!
Last edited: