acho q está na area errada..
é na area de servidores derivados que vc tem q postar esse script ^^
e PS: tente explicar aos usuarios como fazer nas spells que for usar o pouch (é facil explicar, se quiser pode copiar o do pedido la q eu deixei em vermelho)








info
Grupo: Marquês
Registrado: 02/08/12
Posts: 1k
Reputação: +234
Char no Tibia: Maurolkit
/data/actions/scripts crie um arquivo .lua e renomeie para waterRefill.lua e adicione isso dentro:
function onUse(cid, item, fromPosition, itemEx, toPosition) local _ = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825} local slot = getPlayerSlotItem(cid, CONST_SLOTARROW) local water = getWater(slot.uid) local refil = 2 -- % of reffil local add = water == 99 and 1 or refil if getWater(slot.uid) ~= 100 then if isInArray(_, itemEx.itemid) then setWaterPouchPercent(slot.uid, add) end else doPlayerSendCancel(cid, "Your pouch is full") end return true endem actions.xml adicione essa linha:
Agora como fazer para coloca na spell, vá em /data/spells, vá no arquivo da spell desejado, procure o onCastSpell no arquivo, e mude para este.
function onCastSpell(cid, var) local slot = getPlayerSlotItem(cid, CONST_SLOTARROW) local waters = {4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825} local water = true local p = 2 -- quantos porcentos de agua vai usar if getPlayerStorageValue(cid, 372872) < 1 then setWaterPouchPercent(slot.uid, 100) setPlayerStorageValue(cid, 372872, 1) end if slot.uid < 1 then return true end if getWaterInArea(waters, getThingPos(cid), 5, 5) then water = false end if getWater(slot.uid) < p then doPlayerSendTextMessage(cid, 27, "Sorry, you don't have any water") return true end if water then setWaterPouchPercent(slot.uid, getWater(slot.uid) - p) doPlayerSendTextMessage(cid, 27, "You use " .. p .. "% of your pouch now have" .. getWater(slot.uid)) else doPlayerSendTextMessage(cid, 27, "Using ambient water.") end return doCombat(cid, var) endPARTE MUITO IMPORTANTE, NÃO COMETA ERROS.
Vá em /data/libs/050-function e adicione essas três funções:
function setWaterPouchPercent(pouch, percent) doSetItemAttribute(pouch, "water", percent) doSetItemAttribute(pouch, "description", getWater(pouch) .. "% of water in this pouch.") end function getWater(pouch) return getItemAttribute(pouch, "water") end function getWaterInArea(ItemIds, pos, rangex, rangey) -- dalvo for itemId in pairs(ItemIds) do for x = -rangex, rangex do for y = -rangey, rangey do local posi = {x = pos.x + x, y = pos.y + y, z = pos.z} local item = getTileItemById(posi, itemId) if item.uid > 0 and not (x == 0 and y == 0) then return true end end end end return false endQualquer erro postem no tópico.
Editado Abril 22 por Skymagnum