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

switch tile error

Raiden

Developer
Joined
Sep 16, 2008
Messages
486
Reaction score
32
Location
Venezuela
Hello! i got a 7.4 avesta server and when i step in one a switch tile (id 426), it not change to 425 and y get this error on my console:

Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/switch_tile.lua:OnStepIn

attempt to call a table value
stack traceback:

ANd when i step in like 2 or 3 time teh server crash down! why?!
 
ok thanks for help me!!!

Here is switch_tile.lua:

Code:
local SWITCHES = { {416, 417}, {426, 425}, {446, 447} }

local function doTransformTile(item)
	for i, v in pairs(SWITCHES) do
		if(item.itemid == v[1]) then
			return doTransformItem(item.uid, v[2])
		elseif(item.itemid == v[2]) then
			return doTransformItem(item.uid, v[1])
		end
	end
end

function onStepIn(cid, item, pos)
	if(item.actionid > 0) then
		return TRUE
	end

	doTransformTile(item)
	local depot = {}
	for x = -1, 1 do
		for y = -1, 1 do
			pos.x = pos.x + x
			pos.y = pos.y + y
			depot = getTileItemByType(pos, ITEM_TYPE_DEPOT)
			if(depot.uid > 0) then
				local depotItems = getPlayerDepotItems(cid, getDepotId(depot.uid))
				local depotStr = "Your depot contains " .. depotItems .. " items."
				if(depotItems == 1) then
					depotStr = "Your depot contains 1 item."
				end
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, depotStr)
				return TRUE
			end
			-- The pos has changed, change it back
			pos.x = pos.x - x
			pos.y = pos.y - y
		end
	end
	return TRUE
end

function onStepOut(cid, item, pos)
	doTransformTile(item)
	return TRUE
end

And closingdoor.lua:

Code:
function onStepOut(cid, item, position, fromPosition)
	local newPosition = {x = position.x, y = position.y, z = position.z}
	if(isInArray(verticalOpenDoors, item.itemid)) then
		newPosition.x = newPosition.x + 1
	else
		newPosition.y = newPosition.y + 1
	end

	doRelocate(position, newPosition)
	local tmpPos = {x = position.x, y = position.y, z = position.z, stackpos = -1}
	local tileCount = getTileThingByPos(tmpPos)

	local i = 1
	local tmpItem = {uid = 1}
	while(tmpItem.uid ~= 0 and i < tileCount) do
		tmpPos.stackpos = i
		tmpItem = getTileThingByPos(tmpPos)
		if(tmpItem.uid ~= item.uid and tmpItem.uid ~= 0 and isMoveable(tmpItem.uid)) then
			doRemoveItem(tmpItem.uid)
		else
			i = i + 1
		end
	end

	doTransformItem(item.uid, item.itemid - 1)
	return true
end

Check it ;/
 
Back
Top