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

[REQUEST] FULLY working door system

Status
Not open for further replies.

Keraxel

Ω Obfuscator Ω
Joined
Feb 2, 2008
Messages
941
Reaction score
5
Location
Republic of Poland
Anybody have/can write full door system with key system, level door system, quest door system for TFS? i have original door system, but it doesn't working. Thanks in advance.
 
doors.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	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(keys, item.itemid) == TRUE then
		if itemEx.actionid > 0 then
			if item.actionid == itemEx.actionid then
				if doors[itemEx.itemid] ~= nil then
					doTransformItem(itemEx.uid, doors[itemEx.itemid])
					return TRUE
				end
			end
			doPlayerSendCancel(cid, "The key does not match.")
			return TRUE
		end
		return FALSE
	elseif isInArray(horizontalOpenDoors, item.itemid) == TRUE then
		local newPosition = toPosition
		newPosition.y = newPosition.y + 1
		local doorPosition = fromPosition
		doorPosition.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
		local doorCreature = getThingfromPos(doorPosition)
		if doorCreature.itemid ~= 0 then
			if getTilePzInfo(doorPosition) == TRUE and getTilePzInfo(newPosition) == FALSE and doorCreature.uid ~= cid then
				doPlayerSendCancel(cid, "Sorry, not possible.")
				return TRUE
			else
				doTeleportThing(doorCreature.uid, newPosition, TRUE)
			end
		end
		doTransformItem(item.uid, item.itemid - 1)
		return TRUE
	elseif isInArray(verticalOpenDoors, item.itemid) == TRUE then
		local newPosition = toPosition
		newPosition.x = newPosition.x + 1
		local doorPosition = fromPosition
		doorPosition.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
		local doorCreature = getThingfromPos(doorPosition)
		if doorCreature.itemid ~= 0 then
			if getTilePzInfo(doorPosition) == TRUE and getTilePzInfo(newPosition) == FALSE and doorCreature.uid ~= cid then
				doPlayerSendCancel(cid, "Sorry, not possible.")
				return TRUE
			else
				doTeleportThing(doorCreature.uid, newPosition, TRUE)
			end
		end
		doTransformItem(item.uid, item.itemid - 1)
		return TRUE
	elseif doors[item.itemid] ~= nil then
		if item.actionid == 0 then
			doTransformItem(item.uid, doors[item.itemid])
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is locked.")
		end
		return TRUE
	end
	return FALSE
end

actions.xml
Code:
<action fromid="1209" toid="1214" script="other/doors.lua"/>
	<action fromid="1219" toid="1262" script="other/doors.lua"/>
	<action fromid="1539" toid="1542" script="other/doors.lua"/>
	<action fromid="2086" toid="2092" script="other/doors.lua"/>
	<action fromid="3535" toid="3552" script="other/doors.lua"/>
	<action fromid="4913" toid="4918" script="other/doors.lua"/>
	<action fromid="5082" toid="5085" script="other/doors.lua"/>
	<action fromid="5098" toid="5145" script="other/doors.lua"/>
	<action fromid="5278" toid="5295" script="other/doors.lua"/>
	<action fromid="5515" toid="5518" script="other/doors.lua"/>
	<action fromid="5732" toid="5737" script="other/doors.lua"/>
	<action fromid="5745" toid="5749" script="other/doors.lua"/>
	<action fromid="6192" toid="6209" script="other/doors.lua"/>
	<action fromid="6249" toid="6266" script="other/doors.lua"/>
	<action fromid="6795" toid="6802" script="other/doors.lua"/>
	<action fromid="6891" toid="6908" script="other/doors.lua"/>
	<action fromid="7033" toid="7050" script="other/doors.lua"/>
	<action fromid="7054" toid="7057" script="other/doors.lua"/>
 
Here is Fixing Code

Doors.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	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(keys, item.itemid) == TRUE then
		if itemEx.actionid > 0 then
			if item.actionid == itemEx.actionid then
				if doors[itemEx.itemid] ~= nil then
					doTransformItem(itemEx.uid, doors[itemEx.itemid])
					return TRUE
				end
			end
			doPlayerSendCancel(cid, "The key does not match.")
			return TRUE
		end
		return FALSE
	elseif isInArray(horizontalOpenDoors, item.itemid) == TRUE then
		local newPosition = toPosition
		newPosition.y = newPosition.y + 1
		local doorPosition = fromPosition
		doorPosition.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
		local doorCreature = getThingfromPos(doorPosition)
		if doorCreature.itemid ~= 0 then
			if getTilePzInfo(doorPosition) == TRUE and getTilePzInfo(newPosition) == FALSE and doorCreature.uid ~= cid then
				doPlayerSendCancel(cid, "Sorry, not possible.")
				return TRUE
			else
				doTeleportThing(doorCreature.uid, newPosition, TRUE)
			end
		end
		doTransformItem(item.uid, item.itemid - 1)
		return TRUE
	elseif isInArray(verticalOpenDoors, item.itemid) == TRUE then
		local newPosition = toPosition
		newPosition.x = newPosition.x + 1
		local doorPosition = fromPosition
		doorPosition.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
		local doorCreature = getThingfromPos(doorPosition)
		if doorCreature.itemid ~= 0 then
			if getTilePzInfo(doorPosition) == TRUE and getTilePzInfo(newPosition) == FALSE and doorCreature.uid ~= cid then
				doPlayerSendCancel(cid, "Sorry, not possible.")
				return TRUE
			else
				doTeleportThing(doorCreature.uid, newPosition, TRUE)
			end
		end
		doTransformItem(item.uid, item.itemid - 1)
		return TRUE
	elseif doors[item.itemid] ~= nil then
		if item.actionid == 0 then
			doTransformItem(item.uid, doors[item.itemid])
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is locked.")
		end
		return TRUE
	end
	return FALSE
end
In Actions.xml Add:
Code:
	<action fromid="1209" toid="1214" script="doors.lua"/>
	<action fromid="1219" toid="1262" script="doors.lua"/>
	<action fromid="1539" toid="1542" script="doors.lua"/>
	<action fromid="2086" toid="2092" script="doors.lua"/>
	<action fromid="3535" toid="3552" script="doors.lua"/>
	<action fromid="4913" toid="4918" script="doors.lua"/>
	<action fromid="5082" toid="5085" script="doors.lua"/>
	<action fromid="5098" toid="5145" script="doors.lua"/>
	<action fromid="5278" toid="5295" script="doors.lua"/>
	<action fromid="5515" toid="5518" script="doors.lua"/>
	<action fromid="5732" toid="5737" script="doors.lua"/>
	<action fromid="5745" toid="5749" script="doors.lua"/>
	<action fromid="6192" toid="6209" script="doors.lua"/>
	<action fromid="6249" toid="6266" script="doors.lua"/>
	<action fromid="6795" toid="6802" script="doors.lua"/>
	<action fromid="6891" toid="6908" script="doors.lua"/>
	<action fromid="7033" toid="7050" script="doors.lua"/>
	<action fromid="7054" toid="7057" script="doors.lua"/>
i Hope it helps u ;p
 
I know some doors didn't work because they weren't in the proper areas (or not even added) in the global.lua. Have you tried updating your global.lua file to the newest one. As far as I've seen, its working properly with the latest one.
 
Door system are great, but isInArray function id TFS are bugged ;/
To solve you must paste bottom function in global.lua and change all isInArray to itIsInArray ;)
Code:
function itIsInArray(t, v)
    for _, value in pairs(t) do
        if (v == value) then
            return TRUE
        end
    end
    return FALSE
end
 
Status
Not open for further replies.
Back
Top