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

Item changer

phil1p

beep beep im a jeep
Joined
Oct 29, 2009
Messages
77
Reaction score
0
Here's my description:


If 'item' is placed on a switch tile and then player pulls a switch, when pulled it should change the 'item' on the 'tile' to 'item2'.


Regards, Philip.
 
Code:
local t = {
	pos = {x = 100, y = 100, z = 7},
	effect = CONST_ME_MAGIC_RED,
	required = 2464,
	new = 2463
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		local v = getTileItemById(t.pos, t.required).uid
		if v > 0 then
			doRemoveItem(v)
			doCreateItem(t.new, 1, t.pos)
			doSendMagicEffect(t.pos, t.effect)
			doTransformItem(item.uid, 1946)
		else
			doPlayerSendCancel(cid, "Sorry, not possible")
		end
	elseif item.itemid == 1946 then
		doTransformItem(item.uid, 1945)
	end
	return TRUE
end
 
Lua:
local t = {
	pos = {x = 100, y = 100, z = 7},
	effect = CONST_ME_MAGIC_RED,
	required = {
		2464, 2465
	},
	new = 2463
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		local it = {}
		for i = 1, #t.required do
			it[i] = getTileItemById(t.pos, t.required[i]).uid
			if it[i] == 0 then
				return doPlayerSendCancel(cid, 'Sorry, not possible')
			end
		end
		for i = 1, #it do
			doRemoveItem(it[i])
		end
		doCreateItem(t.new, 1, t.pos)
		doSendMagicEffect(t.pos, t.effect)
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Back
Top