FabianoBN
l|¬¬"|l
Hello,
I want to do, the muck remover work, but when I do use the mucus plug, if stacked,
will use a case for a give error in removing the mucus, but if it goes successful player and has a stack of two or more mucus plug all disappear.
Another situation is that I can not also reward the player with, for example, 10 items id 18413 with removal of a mucus plug.
Below Code:
I appreciate everyone's attention.
I want to do, the muck remover work, but when I do use the mucus plug, if stacked,
will use a case for a give error in removing the mucus, but if it goes successful player and has a stack of two or more mucus plug all disappear.
Another situation is that I can not also reward the player with, for example, 10 items id 18413 with removal of a mucus plug.
Below Code:
Code:
local breakChance = 60
local muckItems = {
[18396] = {18413, 18418, 2158, 8878, 18450, 18394, 2445, 18391, 18414}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if muckItems[itemEx.itemid] ~= nil then
if math.random(100) <= breakChance then
doRemoveItem(itemEx.uid,1)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
doSendMagicEffect(getCreaturePosition(cid),34)
else
local newId = muckItems[itemEx.itemid][math.random(#muckItems[itemEx.itemid])]
doTransformItem(itemEx.uid,newId)
if math.random(100) >= breakChance then
doRemoveItem(itemEx.uid,1)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You removed the Mucus Plug, revealing a "..getItemNameById(newId))
doSendMagicEffect(getCreaturePosition(cid),66)
end
end
doRemoveItem(item.uid,1)
return TRUE
end
return FALSE
end
I appreciate everyone's attention.