• 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!

[Action] Tool not working properly :/

kessykins

Intermediate OT User
Joined
Mar 15, 2010
Messages
297
Reaction score
105
Ok so I'm trying to adjust this so 1 tool can be used on 3 seperate items to create different items..
The base of this lua was from a professions script however I screwed up trying to adjust it

This is the error it keeps giving me x.x
Code:
[23/08/2010 22:20:26] [Error - Action Interface] 
[23/08/2010 22:20:26] data/actions/scripts/tools/slimy_common.lua:onUse
[23/08/2010 22:20:26] Description: 
[23/08/2010 22:20:26] data/actions/scripts/tools/slimy_common.lua:49: attempt to index local 'item2' (a nil value)
[23/08/2010 22:20:26] stack traceback:
[23/08/2010 22:20:26] 	data/actions/scripts/tools/slimy_common.lua:49: in function <data/actions/scripts/tools/slimy_common.lua:48>

What did I do wrong?

Code:
local config = {
	msgType = MESSAGE_INFO_DESCR,
	cancel = "Your untrained hands broke the slimy object. Get a higher fist level to have a higher success rate!",
	skill = SKILL_FIST,
	skillReq = 10
}
	
local t = {
	--items common slimy objects can turn into
	[{1, 200}] = {skill = 15, commonitem = 1294, name = "small stone"},
	[{201, 400}] = {skill = 15, commonitem = 4839, name = "bottle"},
	[{401, 500}] = {skill = 15, commonitem = 2333, name = "stamped letter"},
	[{501, 700}] = {skill = 15, commonitem = 5951, name = "fish tail"},
	[{701, 1000}] = {skill = 1, destroyobj = "The slimy object was too delicate to clean off. It broke!"},
	[{1001, 1500}] = {skill = 1, destroyvase = "You broke the fragile vase."}
	}

local q = {
	--items uncommon slimy objects can turn into
	[{1, 100}] = {skill = 25, uncommonitem = 5917, name = "bandana"},
	[{101, 400}] = {skill = 25, uncommonitem = 2050, name = "torch"},
	[{401, 500}] = {skill = 25, uncommonitem = 5918, name = "pirate knee breeches"},
	[{501, 600}] = {skill = 25, uncommonitem = 5462, name = "pirate boots"},
	[{601, 700}] = {skill = 25, uncommonitem = 2670, name = "shrimp"},
	[{701, 900}] = {skill = 25, uncommonitem = 2009, name = "green flask"},
	[{901, 1100}] = {skill = 35, uncommonitem = 2260, name = "blank rune"},
	[{1101, 1200}] = {skill = 35, uncommonitem = 2266, name = "antidote rune"},
	[{1201, 1500}] = {skill = 1, destroyobj = "The slimy object was too delicate to clean off. It broke!"},
	[{1501, 2000}] = {skill = 1, destroyvase = "You broke the fragile vase."}
	}
 
 local w = {
	--items uncommon slimy objects can turn into

	[{1, 200}] = {skill = 45, rareitem = 5899, name = "turtle shell"},	
	[{201, 400}] = {skill = 45, rareitem = 6097, name = "hook"},
	[{401, 600}] = {skill = 55, rareitem = 5909, name = "white piece of cloth"},
	[{601, 800}] = {skill = 55, rareitem = 5914, name = "yellow piece of cloth"},
	[{801, 1000}] = {skill = 55, rareitem = 5912, name = "blue piece of cloth"},
	[{1001,1300}] = {skill = 55, rareitem = 7364, name = "sniper arrow"},	
	[{1301, 1580}] = {skill = 60, rareitem = 10553, name = "uncommon slimy object"},	
	[{1581, 1700}] = {skill = 60, rareitem = 10557, name = "rare slimy object"},		
	[{1701, 1810}] = {skill = 60, rareitem = 11219, name = "gold compass"},
	[{1811, 2111}] = {skill = 1, destroyobj = "The slimy object was too delicate to clean off. It broke!"},
	[{2112, 2612}] = {skill = 1, destroyvase = "You broke the fragile vase."}
	}

function onUse(cid, commonitem, uncommonitem, rareitem, fromposition, item2, toposition)
	if isInArray(config.t, config.q, config.w, item2.itemid) and config.skillReq <= getPlayerSkill(cid, config.skill) then
  if item2.itemid == 0 then
  return 0
  end
  end
		if item2.itemid == 10556 then
		local r = math.random(1500), 1, nil	
		local skill = getPlayerSkill(cid, config.skill)
		for i, k in pairs(t) do
			if r >= i[1] and r <= i[2] then
				if skill >= k.skill then
					if k.commonitem then
						doPlayerAddItem(cid, k.commonitem, 1)
						doRemoveItem(item2.uid, 1)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You cleaned off a "..k.name.."!")
						doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
					end
					if k.destroyobj then
						doRemoveItem(item2.uid, 1)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, k.destroyobj)
						doSendMagicEffect(getThingPos(cid), k.destroyobj and CONST_ME_BLOCKHIT)
					end
					if k.destroyvase then
						doRemoveItem(item2.uid, 1)
						doRemoveItem(commonitem.uid, 1)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, k.destroyvase)
						doSendMagicEffect(getThingPos(cid), k.destroyvase and CONST_ME_WATERSPLASH)
						doPlayerAddItem(cid, 2010, 1)
					end	
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, config.cancel)
					doSendMagicEffect(getThingPos(cid), CONST_ME_BLOCKHIT)
					doRemoveItem(item2.uid, 1)
				end
			end
		end		
	else
		if item2.itemid == 10553 then
		local r = math.random(2000), 1, nil	
		local skill = getPlayerSkill(cid, config.skill)
		for j, l in pairs(q) do
			if r >= j[1] and r <= j[2] then
				if skill >= j.skill then
					if j.uncommonitem then
						doPlayerAddItem(cid, j.uncommonitem, 1)
						doRemoveItem(item2.uid, 1)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You cleaned off a "..j.name.."!")
						doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
					end
					if j.destroyobj then
						doRemoveItem(item2.uid, 1)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, j.destroyobj)
						doSendMagicEffect(getThingPos(cid), j.destroyobj and CONST_ME_BLOCKHIT)
					end
					if j.destroyvase then
						doRemoveItem(item2.uid, 1)
						doRemoveItem(uncommonitem.uid, 1)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, j.destroyvase)
						doSendMagicEffect(getThingPos(cid), j.destroyvase and CONST_ME_WATERSPLASH)
						doPlayerAddItem(cid, 2010, 1)
					end	
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, config.cancel)
					doSendMagicEffect(getThingPos(cid), CONST_ME_BLOCKHIT)
					doRemoveItem(item2.uid, 1)
				end
			end
		end		
	else
		if item2.itemid == 10557 then
		local r = math.random(2612), 1, nil	
		local skill = getPlayerSkill(cid, config.skill)
		for l, m in pairs(w) do
			if r >= l[1] and r <= l[2] then
				if skill >= m.skill then
					if m.commonitem then
						doPlayerAddItem(cid, m.commonitem, 1)
						doRemoveItem(item2.uid, 1)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You cleaned off a "..m.name.."!")
						doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
					end
					if m.destroyobj then
						doRemoveItem(item2.uid, 1)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, m.destroyobj)
						doSendMagicEffect(getThingPos(cid), m.destroyobj and CONST_ME_BLOCKHIT)
					end
					if m.destroyvase then
						doRemoveItem(item2.uid, 1)
						doRemoveItem(commonitem.uid, 1)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, m.destroyvase)
						doSendMagicEffect(getThingPos(cid), m.destroyvase and CONST_ME_WATERSPLASH)
						doPlayerAddItem(cid, 2010, 1)
					end	
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, config.cancel)
					doSendMagicEffect(getThingPos(cid), CONST_ME_BLOCKHIT)
					doRemoveItem(item2.uid, 1)
				end
			end
		end		
	else
end	
	return 0
	end
return 1
end
end
 
Last edited:
Lua:
local config = {
	cancel = 'Your untrained hands broke the slimy object. Get a higher fist level to have a higher success rate!',
	skill = SKILL_FIST
}

local t = {
	[10556] = {
		--items common slimy objects can turn into
		size = 1500,
		[{1,	200}] = {skill = 15, item = 1294},
		[{201,	400}] = {skill = 15, item = 4839},
		[{401,	500}] = {skill = 15, item = 2333},
		[{501,	700}] = {skill = 15, item = 5951},
		[{701,	1000}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{1001,	1500}] = {destroyvase = 'You broke the fragile vase.'}
	},
	[10553] = {
		--items uncommon slimy objects can turn into
		size = 2000,
		[{1,	100}] = {skill = 25, item = 5917},
		[{101,	400}] = {skill = 25, item = 2050},
		[{401,	500}] = {skill = 25, item = 5918},
		[{501,	600}] = {skill = 25, item = 5462},
		[{601,	700}] = {skill = 25, item = 2670},
		[{701,	900}] = {skill = 25, item = 2009},
		[{901,	1100}] = {skill = 35, item = 2260},
		[{1101,	1200}] = {skill = 35, item = 2266},
		[{1201,	1500}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{1501,	2000}] = {destroyvase = 'You broke the fragile vase.'}
	},
	[10557] = {
		--items rare slimy objects can turn into
		size = 2612,
		[{1,	200}] = {skill = 45, item = 5899},	
		[{201,	400}] = {skill = 45, item = 6097},
		[{401,	600}] = {skill = 55, item = 5909},
		[{601,	800}] = {skill = 55, item = 5914},
		[{801,	1000}] = {skill = 55, item = 5912},
		[{1001,	1300}] = {skill = 55, item = 7364},	
		[{1301,	1580}] = {skill = 60, item = 10553},	
		[{1581,	1700}] = {skill = 60, item = 10557},		
		[{1701,	1810}] = {skill = 60, item = 11219},
		[{1811,	2111}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{2112,	2612}] = {destroyvase = 'You broke the fragile vase.'}
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[itemEx.itemid]
	if v then
		local r, skill = math.random(v.size), getPlayerSkill(cid, config.skill)
		for i, k in pairs(v) do
			if i ~= 'size' and r >= i[1] and r <= i[2] then
				local pos = getThingPos(cid)
				doChangeTypeItem(itemEx.uid, itemEx.type - 1)
				if not k.skill or skill >= k.skill then
					if k.item then
						doPlayerAddItem(cid, k.item, 1)
						local article = getItemInfo(k.item).article
						doCreatureSay(cid, 'You cleaned off ' .. (article ~= '' and article .. ' ' or '') .. getItemInfo(k.item).name .. '!', TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
					elseif k.destroyobj then
						doCreatureSay(cid, k.destroyobj, TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
					elseif k.destroyvase then
						doRemoveItem(item.uid)
						doCreatureSay(cid, k.destroyvase, TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_WATERSPLASH)
						doPlayerAddItem(cid, 2010, 1)
					end
				else
					doCreatureSay(cid, config.cancel, TALKTYPE_ORANGE_1, false, cid)
					doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
					doRemoveItem(itemEx.uid, 1)
				end
				break
			end
		end
		return true
	end
end
 
Last edited:
It works perfectly! Thanks!

slimycykotitan.png
 
Hmm

I tried adding more loot possibilities to the lua but I broke it x.xxx

What did I do wrong x.x

Code:
[29/08/2010 12:09:04] [Error - Action Interface] 
[29/08/2010 12:09:04] data/actions/scripts/tools/slimy_common.lua:onUse
[29/08/2010 12:09:04] Description: 
[29/08/2010 12:09:04] data/actions/scripts/tools/slimy_common.lua:112: attempt to compare nil with number
[29/08/2010 12:09:04] stack traceback:
[29/08/2010 12:09:04] 	data/actions/scripts/tools/slimy_common.lua:112: in function <data/actions/scripts/tools/slimy_common.lua:107>

Code:
local config = {
	cancel = 'Your untrained hands broke the slimy object. Get a higher fist level to have a higher success rate!',
	skill = SKILL_FIST
}
 
local t = {
	[10556] = {
		--items common slimy objects can turn into
		size = 211,
		[{1,	50}] = {skill = 15, item = 1294},   --small stone
		[{51,	52}] = {skill = 15, item = 7636},   --empty potion flask
		[{53,	54}] = {skill = 15, item = 7635},   --empty potion flask	
		[{55,	56}] = {skill = 15, item = 7634},   --empty potion flask		
		[{57,	58}] = {skill = 15, item = 2333},   --letter to markwin
		[{59,	60}] = {skill = 15, item = 5951},   --fish tail
		[{61,	62}] = {skill = 15, item = 2236},   --torn book
		[{63,	64}] = {skill = 15, item = 2240},	 --fish remains
		[{65,	66}] = {skill = 15, item = 2226},	 --fishbone
		[{67,	68}] = {skill = 15, item = 2232},	 --broken brown glass
		[{69,	70}] = {skill = 15, item = 2228},	 --broken pottery
		[{71,	72}] = {skill = 15, item = 2252},	 --wooden trash
		[{73,	74}] = {skill = 15, item = 2251},	 --wooden trash
		[{75,	76}] = {skill = 15, item = 2115},	 --broken piggy bank
		[{77,	78}] = {skill = 15, item = 2816}, 	 --dead rat
		[{79,	80}] = {skill = 15, item = 2815}, 	 --dead rat
		[{81,	82}] = {skill = 15, item = 2813}, 	 --dead rat
		[{83,	84}] = {skill = 15, item = 1947},	 --blank paper
		[{85,	86}] = {skill = 15, item = 1954},	 --paper
		[{87,	88}] = {skill = 15, item = 2013},	 --cup
		[{89,	90}] = {skill = 15, item = 2005},	 --bucket
		[{91,	92}] = {skill = 15, item = 5901},	 --piece of wood	
		[{93,	94}] = {skill = 15, item = 2819},	 --snake
		[{95,	96}] = {skill = 15, item = 2148},   --gold coin
		[{97,	98}] = {skill = 15, item = 2238},	 --worn leather boots
		[{99,	100}] = {skill = 15, item = 2237},   --dirty cape
		[{101,	102}] = {skill = 15, item = 1967},	 -- parchment
		[{103,	104}] = {skill = 15, item = 2260},	 --blank rune
		[{105,	106}] = {skill = 25, item = 2120},	 --rope
		[{107,	108}] = {skill = 25, item = 2389},	 --spear		
		[{109,	110}] = {skill = 25, item = 2132},   --silver amulet
		[{111,	120}] = {skill = 25, item = 8820},	 --mage hat
		[{121,  130}] = {skill = 25, item = 2399},	 --throwing star
		[{131,	140}] = {skill = 25, item = 2229},	 --skull
		[{141,	150}] = {skill = 25, item = 2379},	 --dagger	
		[{151,	152}] = {skill = 25, item = 2410},	 --throwing knife
		[{153,	154}] = {skill = 25, item = 2543},	 --bolt
		[{155,	156}] = {skill = 25, item = 2544},	 --arrow
		[{157,	158}] = {skill = 25, item = 1958},	 --book	
		[{159,	160}] = {skill = 35, item = 2384},	 --rapier
		[{161,	162}] = {skill = 35, item = 2510},   --plate shield
		[{163,	164}] = {skill = 35, item = 3937},	 --trough kit
		[{165,	166}] = {skill = 35, item = 1989},	 --basket
		[{167,	168}] = {skill = 35, item = 4847},	 --simple dress
		[{169,	170}] = {skill = 45, item = 6087},	 --music sheet
		[{171,	172}] = {skill = 45, item = 7618},	 --small health potion
		[{173,	174}] = {skill = 45, item = 7620},	 --small mana potion			
		[{175,	176}] = {skill = 55, item = 5878},	 --minotaur leather
		[{177,	178}] = {skill = 55, item = 5876},	 --lizard leather		
		[{179,	180}] = {skill = 55, item = 5890},	 --chicken feather
		[{181,	182}] = {skill = 55, item = 5941},	 --wooden stake
		[{183,	184}] = {skill = 55, item = 6125},	 --tortoise egg
		[{185,	186}] = {skill = 55, item = 5944},	 --soul orb
		[{187,	188}] = {skill = 55, item = 2231},	 --big bone	
		[{189,	190}] = {skill = 55, item = 2230},	 --bone
		[{191,	192}] = {skill = 55, item = 5902},	 --honeycomb	
		[{193,	194}] = {skill = 55, item = 5921},	 --heaven blossom
		[{195,	196}] = {skill = 55, item = 5948},	 --red dragon leather		
		[{197,	198}] = {skill = 55, item = 5877},	 --green dragon leather	
		[{199,	200}] = {skill = 55, item = 2114},	 --piggy bank
		[{201,	203}] = {skill = 65, item = 2186},	 --moonlight rod		
		[{204,	205}] = {skill = 65, item = 2190},	 --wand of vortex	
		[{206,	207}] = {skill = 65, item = 2191},	 --wand of dragonbreath			
		[{208,	209}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{210, 211}] = {destroyvase = 'You broke the fragile vase.'}
	},
	[10553] = {
		--items uncommon slimy objects can turn into
		size = 2000,
		[{1,	100}] = {skill = 25, item = 5917},
		[{101,	400}] = {skill = 25, item = 2050},
		[{401,	500}] = {skill = 25, item = 5918},
		[{501,	600}] = {skill = 25, item = 5462},
		[{601,	700}] = {skill = 25, item = 2670},
		[{701,	900}] = {skill = 25, item = 2009},
		[{901,	1100}] = {skill = 35, item = 2260},
		[{1101,	1200}] = {skill = 35, item = 2266},
		[{1201,	1500}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{1501,	2000}] = {destroyvase = 'You broke the fragile vase.'}
	},
	[10557] = {
		--items rare slimy objects can turn into
		size = 2612,
		[{1,	200}] = {skill = 45, item = 5899},	
		[{201,	400}] = {skill = 45, item = 6097},
		[{401,	600}] = {skill = 55, item = 5909},
		[{601,	800}] = {skill = 55, item = 5914},
		[{801,	1000}] = {skill = 55, item = 5912},
		[{1001,	1300}] = {skill = 55, item = 7364},	
		[{1301,	1580}] = {skill = 60, item = 10553},	
		[{1581,	1700}] = {skill = 60, item = 10557},		
		[{1701,	1810}] = {skill = 60, item = 11213},
		[{1811,	2111}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{2112,	2612}] = {destroyvase = 'You broke the fragile vase.'}
	}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[itemEx.itemid]
	if v then
		local r, skill = math.random(v.size), getPlayerSkill(cid, config.skill)
		for i, k in pairs(v) do
			if i ~= size and r >= i[1] and r <= i[2] then
				local pos = getThingPos(cid)
				doChangeTypeItem(itemEx.uid, itemEx.type - 1)
				if not k.skill or skill >= k.skill then
					if k.item then
						doPlayerAddItem(cid, k.item, 1)
						local article = getItemInfo(k.item).article
						doCreatureSay(cid, 'You cleaned off ' .. (article ~= '' and article .. ' ' or '') .. getItemInfo(k.item).name .. '!', TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
					elseif k.destroyobj then
						doCreatureSay(cid, k.destroyobj, TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
					elseif k.destroyvase then
						doCreatureSay(cid, k.destroyvase, TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_WATERSPLASH)
						doPlayerAddItem(cid, 2010, 1)
					end
				else
					doCreatureSay(cid, config.cancel, TALKTYPE_ORANGE_1, false, cid)
					doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
					doRemoveItem(itemEx.uid, 1)
				end
				break
			end
		end
		return true
	end
end
 
:eek: that shouldn't be happening, everything seems fine

you get the error when you use it on a common slimy object?
 
whoops, change
Code:
			if i ~= size and r >= i[1] and r <= i[2] then
to
Code:
			if i ~= [B][COLOR="red"]'[/COLOR][/B]size[B][COLOR="red"]'[/COLOR][/B] and r >= i[1] and r <= i[2] then
my fault, sorry for the trouble
 
Oook after more testing.. we found that when a level 8 player with fisting 10 tries to clean an item and breaks it.. this error appears x.x

[01/09/2010 02:23:05] [Error - Action Interface]
[01/09/2010 02:23:05] data/actions/scripts/tools/slimy_common.lua:eek:nUse
[01/09/2010 02:23:05] Description:
[01/09/2010 02:23:05] (luaDoRemoveItem) Item not found

Is there some way to avoid this?
This is the script which includes the update cykotitan helped with:
Code:
local config = {
	cancel = 'Your untrained hands broke the slimy object. Get a higher fist level to have a higher success rate!',
	skill = SKILL_FIST
}
 
local t = {
	[10556] = {
		--items common slimy objects can turn into
		size = 211,
		[{1,	50}] = {skill = 15, item = 1294},   --small stone
		[{51,	52}] = {skill = 15, item = 7636},   --empty potion flask
		[{53,	54}] = {skill = 15, item = 7635},   --empty potion flask	
		[{55,	56}] = {skill = 15, item = 7634},   --empty potion flask		
		[{57,	58}] = {skill = 15, item = 2333},   --letter to markwin
		[{59,	60}] = {skill = 15, item = 5951},   --fish tail
		[{61,	62}] = {skill = 15, item = 2236},   --torn book
		[{63,	64}] = {skill = 15, item = 2240},	 --fish remains
		[{65,	66}] = {skill = 15, item = 2226},	 --fishbone
		[{67,	68}] = {skill = 15, item = 2232},	 --broken brown glass
		[{69,	70}] = {skill = 15, item = 2228},	 --broken pottery
		[{71,	72}] = {skill = 15, item = 2252},	 --wooden trash
		[{73,	74}] = {skill = 15, item = 2251},	 --wooden trash
		[{75,	76}] = {skill = 15, item = 2115},	 --broken piggy bank
		[{77,	78}] = {skill = 15, item = 2816}, 	 --dead rat
		[{79,	80}] = {skill = 15, item = 2815}, 	 --dead rat
		[{81,	82}] = {skill = 15, item = 2813}, 	 --dead rat
		[{83,	84}] = {skill = 15, item = 1947},	 --blank paper
		[{85,	86}] = {skill = 15, item = 1954},	 --paper
		[{87,	88}] = {skill = 15, item = 2013},	 --cup
		[{89,	90}] = {skill = 15, item = 2005},	 --bucket
		[{91,	92}] = {skill = 15, item = 5901},	 --piece of wood	
		[{93,	94}] = {skill = 15, item = 2819},	 --snake
		[{95,	96}] = {skill = 15, item = 2148},   --gold coin
		[{97,	98}] = {skill = 15, item = 2238},	 --worn leather boots
		[{99,	100}] = {skill = 15, item = 2237},   --dirty cape
		[{101,	102}] = {skill = 15, item = 1967},	 -- parchment
		[{103,	104}] = {skill = 15, item = 2260},	 --blank rune
		[{105,	106}] = {skill = 25, item = 2120},	 --rope
		[{107,	108}] = {skill = 25, item = 2389},	 --spear		
		[{109,	110}] = {skill = 25, item = 2132},   --silver amulet
		[{111,	120}] = {skill = 25, item = 8820},	 --mage hat
		[{121,  130}] = {skill = 25, item = 2399},	 --throwing star
		[{131,	140}] = {skill = 25, item = 2229},	 --skull
		[{141,	150}] = {skill = 25, item = 2379},	 --dagger	
		[{151,	152}] = {skill = 25, item = 2410},	 --throwing knife
		[{153,	154}] = {skill = 25, item = 2543},	 --bolt
		[{155,	156}] = {skill = 25, item = 2544},	 --arrow
		[{157,	158}] = {skill = 25, item = 1958},	 --book	
		[{159,	160}] = {skill = 35, item = 2384},	 --rapier
		[{161,	162}] = {skill = 35, item = 2510},   --plate shield
		[{163,	164}] = {skill = 35, item = 3937},	 --trough kit
		[{165,	166}] = {skill = 35, item = 1989},	 --basket
		[{167,	168}] = {skill = 35, item = 4847},	 --simple dress
		[{169,	170}] = {skill = 45, item = 6087},	 --music sheet
		[{171,	172}] = {skill = 45, item = 7618},	 --small health potion
		[{173,	174}] = {skill = 45, item = 7620},	 --small mana potion			
		[{175,	176}] = {skill = 55, item = 5878},	 --minotaur leather
		[{177,	178}] = {skill = 55, item = 5876},	 --lizard leather		
		[{179,	180}] = {skill = 55, item = 5890},	 --chicken feather
		[{181,	182}] = {skill = 55, item = 5941},	 --wooden stake
		[{183,	184}] = {skill = 55, item = 6125},	 --tortoise egg
		[{185,	186}] = {skill = 55, item = 5944},	 --soul orb
		[{187,	188}] = {skill = 55, item = 2231},	 --big bone	
		[{189,	190}] = {skill = 55, item = 2230},	 --bone
		[{191,	192}] = {skill = 55, item = 5902},	 --honeycomb	
		[{193,	194}] = {skill = 55, item = 5921},	 --heaven blossom
		[{195,	196}] = {skill = 55, item = 5948},	 --red dragon leather		
		[{197,	198}] = {skill = 55, item = 5877},	 --green dragon leather	
		[{199,	200}] = {skill = 55, item = 2114},	 --piggy bank
		[{201,	203}] = {skill = 65, item = 2186},	 --moonlight rod		
		[{204,	205}] = {skill = 65, item = 2190},	 --wand of vortex	
		[{206,	207}] = {skill = 65, item = 2191},	 --wand of dragonbreath			
		[{208,	209}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{210, 211}] = {destroyvase = 'You broke the fragile vase.'}
	},
	[10553] = {
		--items uncommon slimy objects can turn into
		size = 2000,
		[{1,	100}] = {skill = 25, item = 5917},
		[{101,	400}] = {skill = 25, item = 2050},
		[{401,	500}] = {skill = 25, item = 5918},
		[{501,	600}] = {skill = 25, item = 5462},
		[{601,	700}] = {skill = 25, item = 2670},
		[{701,	900}] = {skill = 25, item = 2009},
		[{901,	1100}] = {skill = 35, item = 2260},
		[{1101,	1200}] = {skill = 35, item = 2266},
		[{1201,	1500}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{1501,	2000}] = {destroyvase = 'You broke the fragile vase.'}
	},
	[10557] = {
		--items rare slimy objects can turn into
		size = 2612,
		[{1,	200}] = {skill = 45, item = 5899},	
		[{201,	400}] = {skill = 45, item = 6097},
		[{401,	600}] = {skill = 55, item = 5909},
		[{601,	800}] = {skill = 55, item = 5914},
		[{801,	1000}] = {skill = 55, item = 5912},
		[{1001,	1300}] = {skill = 55, item = 7364},	
		[{1301,	1580}] = {skill = 60, item = 10553},	
		[{1581,	1700}] = {skill = 60, item = 10557},		
		[{1701,	1810}] = {skill = 60, item = 11213},
		[{1811,	2111}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{2112,	2612}] = {destroyvase = 'You broke the fragile vase.'}
	}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[itemEx.itemid]
	if v then
		local r, skill = math.random(v.size), getPlayerSkill(cid, config.skill)
		for i, k in pairs(v) do
			if i ~= 'size' and r >= i[1] and r <= i[2] then
				local pos = getThingPos(cid)
				doChangeTypeItem(itemEx.uid, itemEx.type - 1)
				if not k.skill or skill >= k.skill then
					if k.item then
						doPlayerAddItem(cid, k.item, 1)
						local article = getItemInfo(k.item).article
						doCreatureSay(cid, 'You cleaned off ' .. (article ~= '' and article .. ' ' or '') .. getItemInfo(k.item).name .. '!', TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
					elseif k.destroyobj then
						doCreatureSay(cid, k.destroyobj, TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
					elseif k.destroyvase then
						doCreatureSay(cid, k.destroyvase, TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_WATERSPLASH)
						doPlayerAddItem(cid, 2010, 1)
					end
				else
					doCreatureSay(cid, config.cancel, TALKTYPE_ORANGE_1, false, cid)
					doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
					doRemoveItem(itemEx.uid, 1)
				end
				break
			end
		end
		return true
	end
end
 
Last edited:
uh, this should fix it
Lua:
local config = {
	cancel = 'Your untrained hands broke the slimy object. Get a higher fist level to have a higher success rate!',
	skill = SKILL_FIST
}
 
local t = {
	[10556] = {
		--items common slimy objects can turn into
		size = 211,
		[{1,	50}] = {skill = 15, item = 1294},   --small stone
		[{51,	52}] = {skill = 15, item = 7636},   --empty potion flask
		[{53,	54}] = {skill = 15, item = 7635},   --empty potion flask	
		[{55,	56}] = {skill = 15, item = 7634},   --empty potion flask		
		[{57,	58}] = {skill = 15, item = 2333},   --letter to markwin
		[{59,	60}] = {skill = 15, item = 5951},   --fish tail
		[{61,	62}] = {skill = 15, item = 2236},   --torn book
		[{63,	64}] = {skill = 15, item = 2240},	 --fish remains
		[{65,	66}] = {skill = 15, item = 2226},	 --fishbone
		[{67,	68}] = {skill = 15, item = 2232},	 --broken brown glass
		[{69,	70}] = {skill = 15, item = 2228},	 --broken pottery
		[{71,	72}] = {skill = 15, item = 2252},	 --wooden trash
		[{73,	74}] = {skill = 15, item = 2251},	 --wooden trash
		[{75,	76}] = {skill = 15, item = 2115},	 --broken piggy bank
		[{77,	78}] = {skill = 15, item = 2816}, 	 --dead rat
		[{79,	80}] = {skill = 15, item = 2815}, 	 --dead rat
		[{81,	82}] = {skill = 15, item = 2813}, 	 --dead rat
		[{83,	84}] = {skill = 15, item = 1947},	 --blank paper
		[{85,	86}] = {skill = 15, item = 1954},	 --paper
		[{87,	88}] = {skill = 15, item = 2013},	 --cup
		[{89,	90}] = {skill = 15, item = 2005},	 --bucket
		[{91,	92}] = {skill = 15, item = 5901},	 --piece of wood	
		[{93,	94}] = {skill = 15, item = 2819},	 --snake
		[{95,	96}] = {skill = 15, item = 2148},   --gold coin
		[{97,	98}] = {skill = 15, item = 2238},	 --worn leather boots
		[{99,	100}] = {skill = 15, item = 2237},   --dirty cape
		[{101,	102}] = {skill = 15, item = 1967},	 -- parchment
		[{103,	104}] = {skill = 15, item = 2260},	 --blank rune
		[{105,	106}] = {skill = 25, item = 2120},	 --rope
		[{107,	108}] = {skill = 25, item = 2389},	 --spear		
		[{109,	110}] = {skill = 25, item = 2132},   --silver amulet
		[{111,	120}] = {skill = 25, item = 8820},	 --mage hat
		[{121,	130}] = {skill = 25, item = 2399},	 --throwing star
		[{131,	140}] = {skill = 25, item = 2229},	 --skull
		[{141,	150}] = {skill = 25, item = 2379},	 --dagger	
		[{151,	152}] = {skill = 25, item = 2410},	 --throwing knife
		[{153,	154}] = {skill = 25, item = 2543},	 --bolt
		[{155,	156}] = {skill = 25, item = 2544},	 --arrow
		[{157,	158}] = {skill = 25, item = 1958},	 --book	
		[{159,	160}] = {skill = 35, item = 2384},	 --rapier
		[{161,	162}] = {skill = 35, item = 2510},   --plate shield
		[{163,	164}] = {skill = 35, item = 3937},	 --trough kit
		[{165,	166}] = {skill = 35, item = 1989},	 --basket
		[{167,	168}] = {skill = 35, item = 4847},	 --simple dress
		[{169,	170}] = {skill = 45, item = 6087},	 --music sheet
		[{171,	172}] = {skill = 45, item = 7618},	 --small health potion
		[{173,	174}] = {skill = 45, item = 7620},	 --small mana potion			
		[{175,	176}] = {skill = 55, item = 5878},	 --minotaur leather
		[{177,	178}] = {skill = 55, item = 5876},	 --lizard leather		
		[{179,	180}] = {skill = 55, item = 5890},	 --chicken feather
		[{181,	182}] = {skill = 55, item = 5941},	 --wooden stake
		[{183,	184}] = {skill = 55, item = 6125},	 --tortoise egg
		[{185,	186}] = {skill = 55, item = 5944},	 --soul orb
		[{187,	188}] = {skill = 55, item = 2231},	 --big bone	
		[{189,	190}] = {skill = 55, item = 2230},	 --bone
		[{191,	192}] = {skill = 55, item = 5902},	 --honeycomb	
		[{193,	194}] = {skill = 55, item = 5921},	 --heaven blossom
		[{195,	196}] = {skill = 55, item = 5948},	 --red dragon leather		
		[{197,	198}] = {skill = 55, item = 5877},	 --green dragon leather	
		[{199,	200}] = {skill = 55, item = 2114},	 --piggy bank
		[{201,	203}] = {skill = 65, item = 2186},	 --moonlight rod		
		[{204,	205}] = {skill = 65, item = 2190},	 --wand of vortex	
		[{206,	207}] = {skill = 65, item = 2191},	 --wand of dragonbreath			
		[{208,	209}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{210,	211}] = {destroyvase = 'You broke the fragile vase.'}
	},
	[10553] = {
		--items uncommon slimy objects can turn into
		size = 2000,
		[{1,	100}] = {skill = 25, item = 5917},
		[{101,	400}] = {skill = 25, item = 2050},
		[{401,	500}] = {skill = 25, item = 5918},
		[{501,	600}] = {skill = 25, item = 5462},
		[{601,	700}] = {skill = 25, item = 2670},
		[{701,	900}] = {skill = 25, item = 2009},
		[{901,	1100}] = {skill = 35, item = 2260},
		[{1101,	1200}] = {skill = 35, item = 2266},
		[{1201,	1500}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{1501,	2000}] = {destroyvase = 'You broke the fragile vase.'}
	},
	[10557] = {
		--items rare slimy objects can turn into
		size = 2612,
		[{1,	200}] = {skill = 45, item = 5899},	
		[{201,	400}] = {skill = 45, item = 6097},
		[{401,	600}] = {skill = 55, item = 5909},
		[{601,	800}] = {skill = 55, item = 5914},
		[{801,	1000}] = {skill = 55, item = 5912},
		[{1001,	1300}] = {skill = 55, item = 7364},	
		[{1301,	1580}] = {skill = 60, item = 10553},	
		[{1581,	1700}] = {skill = 60, item = 10557},		
		[{1701,	1810}] = {skill = 60, item = 11213},
		[{1811,	2111}] = {destroyobj = 'The slimy object was too delicate to clean off. It broke!'},
		[{2112,	2612}] = {destroyvase = 'You broke the fragile vase.'}
	}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = t[itemEx.itemid]
	if v then
		local r, skill = math.random(v.size), getPlayerSkill(cid, config.skill)
		for i, k in pairs(v) do
			if i ~= 'size' and r >= i[1] and r <= i[2] then
				local pos = getThingPos(cid)
				doChangeTypeItem(itemEx.uid, itemEx.type - 1)
				if not k.skill or skill >= k.skill then
					if k.item then
						doPlayerAddItem(cid, k.item, 1)
						local article = getItemInfo(k.item).article
						doCreatureSay(cid, 'You cleaned off ' .. (article ~= '' and article .. ' ' or '') .. getItemInfo(k.item).name .. '!', TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
					elseif k.destroyobj then
						doCreatureSay(cid, k.destroyobj, TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
					elseif k.destroyvase then
						doCreatureSay(cid, k.destroyvase, TALKTYPE_ORANGE_1, false, cid)
						doSendMagicEffect(pos, CONST_ME_WATERSPLASH)
						doPlayerAddItem(cid, 2010, 1)
					end
				else
					doCreatureSay(cid, config.cancel, TALKTYPE_ORANGE_1, false, cid)
					doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
				end
				break
			end
		end
		return true
	end
end
That would happen when an untrained player uses the vase on a single slimy object.
It would always try to remove count twice, and would fail since there was only 1 to remove.
 
Last edited:
Back
Top