Untitled
unknown
lua
3 years ago
1.4 kB
7
Indexable
local config = {
scroll_id = 12466;
scroll_amount = 1000;
effect = CONST_ME_FIREWORK_RED;
no_cap = "No tienes suficiente capacidad. Necesitas almenos %d.00 oz de capacidad.";
no_espacio = "No tienes suficiente espacio en tu backpack.";
todo_bien = "Has abierto una caja de x%d %s!";
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.aid == 3822 then
return false
end
local it = getItemInfo(config.scroll_id)
local itemsWeight = math.ceil(it.weight * config.scroll_amount)
if getPlayerFreeCap(cid) < itemsWeight then
return doPlayerSendCancel(cid, config.no_espacio:format(searchFreeslots))
end
local bag = doCreateItemEx(1988, 1)
if doPlayerAddItemEx(cid, bag) ~= RETURNVALUE_NOERROR then
return doPlayerSendCancel(cid, config.no_espacio:format(searchFreeslots))
end
-- si vemos que si puede agregar la backpack al player, entonces le metemos los scrolls a la backpack
local amount = config.scroll_amount
while (amount > 0) do
local count = it.stackable and math.min(100, amount) or 1
amount = amount - count
doAddContainerItemEx(bag, doCreateItemEx(config.scroll_id, count))
end
doSendMagicEffect(getThingPos(cid), config.effect)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.todo_bien:format(config.scroll_amount, getItemNameById(config.scroll_id)))
return true
endEditor is loading...