• 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] Key cant lock

scriptha

On a distinguished road
Joined
Jul 21, 2007
Messages
125
Reaction score
0
Location
/etc/pr0n
Hi

I've got a door with an actionid, and an npc selling a key with the same id.
I want to open the door with my key, which is working. But when I try to close the door again, it says that I cant use the object, and when I try to close it with the key it says it doesn't match..

Help please :/

nvm, seems to be solved when I use another door.. it seems that I cant close the door no. 1251...
 
Last edited by a moderator:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local doorPosition = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
	local doorCreature = getThingfromPos(doorPosition)
	if isInArray(questDoors, item.itemid) == TRUE then
		if getPlayerStorageValue(cid, item.actionid) ~= -1 then
			doTransformItem(item.uid, item.itemid + 1)
			doTeleportThing(cid, toPosition, TRUE)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.")
		end
		return TRUE
	elseif isInArray(levelDoors, item.itemid) == TRUE then
		if item.actionid > 0 and getPlayerLevel(cid) >= item.actionid - 1000 then
			doTransformItem(item.uid, item.itemid + 1)
			doTeleportThing(cid, toPosition, TRUE)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
		end
		return TRUE
	elseif isInArray(horizontalOpenDoors, item.itemid) == TRUE then
		doorPosition.y = doorPosition.y + 1
		if doorCreature.itemid > 0 then
			doTeleportThing(doorCreature.uid, doorPosition, TRUE)
		end
		doTransformItem(item.uid, item.itemid - 1)
		return TRUE
	elseif isInArray(verticalOpenDoors, item.itemid) == TRUE then
		doorPosition.x = doorPosition.x + 1
		if doorCreature.itemid > 0 then
			doTeleportThing(doorCreature.uid, doorPosition, TRUE)
		end
		doTransformItem(item.uid, item.itemid - 1)
		return TRUE
	elseif isInArray(keys, item.itemid) == TRUE then
		if itemEx.actionid > 0 then
			if item.actionid == itemEx.actionid then
				for i = 0, table.maxn(closedDoors) do
					if itemEx.itemid == closedDoors[i] then
						doTransformItem(itemEx.uid, openDoors[i])
						return TRUE
					end
				end
			end
			doPlayerSendCancel(cid, "The key does not match.")
			return TRUE
		end
	else
		for i = 0, table.maxn(closedDoors) do
			if item.itemid == closedDoors[i] then
				if item.actionid == 0 then
					doTransformItem(item.uid, openDoors[i])
				else
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is locked.")
				end
				return TRUE
			end
		end
	end
	return FALSE
end
 
Back
Top