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

Onuse and transform? Rep++

Dexftw

Total Boss
Joined
Jan 30, 2011
Messages
317
Reaction score
8
Could anyone help me with a script that if you have an item + another item it transforms it into a new item? C: reP++
 
Code:
	function onUse(cid, item, frompos, item2, topos)

	id1 = 2123
	id2 = 2648
	id3 = 2112
if (item.itemid == id1) then
	doPlayerRemoveItem(cid, id1, 1)
	doPlayerRemoveItem(cid, id2, 1)
	doPlayerAddItem(cid, id3, 1)
	end	
end

Managed to get it to work with 1 item, but if you change

Code:
if (item.itemid == id1) then

to

Code:
if (item.itemid == id1 and item.itemid == id2) then
 
Last edited:
Finally! After a long time of changing this script around I found a way. It wasn't easy since I don't really script :p

Code:
	local id1 = 2123 -- ID of the first item.
	local id2 = 2648 -- ID of the second item.
	local id3 = 2112 -- ID of the final item.

function onUse(cid, item, frompos, item2, topos)


	if item.itemid == id1 then
doPlayerRemoveItem(cid, id1, 1)
doPlayerSendTextMessage(cid,22,"Please use the next item.")
	end

	if item2.itemid == id2 then
doPlayerRemoveItem(cid, id2, 1)
doPlayerSendTextMessage(cid,22,"Congratulations! you received an [itemname].")
	doPlayerAddItem(cid, id3, 1)
	end	
end

Change the local id's to what you want.

When the player uses the first item, they will be sent a message saying, please use the next item and when they use the next item they will get another message saying congratulations you received an 'itemname'.

The other two items will also be removed :)
 
Forgot to mention in actions.xml you need to have the first and second item id's

<action itemid="2168" script="transform.lua"/>
<action itemid="2214" script="transform.lua"/>
 
Last edited:
you must check toPosition.stackpos -1
for example:
Lua:
toPosition.stackpos = toPosition.stackpos - 1
if getThingFromPos(toPosition).itemid == 2222 then
...
 
Back
Top