• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua If already monster then no summon next

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
671
Hello.
I need an function to this script:
LUA:
local left = {x=3068, y=3074, z=7, stackpos=2}
local right = {x=3070, y=3074, z=7, stackpos=2}
 
local summon = {x=3067, y=3072, z=7}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		local a = getThingfromPos(left)
		if a.itemid == 11754 and a.type >= 2 then
			local b = getThingfromPos(right)
			if b.itemid == 11754 and b.type >= 2 then
				doRemoveItem(a.uid, 2)
				doRemoveItem(b.uid, 2)
				doCreateMonster('Wolf', summon)
				doSendMagicEffect(summon, 121)
				doCreatureSay(cid, 'You lost two wolfs skin and an Wolf appear.', 0x13)
				return doTransformItem(item.uid, 1946)
			end
		end
		return doPlayerSendCancel(cid,"Put the right items in the right spots!")
	end
	return doTransformItem(item.uid, 1945)
end

If an creature is in summon position than player cant use lever.
Anyone ?
 
Last edited:
add this

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
      if isPlayer(cid) then
	if item.itemid == 1945 then
		local a = getThingfromPos(left)
		if a.itemid == 11754 and a.type >= 2 then
			local b = getThingfromPos(right)
			if b.itemid == 11754 and b.type >= 2 then
				doRemoveItem(a.uid, 2)
				doRemoveItem(b.uid, 2)
				doCreateMonster('Wolf', summon)
				doSendMagicEffect(summon, 121)
				doCreatureSay(cid, 'You lost two wolfs skin and an Wolf appear.', 0x13)
				return doTransformItem(item.uid, 1946)
			end
                     end
		end
		return doPlayerSendCancel(cid,"Put the right items in the right spots!")
	end
	return doTransformItem(item.uid, 1945)
end
 
LUA:
local left = {x=3068, y=3074, z=7, stackpos=2}
local right = {x=3070, y=3074, z=7, stackpos=2}
local summon = {x=3067, y=3072, z=7}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local tileid = getTopCreature(summon).uid
	if tileid == 0 then
		if item.itemid == 1945 then
			local a = getThingfromPos(left)
			if a.itemid == 11754 and a.type >= 2 then
				local b = getThingfromPos(right)
				if b.itemid == 11754 and b.type >= 2 then
					doRemoveItem(a.uid, 2)
					doRemoveItem(b.uid, 2)
					doCreateMonster('Wolf', summon)
					doSendMagicEffect(summon, 121)
					doCreatureSay(cid, 'You lost two wolfs skin and an Wolf appear.', 0x13)
					return doTransformItem(item.uid, 1946)
				end
			end
			return doPlayerSendCancel(cid,"Put the right items in the right spots!")
		end
		return doTransformItem(item.uid, 1945)
	else
		doPlayerSendCancel(cid,"A creature is in the summon position!")
	end
end
 
if it's an area and not just a single position, use something like this
LUA:
local left = {x=3068, y=3074, z=7, stackpos=2}
local right = {x=3070, y=3074, z=7, stackpos=2}

local summon = {x=3067, y=3072, z=7}

local from = {x=100, y=100, z=7} -- top left corner
local to = {x=200, y=200, z=7} -- bottom right corner

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		local a = getThingfromPos(left)
		if a.itemid == 11754 and a.type >= 2 then
			local b = getThingfromPos(right)
			if b.itemid == 11754 and b.type >= 2 then
				for x = from.x, to.x do
					for y = from.y, to.y do
						local f = getTopCreature({x=x, y=y, z=from.z}).uid
						if f ~= 0 and isMonster(f) and getCreatureMaster(f) == f and getCreatureName(f):lower() == 'wolf' then
							return doPlayerSendCancel(cid, 'The monster is already summoned.') 
						end
					end
				end
				doRemoveItem(a.uid, 2)
				doRemoveItem(b.uid, 2)
				doCreateMonster('Wolf', summon)
				doSendMagicEffect(summon, 121)
				doCreatureSay(cid, 'You lost two wolfs skin and an Wolf appear.', 0x13)
				return doTransformItem(item.uid, 1946)
			end
		end
		return doPlayerSendCancel(cid, 'Put the right items in the right spots!')
	end
	return doTransformItem(item.uid, 1945)
end
 
Back
Top