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

[Script] Use hammer on x item at anvil to creat x item. [7.6]

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.itemid == [B][COLOR="red"]X_ITEM[/COLOR][/B] then
		if toPosition.x == 65535 or getTileItemById(toPosition, 2555).uid == 0 then
			doCreatureSay(cid, 'You must place this item on an anvil.', TALKTYPE_ORANGE_1, false, cid)
		else
			doTransformItem(itemEx.uid, [B][COLOR="red"]Y_ITEM[/COLOR][/B])
			doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
		end
		return true
	end
end
 
If they use the hammer on an item that's inside player's backpack or in the inventory slots, toPosition.x will be 65535 and we want to prevent the server from throwing an error in this case.
 
No it doesnt mather where you do it.
but all i have to do is to add this lines in /script/smith.lua etc, and edit X_ITEM (in my case hammer id) and Y_ITEM to the item it will be changed for? and the hammer needs to be in my backpack or can it be at the ground aswell?
 
It can be anywhere, the hammer won't be changed and X_ITEM is the item that you have to use it on, not the hammer id.
 
it just says sorry not possible. when im trying to use the hammer. and how does it knows its the hammer you need to use?
okej.png

By flowftw at 2011-02-26

from a pice of iron to this key.
 
I don't know about your server, but it should work fine on any modern server and Avesta is one of them because it has the functions.
LUA:
function onUse(cid, item, frompos, item2, topos)
	if item2.itemid == 2225 then
		if topos.x == 65535 or getTileItemById(topos, 2555).uid == 0 then
			doCreatureSay(cid, 'You must place this item on an anvil.', TALKTYPE_ORANGE_1)
		else
			doTransformItem(item2.uid, 2086)
			doSendMagicEffect(topos, CONST_ME_BLOCKHIT)
		end
		return TRUE
	end
end
 
Back
Top