• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved [Script] Muck Remover

FabianoBN

l|¬¬"|l
Joined
Jan 23, 2009
Messages
745
Reaction score
22
Location
Goias - Brazil
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:

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.
 
Lua:
local nTable = {[18396] = {18413, 18418, 2158, 8878, 18450, 18394, 2445, 18391, 18414}}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if nTable[itemEx.itemid] then
		if 60 < math.random(100) then
			doRemoveItem(cid, itemEx.uid,1)
		else
			local nID = nTable[itemEx.itemid][math.random(#nTable[itemEx.itemid])]
            doRemoveItem(cid, itemEx.uid,1)
			doPlayerAddItem(cid, nID, 1)
		end
	end
end

I have no knowledge about tfs so fix the errors if there is any, I based it upon your code.
 
I guess you could do something like this:

Lua:
local nTable = {[18396] = {18413, 18418, 2158, 8878, 18450, 18394, 2445, 18391, 18414}}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if nTable[itemEx.itemid] then
		if 60 < math.random(100) then
			doRemoveItem(cid, itemEx.uid,1)
		else
			local nID = nTable[itemEx.itemid][math.random(#nTable[itemEx.itemid])]
			if nID == 18413 then
			doRemoveItem(cid, itemEx.uid,1)
			doPlayerAddItem(cid,nID, 10)
			else
			doRemoveItem(cid, itemEx.uid,1)
			doPlayerAddItem(cid, nID, 1)
			end
		end
	end
end
 
Last edited:
Back
Top