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

make a bit more advanced script. [7.6]

tompan

Member
Joined
Dec 13, 2008
Messages
646
Reaction score
24
Location
Sweden
PHP:
function onUse(cid, item, frompos, item2, topos)
	if frompos.x == 65535 then
		doPlayerSendCancel(cid, "Put the metal on the anvil first.")
		return 1
	end

	doSendMagicEffect(topos,2)	-- puff

	if item.itemid == 2225 then			-- pice of iron
		doTransformItem(item.uid,2088)
	
	else
		return 0
	end
	return 1
end


I want so you can only use this at X,Y,Z pos. not everywhere on the ground.
 
LUA:
function onUse(cid, item, frompos, item2, topos)
	if topos.x == 65535 or not(topos.x == 123 and topos.y == 456 and topos.z == 7) then
		doPlayerSendCancel(cid, 'Put the metal on the anvil first.')
		return TRUE
	end

	doSendMagicEffect(topos, 2)
	if item2.itemid == 2225 then
		doTransformItem(item2.uid, 2088)
		return TRUE
	end
end
 
like this?

LUA:
local X,Y,Z = 391,231,7
function onUse(cid, item, frompos, item2, topos)
local v = getThingPos(cid)
	if v.x == X and v.y == Y and v.z == Z then
		if item.itemid == 225 then -- Piece of iron.
			doTransformItem(item.uid,2088)
			doSendMagicEffect(v,CONST_ME_MAGIC_GREEN)
		end
	else
		doPlayerSendCancel(cid,'Invalid position.')
		doSendMagicEffect(v,CONST_ME_POFF)
	end
	return true
end
 
like this?

LUA:
local X,Y,Z = 391,231,7
function onUse(cid, item, frompos, item2, topos)
local v = getThingPos(cid)
	if v.x == X and v.y == Y and v.z == Z then
		if item.itemid == 225 then -- Piece of iron.
			doTransformItem(item.uid,2088)
			doSendMagicEffect(v,CONST_ME_MAGIC_GREEN)
		end
	else
		doPlayerSendCancel(cid,'Invalid position.')
		doSendMagicEffect(v,CONST_ME_POFF)
	end
	return true
end
I thought he said 7.6
 
it has to work, either something's wrong with your server or you're doing something wrong

this is the script that should be registered to the hammer, and you're supposed to use the hammer on the piece of iron while iron is on anvil.
 
LUA:
function onUse(cid, item, frompos, item2, topos)
	if topos.x == 65535 or not(topos.x == 123 and topos.y == 456 and topos.z == 7) then
		doPlayerSendCancel(cid, 'Put the metal on the anvil first.')
		return TRUE
	end

	doSendMagicEffect(topos, 2)
	if item2.itemid == 2225 then
		doTransformItem(item2.uid, 2088)
		return TRUE
	end
end



return TRUE.
it should be return 1. now this script works properly. thanks!
 
Back
Top