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

Action Doors system.

marcryzius

New Member
Joined
Mar 22, 2009
Messages
61
Reaction score
0
With this script to use a key in the door it will open and will be possible to open and close the door until it is locked with the key again.

replace your doors.lua by this script:
Lua:
function checkStackpos(pos,POS)
local new_pos = (pos == nil) and POS or pos
	new_pos.stackpos = 255
	local thing = getThingFromPos(new_pos)
	if(isCreature(thing.uid) == TRUE and thing.itemid > 0)then
		return FALSE
	end
	return TRUE
end
CHAVE_DOORS = {}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local groupid = getPlayerGroupId(cid)
	if(getItemLevelDoor(item.itemid) > 0)then
		if(item.actionid > 0 and item.actionid <= 2000)then
			if(getPlayerLevel(cid) >= item.actionid-getItemLevelDoor(item.itemid))or(groupid >= 3)then
				doTransformItem(item.uid, item.itemid + 1)
				doTeleportThing(cid, toPosition, TRUE)
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are not experienced enough to pass.")
			end
		end
		return TRUE
	elseif(checkStackpos(fromPosition,toPosition) == FALSE)then
		return TRUE,doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,'You can not close the door because someone is using it.')
	end
	if(doors[item.itemid] ~= nil and item.actionid == 0)then
		doTransformItem(item.uid,doors[item.itemid])
	end
	if(isInArray(specialDoors, item.itemid) == TRUE) then
		if(item.actionid ~= 0 and getPlayerStorageValue(cid, item.actionid) > 0)or(groupid >= 3)then
			if(checkStackpos(fromPosition,toPosition) == TRUE)then
				doTransformItem(item.uid, item.itemid +1)
				doTeleportThing(cid, toPosition, TRUE)
			else
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,'You can not close the door because someone is using it.')
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.")
		end
		return TRUE
	end
	if((isInArray(horizontalOpenDoors, item.itemid) == TRUE)
	or(isInArray(verticalOpenDoors, item.itemid) == TRUE))then
		if((item.actionid == 0)and(checkStackpos(fromPosition,toPosition) == TRUE))then
			return TRUE,doTransformItem(item.uid, item.itemid -1)
		end
	elseif(isInArray(closingDoors, item.itemid) ~= TRUE)and(item.actionid == 0)
	and(checkStackpos(fromPosition,toPosition) == TRUE)then
		return TRUE,doTransformItem(item.uid, item.itemid +1)
	end
	if(isInArray(keys, item.itemid) == TRUE) then
		if(isCreature(itemEx.uid) == TRUE)then
			return TRUE,doPlayerSendTextMessage(cid,25,'You can not close the door because someone is using it.')
		end
		if(itemEx.actionid == item.actionid)and(doors[itemEx.itemid] ~= nil)then
			if(isInArray(CHAVE_DOORS,itemEx.actionid) == FALSE)and(itemEx.actionid > 0)then
				table.insert(CHAVE_DOORS,itemEx.actionid)
			end
				doTransformItem(itemEx.uid,itemEx.itemid+1)
		elseif((isInArray(horizontalOpenDoors,itemEx.itemid)==TRUE
			or isInArray(verticalOpenDoors,itemEx.itemid)==TRUE)
			and(item.actionid == itemEx.actionid))then
				doTransformItem(itemEx.uid,itemEx.itemid-1)
			for c,_ in pairs(CHAVE_DOORS) do
				if(CHAVE_DOORS[c] == itemEx.actionid)then
					table.remove(CHAVE_DOORS,c)
				end
			end
		else
			doPlayerSendCancel(cid,'Wrong key for this door.')
		end
		return TRUE
	end
	if(isInArray(CHAVE_DOORS,item.actionid) == TRUE)and(doors[item.itemid] ~= nil)then
		doTransformItem(item.uid, doors[item.itemid])
	elseif((isInArray(horizontalOpenDoors, item.itemid) == TRUE
	or isInArray(verticalOpenDoors, item.itemid) == TRUE)
	and(isInArray(CHAVE_DOORS,item.actionid) == TRUE))then
		if(checkStackpos(fromPosition,toPosition) == TRUE)then
			doTransformItem(item.uid,item.itemid-1)
		else
			doPlayerSendTextMessage(cid,25,'You can not close the door because someone is using it.')
		end
	else
		doPlayerSendTextMessage(cid,25,'It is locked.')
	end
	return TRUE
end


tested in tfs 0.3.3 crying damson.
script to otland no post in other forums :peace:
 
You don't need this script for 0.3.6, its already implemented.
 
Back
Top