pisquila
New Member
- Joined
- Nov 14, 2023
- Messages
- 28
- Reaction score
- 3
set to charge item when pulling the lever
item: 2160 / quantity 70
item: 2160 / quantity 70
local config = {
daily = "yes", -- allow only one enter per day? (like in global Tibia)
level = 500,
storage = 30015,
entry =
{
{x = 319, y = 669, z = 7},
{x = 319, y = 668, z = 7},
{x = 319, y = 667, z = 7},
{x = 319, y = 666, z = 7}
},
destination =
{
{x = 276, y = 653, z = 7},
{x = 276, y = 653, z = 7},
{x = 276, y = 653, z = 7},
{x = 276, y = 653, z = 7}
}
}
config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.itemid == 1946) then
if(config.daily) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
else
doTransformItem(item.uid, item.itemid - 1)
end
return true
end
if(item.itemid ~= 1945) then
return true
end
local players = {}
for _, position in ipairs(config.entry) do
local pid = getTopCreature(position).uid
if(pid == 0 or not isPlayer(pid) or getCreatureStorage(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
return true
end
table.insert(players, pid)
end
for i, pid in ipairs(players) do
doSendMagicEffect(config.entry, CONST_ME_POFF)
doTeleportThing(pid, config.destination, false)
doSendMagicEffect(config.destination, CONST_ME_ENERGYAREA)
end
doTransformItem(item.uid, item.itemid + 1)
return true
end