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

[Global event request] Help! again xD

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
Hello again... I need help with this script ... this script that i have just done should remove and create 6 doors specified in the positions, but only it removes and create one of them, why this happens?

Here is the script...

Code:
[COLOR="Blue"]function onThink(interval, lastExecution)

local config = {
	timeToClose = 5,
	doorId = 9485,
	doorPositions = {
		{ x = 408, y = 445, z = 11, stackpos = 1 },
		{ x = 409, y = 445, z = 11, stackpos = 1 },
		{ x = 410, y = 445, z = 11, stackpos = 1 },
		{ x = 411, y = 445, z = 11, stackpos = 1 },
		{ x = 412, y = 445, z = 11, stackpos = 1 },
		{ x = 413, y = 445, z = 11, stackpos = 1 }
	}
}

	for i = 1, table.maxn(config.doorPositions) do

local getDoors = getThingfromPos(config.doorPositions[i])

if getDoors.itemid == config.doorId then

	doRemoveItem(getDoors.uid,1)
	doSendMagicEffect(config.doorPositions[i], CONST_ME_BLOCKHIT)
	doBroadcastMessage("The doors of the vampire castle are opened!", MESSAGE_STATUS_CONSOLE_ORANGE)
	addEvent(closeCastle, (1000*config.timeToClose))

			return TRUE
		end
	end
end

function closeCastle()

local doorId = 9485
local doorPositions = {
		{ x = 408, y = 445, z = 11, stackpos = 1 },
		{ x = 409, y = 445, z = 11, stackpos = 1 },
		{ x = 410, y = 445, z = 11, stackpos = 1 },
		{ x = 411, y = 445, z = 11, stackpos = 1 },
		{ x = 412, y = 445, z = 11, stackpos = 1 },
		{ x = 413, y = 445, z = 11, stackpos = 1 }
	}

for k = 1, table.maxn(doorPositions) do

local getDoors = getThingfromPos(doorPositions[k])

if getDoors.itemid == 0 then
	doCreateItem(doorId,1,doorPositions[k])
	doBroadcastMessage("The doors of the vampire castle are closed!", MESSAGE_STATUS_CONSOLE_ORANGE)

		return TRUE

		end
	end
end[/COLOR]

Look the image =d!

2dl44mo.jpg


Help! =)
 
Try this:

PHP:
function onThink(interval, lastExecution)

local config = {
	timeToClose = 5,
	doorId = 9485,
	doorPositions = {
		{ x = 408, y = 445, z = 11, stackpos = 1 },
		{ x = 409, y = 445, z = 11, stackpos = 1 },
		{ x = 410, y = 445, z = 11, stackpos = 1 },
		{ x = 411, y = 445, z = 11, stackpos = 1 },
		{ x = 412, y = 445, z = 11, stackpos = 1 },
		{ x = 413, y = 445, z = 11, stackpos = 1 }
	}
}

	if getDoors.itemid == config.doorId then
		for i = 1, table.maxn(config.doorPositions) do
			local getDoors = getThingfromPos(config.doorPositions[i])
			doRemoveItem(getDoors.uid,1)
		end
			doSendMagicEffect(config.doorPositions[i], CONST_ME_BLOCKHIT)
			doBroadcastMessage("The doors of the vampire castle are opened!", MESSAGE_STATUS_CONSOLE_ORANGE)
			addEvent(closeCastle, (1000*config.timeToClose))
return TRUE
	end
end

function closeCastle()

local doorId = 9485
local doorPositions = {
		{ x = 408, y = 445, z = 11, stackpos = 1 },
		{ x = 409, y = 445, z = 11, stackpos = 1 },
		{ x = 410, y = 445, z = 11, stackpos = 1 },
		{ x = 411, y = 445, z = 11, stackpos = 1 },
		{ x = 412, y = 445, z = 11, stackpos = 1 },
		{ x = 413, y = 445, z = 11, stackpos = 1 }
	}

	if getDoors.itemid == 0 then
		for k = 1, table.maxn(doorPositions) do
			local getDoors = getThingfromPos(doorPositions[k])
			doCreateItem(doorId,1,doorPositions[k])
		end
			doBroadcastMessage("The doors of the vampire castle are closed!", MESSAGE_STATUS_CONSOLE_ORANGE)

		return TRUE

	end
end
 
If this script is for your Demon Castle (Blood Castle) event, check my post on your OTFans thread. I think I provided an alternative you may be more happy with as it fits in perfectly.

Edit: Just noticed it said 'Vampire Castle' in the script, my bad. That is, unless this is a weaker version of the castle. But you may as well look at your other thread anyway...
 
Back
Top