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

Help fixing this script (demon helmet)

CheatsBCN

New Member
Joined
Mar 6, 2012
Messages
131
Reaction score
1
Hello, i tryed to do my own demon helmet quest with looking at some scripts so i can learn a bit (and so i dont request for to many script as some got angry with me jeje) this is what i did but its all the time returning me that there is some monster alive even when no monster is alive.


this is the script, i know there are some out there but i want to fix this one cus its in someway different and also to see where is there error and learn. i will apreciate any help.

Lua:
local pinkstonepos1 = {x=1027, y=1096, z=8, stackpos=1}        -- Blocking stone position.
local TeleportToPos = { x = 1139, y = 1111, z = 8, stackpos=2} -- Position the player will be ported to when leaving the DHQ, like the Temple...
local LeverPos      = { x = 1043, y = 1095, z = 8, stackpos=2} -- Lever Position
local TeleportOutPos = { x = 1035, y = 1096, z = 8, stackpos=1} -- where tp is created
local timeToRemove  = 5 -- Time before quest reset
local starting= {x = 1027, y = 1089, z = 8} -- edit this to the top left sqm of ur annhilator room
local ending= {x = 1041, y = 1101, z = 8} -- edit this to the bottom right sqm of ur annhilator room
local demon1pos = {x=1032, y=1095, z=8}
local demon2pos = {x=1032, y=1098, z=8}
local demon3pos = {x=1034, y=1096, z=8}
local demon4pos = {x=1037, y=1095, z=8}
local demon5pos = {x=1037, y=1098, z=8}
local banshee1pos = {x=1036, y=1092, z=8}
local banshee2pos = {x=1036, y=1100, z=8}
local banshee3pos = {x=1039, y=1097, z=8}

function onUse(cid, item, fromPos, item2, toPos)
	local hi = false
	if (cleanArea()) then
        if item.itemid == 1945 then
            doRemoveItem(getThingfromPos(pinkstonepos1).uid, 1)
            doCreateTeleport(1387, TeleportToPos, TeleportOutPos)
            doSendMagicEffect(TeleportOutPos, CONST_ME_TELEPORT)
			doCreatureSay(cid, "You have " .. timeToRemove .. " seconds to go into de teleport!", TALKTYPE_ORANGE_1)
			doTransformItem(item.uid,1946)
            addEvent(doRemoveTeleport, (1000*timeToRemove))
 
 

		elseif item.itemid == 1946 then

			doPlayerSendCancel(cid,"Sorry, not possible.") -- message if the lever is pulled again.

		end
	
	else
		doPlayerSendCancel(cid,"You have to kill all the monsters before you can pull it!")
	end
	return true
end		
		

function cleanArea()
    local checking= {x = starting.x, y = starting.y, z = starting.z, stackpos = 253}
		while(checking.y <= ending.y) do
			local creature = getTopCreature(checking).uid or getTopCreature(checking)
			if(isCreature(creature) == TRUE) then
			return false	
			end
		if(checking.x == ending.x) then
            checking.x = starting.x
            checking.y = checking.y + 1
        end
        checking.x = checking.x + 1
		end
    return true
end


function doRemoveTeleport()


		if getThingfromPos({x=1035, y=1096, z=8, stackpos=1}).itemid == 1387 then
			doCreateItem(1355, 1, pinkstonepos1)
			doRemoveItem(getThingfromPos({x=1035, y=1096, z=8, stackpos=1}).uid,1)
			doSendMagicEffect({x=1035, y=1096, z=8, stackpos=15}, CONST_ME_POFF)
			doTransformItem(getThingfromPos({x=1043, y=1095, z=8, stackpos=2}).uid, 1945)
			respawn()
		end
		return true

end  

function respawn()

        doSummonCreature("Demon", demon1pos)
        doSummonCreature("Demon", demon2pos)
        doSummonCreature("Demon", demon3pos)
        doSummonCreature("Demon", demon4pos)
        doSummonCreature("Demon", demon5pos)
		doSummonCreature("Banshee", banshee1pos)
		doSummonCreature("Banshee", banshee2pos)		
		doSummonCreature("Banshee", banshee3pos)
end

the problem is in the function clearAll() dunno what is wrong but couldnt see it..

- - - Updated - - -

....
 
...

- - - Updated - - -

trolol

- - - Updated - - -

HAHAHAHA i know the error.. i had those magictower and they are mosnter thats why i couldnt continue xD



SOLVED!
 
The problem is, that the isCreature(cid) function detect's a player also as a creature, so you have to change one line:
Lua:
if (isCreature(creature) == TRUE) then
to this
Lua:
if (isCreature(creature) == TRUE) and isPlayer(creature)~= TRUE then

Your script works now, but it is very bad made. I have made it a little better and clearly.
Lua:
local pinkstonepos1 = {x=1027, y=1096, z=8, stackpos=1} -- Blocking stone position.
local TeleportToPos = { x = 1139, y = 1111, z = 8, stackpos=2} -- Position the player will be ported to when leaving the DHQ, like the Temple...
local TeleportOutPos = { x = 1035, y = 1096, z = 8, stackpos=1} -- where tp is created
local timeToRemove  = 5 -- Time before quest reset
local starting= {x = 1027, y = 1089, z = 8} -- edit this to the top left sqm of ur annhilator room
local ending= {x = 1041, y = 1101, z = 8} -- edit this to the bottom right sqm of ur annhilator room
local monster = {
{position = {x=1032, y=1095, z=8}, creature = "demon"},
{position = {x=1032, y=1098, z=8}, creature = "demon"},
{position = {x=1034, y=1096, z=8}, creature = "demon"},
{position = {x=1037, y=1095, z=8}, creature = "demon"},
{position = {x=1037, y=1098, z=8}, creature = "demon"},
{position = {x=1036, y=1092, z=8}, creature = "banshee"},
{position = {x=1036, y=1100, z=8}, creature = "banshee"},
{position = {x=1039, y=1097, z=8}, creature = "banshee"}
}

function onUse(cid, item, fromPos, item2, toPos)
	local hi = false
	if (cleanArea(starting, ending)) then
        if item.itemid == 1945 then
            doRemoveItem(getThingfromPos(pinkstonepos1).uid, 1)
            doCreateTeleport(1387, TeleportToPos, TeleportOutPos)
            doSendMagicEffect(TeleportOutPos, CONST_ME_TELEPORT)
			doCreatureSay(cid, "You have " .. timeToRemove .. " seconds to go into de teleport!", TALKTYPE_ORANGE_1)
			doTransformItem(item.uid,1946)
            addEvent(doRemoveTeleport, 1000*timeToRemove, item, TeleportOutPos)
 
		elseif item.itemid == 1946 then
			doPlayerSendCancel(cid,"Sorry, not possible.") -- message if the lever is pulled again.
		end
	else
		doPlayerSendCancel(cid,"You have to kill all the monsters before you can pull it!")
	end
	return true
end		
 
 
function cleanArea(a,b)
    for ix = a.x, b.x do
		for iy = a.y, b.y do
		local CheckTile = getThingfromPos({x = ix, y = iy, z = a.z, stackpos = 255})
			if isCreature(CheckTile.uid) == TRUE and isPlayer(CheckTile.uid) ~= TRUE then
				return false
			end
		end
	end
    return true
end
 
 
function doRemoveTeleport(lever, teleporter)
	if getThingfromPos(teleporter).itemid == 1387 then
		doCreateItem(1355, 1, pinkstonepos1)
		doRemoveItem(getThingfromPos(teleporter).uid,1)
		doSendMagicEffect(teleporter, CONST_ME_POFF)
		doTransformItem(lever.uid, 1945)
		respawn()
	end
	return true
end  
 
function respawn()
	for i = 1, #monster do
        doSummonCreature(monster[i].creature, monster[i].position)
	end
end

I see, that you want to understand, what you script, so if you have a problem with something here, just ask :)

- - - Updated - - -

Oh, I think, I was too slow :p
But maybe you like the new script :D
 
Back
Top