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

Simple Script Error Fix

Micool777

New Member
Joined
Aug 25, 2012
Messages
14
Reaction score
0
LUA:
local fromPos={x = 110, y = 78, z = 0}
local toPos={x = 116, y = 84, z = 0}
local firstpos={x = 113, y = 81, z = 6} --<very first lever beginning quest positions
local secondpos={x = 116, y = 84, z = 6} -->
function onUse(cid, item, fromPosition, itemEx, toPosition)
local currentlevel = fromPosition.z
if (item.itemid==1945) then
	
if not isPlayer(cid) then
		return true
end
	local amount = 0
			--
	for xx = firstpos.x, secondpos.x do
		for yy = firstpos.y, secondpos.y do
			for zz = firstpos.z, secondpos.z do
			--
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			for z = fromPos.z + currentlevel, toPos.z + currentlevel do
			--
			if (currentlevel ~= 6) then
				local pid = getThingfromPos({x=x,y=y,z=z}).uid
			elseif (currentlevel == 6) then
				local pid = getThingfromPos({x=xx,y=yy,z=zz}).uid
			end
				if (isCreature(pid) and pid>0) then
					amount = amount+1
					--doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, pid)
					else
				end	
			end
		end
				end	
			end
		end
		--
	end
	
[[[[40]]]]	if (amount=0 and item.uid~=15006 or item.uid~=15002) then
	fromPosition.z=fromPosition.z-1
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations on defeating the Demon Gods! Only "..currentlevel-3.." levels to go!")
		elseif (item.uid == 15002 and amount=0) then
	doTeleportThing(cid, {x = 113, y = 81, z = 7}, FALSE)	
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have entered the lair of the Demon Gods... I wish you luck.")
		elseif (item.uid == 15006 and amount=0) then
	doTeleportThing(cid, {x = 113, y = 85, z = 11}, FALSE)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have defeated all of the Demon Gods! Proceed to the chest to receive your reward.")
		else
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are/is still "..amount.." Demon God(s) left. You must defeat all of them before you can proceed.")
	end
	end
end

Error at line 40 - ')' expected near '='... I really don't see the problem in that if statement. I have tried many variations, but all have failed :(. Please help.
 
Last edited by a moderator:
Try:

LUA:
local fromPos={x = 110, y = 78, z = 0}
local toPos={x = 116, y = 84, z = 0}
local firstpos={x = 113, y = 81, z = 6} --<very first lever beginning quest positions
local secondpos={x = 116, y = 84, z = 6} -->
function onUse(cid, item, fromPosition, itemEx, toPosition)
local currentlevel = fromPosition.z
if (item.itemid==1945) then
	
if not isPlayer(cid) then
		return true
end
	local amount = 0
			--
	for xx = firstpos.x, secondpos.x do
		for yy = firstpos.y, secondpos.y do
			for zz = firstpos.z, secondpos.z do
			--
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			for z = fromPos.z + currentlevel, toPos.z + currentlevel do
			--
			if (currentlevel ~= 6) then
				local pid = getThingfromPos({x=x,y=y,z=z}).uid
			elseif (currentlevel == 6) then
				local pid = getThingfromPos({x=xx,y=yy,z=zz}).uid
			end
				if (isCreature(pid) and pid>0) then
					amount = amount+1
					--doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, pid)
					else
				end	
			end
		end
				end	
			end
		end
		--
	end
	
[[[[40]]]]	if (amount~=0 and item.uid~=15006 or item.uid~=15002) then
	fromPosition.z=fromPosition.z-1
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations on defeating the Demon Gods! Only "..currentlevel-3.." levels to go!")
		elseif (item.uid == 15002 and amount=0) then
	doTeleportThing(cid, {x = 113, y = 81, z = 7}, FALSE)	
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have entered the lair of the Demon Gods... I wish you luck.")
		elseif (item.uid == 15006 and amount=0) then
	doTeleportThing(cid, {x = 113, y = 85, z = 11}, FALSE)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have defeated all of the Demon Gods! Proceed to the chest to receive your reward.")
		else
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are/is still "..amount.." Demon God(s) left. You must defeat all of them before you can proceed.")
	end
	end
end
 
Thank you, you lead me down the right path, I realized that I wasn't comparing the object, I was setting it (should've used == in place of =). But now I have a new problem.. when I use the lever, it detects 784 monsters. I dont see how "isCreature(pid)" returns more monsters than there even are in the map, much less in an area smaller than 784 tiles. Maybe it is returning the id? But I don't see how it would be, since it sets 'amount' higher when faced with a true return of the function.

-EDIT-

Also, sorry about forgetting lua tags :D
 
Last edited:
Back
Top