• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Advanced doors & tiles!

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,670
Solutions
125
Reaction score
1,117
Location
Germany
GitHub
slawkens
Advanced doors & tiles.

This pack will add new features to your doors, and special tiles.

Usage: You place any level doors or special tile (I mean these which are used with depots -ex. id: 416)

Then you set actionid of it to:
-100+vocationID - only for vocation
example - 104 - Knight can pass (Elite Knight also!), but if you set actionid = 108 only Elite Knight can pass. It works with custom vocations too!​
-200+groupID - only for group
example - 202 - only TUTOR can pass.​
-300+skullID - only for player with selected skull
example - 304 - only players with RED_SKULL can enter​
-400 - only females can enter
-401 - only males
-500 - only premium accounts

These works only for TILES:
-501 - tile only for player
-502 - tile only for monster
-503 - tile only for NPC

-506 - tile not for player
-507 - tile not for monster
-508 - tile not for NPC

-1000+level - level tile
example - 1150 - only players with level 150+ can enter.​

-504 - tile not for player (Only monster && NPC can enter) [Deprecated - DONT use, instead use 506]

OK Lets implement it!

Replace actions/scripts/other/doors.lua with this:
Code:
PLAYERSEX_FEMALE = 0
PLAYERSEX_MALE = 1

local function checkStackpos(item, position)
	position.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
	local thing = getThingfromPos(position)
	position.stackpos = STACKPOS_TOP_FIELD
	local field = getThingfromPos(position)
	if(item.uid ~= thing.uid and thing.itemid >= 100 or field.itemid ~= 0) then
		return FALSE
	end

	return TRUE
end

local function doPlayerOpenDoor(cid, item, toPosition)
	doTransformItem(item.uid, item.itemid + 1)
	doTeleportThing(cid, toPosition, TRUE)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getItemLevelDoor(item.itemid) > 0) then
		if(item.actionid == 500) then
			if(isPremium(cid) ~= TRUE) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Premium account required to enter.")
				return TRUE
			end

			doPlayerOpenDoor(cid, item, toPosition)
			return TRUE
		end

		local gender = item.actionid - 400
		if(gender == PLAYERSEX_FEMALE or gender == PLAYERSEX_MALE) then
			local playerSex = getPlayerSex(cid)
			if(playerSex ~= gender) then
				local tmp = {"females", "males"}
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Doors only for " .. tmp[gender+ 1] .. ".")
				return TRUE
			end

			doPlayerOpenDoor(cid, item, toPosition)
			return TRUE
		end

		local skull = item.actionid - 300
		if(skull >= 0 and skull <= 50) then
			local playerSkull = getCreatureSkullType(cid)
			if(skull == 0 and playerSkull ~= SKULL_NONE) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Doors only for players without skull.")
				return TRUE
			elseif(playerSkull ~= skull) then
				local skulls = {"yellow", "green", "white", "red"}
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Doors only for players with " .. skulls[playerSkull] .. " skulls.")
				return TRUE
			end

			doPlayerOpenDoor(cid, item, toPosition)
			return TRUE
		end

		local group = item.actionid - 200
		if(group >= 0 and group <= 50) then
			local playerGroup = getPlayerGroupId(cid)
			if(playerGroup < group) then
				local tmp = getGroupInfo(group)
				if(tmp ~= FALSE) then
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Doors only for " .. tmp.name .. "s.")
				end

				return TRUE
			end

			doPlayerOpenDoor(cid, item, toPosition)
			return TRUE
		end

		local vocation = item.actionid - 100
		if(vocation >= 0 and vocation <= 50) then
			local playerVocation = getVocationInfo(getPlayerVocation(cid))
			if(playerVocation.id ~= vocation and playerVocation.fromVocation ~= vocation) then
				local tmp = getVocationInfo(vocation)
				if(tmp ~= FALSE) then
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Doors only for " .. tmp.name .. "s.")
				end

				return TRUE
			end

			doPlayerOpenDoor(cid, item, toPosition)
			return TRUE
		end

		if(item.actionid > 0 and getPlayerLevel(cid) >= (item.actionid - getItemLevelDoor(item.itemid))) then
			doPlayerOpenDoor(cid, item, toPosition)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
		end

		return TRUE
	end

	if(isInArray(specialDoors, item.itemid) == TRUE) then
		if(item.actionid == 100 or (item.actionid ~= 0 and getPlayerStorageValue(cid, item.actionid) > 0)) then
			doPlayerOpenDoor(cid, item, toPosition)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.")
		end

		return TRUE
	end

	if(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
	end

	if(isInArray(horizontalOpenDoors, item.itemid) == TRUE and checkStackpos(item, fromPosition) == 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
				doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			else
				doTeleportThing(doorCreature.uid, newPosition, TRUE)
				if(isInArray(closingDoors, item.itemid) ~= TRUE) then
					doTransformItem(item.uid, item.itemid - 1)
				end
			end

			return TRUE
		end

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

	if(isInArray(verticalOpenDoors, item.itemid) == TRUE and checkStackpos(item, fromPosition) == 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
				doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			else
				doTeleportThing(doorCreature.uid, newPosition, TRUE)
				if(isInArray(closingDoors, item.itemid) ~= TRUE) then
					doTransformItem(item.uid, item.itemid - 1)
				end
			end

			return TRUE
		end

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

	if(doors[item.itemid] ~= nil and checkStackpos(item, fromPosition) == TRUE) 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

replace movements/scripts/tiles.lua with this:
Code:
PLAYERSEX_FEMALE = 0
PLAYERSEX_MALE = 1

local increasingItems = {[416] = 417, [426] = 425, [446] = 447, [3216] = 3217, [3202] = 3215}
local decreasingItems = {[417] = 416, [425] = 426, [447] = 446, [3217] = 3216, [3215] = 3202}
local depots = {2589, 2590, 2591, 2592}

local function doPlayerMoveBack(cid, position, fromPosition)
	doTeleportThing(cid, fromPosition, FALSE)
	doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
end

local creatureFunc = {isPlayer, isMonster, isNpc}
function onStepIn(cid, item, position, fromPosition)
	if(not increasingItems[item.itemid]) then
		return TRUE
	end

	if(isPlayer(cid) ~= TRUE or isPlayerGhost(cid) ~= TRUE) then
		doTransformItem(item.uid, increasingItems[item.itemid])
	end

	if(item.actionid >= 501 and item.actionid <= 503) then
		local f = creatureFunc[item.actionid-500]
		if(f(cid) ~= TRUE) then
			doPlayerMoveBack(cid, position, fromPosition)
		end

		return TRUE
	end

	if(item.actionid == 504 and isPlayer(cid) == TRUE) then
		doPlayerMoveBack(cid, position, fromPosition)
		return TRUE
	end

	if(item.actionid >= 506 and item.actionid <= 508) then
		local f = creatureFunc[item.actionid-505]
		if(f(cid) == TRUE) then
			doPlayerMoveBack(cid, position, fromPosition)
		end

		return TRUE
	end

	if(isPlayer(cid) ~= TRUE) then
		return TRUE
	end

	if(item.actionid == 500 and isPremium(cid) ~= TRUE) then
		doPlayerMoveBack(cid, position, fromPosition)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Premium account required to enter.")
		return TRUE
	end

	local gender = item.actionid - 400
	if(gender == PLAYERSEX_FEMALE or gender == PLAYERSEX_MALE) then
		local playerSex = getPlayerSex(cid)
		if(playerSex ~= gender) then
			local tmp = {"females", "males"}
			doPlayerMoveBack(cid, position, fromPosition)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only " .. tmp[gender+ 1] .. " can enter.")
		end

		return TRUE
	end

	local skull = item.actionid - 300
	if(skull >= 0 and skull <= 50) then
		local playerSkull = getCreatureSkullType(cid)
		if(skull == 0 and playerSkull ~= SKULL_NONE) then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only players without skull can enter.")
			doPlayerMoveBack(cid, position, fromPosition)
		elseif(playerSkull ~= skull) then
			local skulls = {"yellow", "green", "white", "red"}
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only players with " .. skulls[playerSkull] .. " skull can enter.")
			doPlayerMoveBack(cid, position, fromPosition)
		end

		return TRUE
	end

	local group = item.actionid - 200
	if(group >= 0 and group <= 50) then
		local playerGroup = getPlayerGroupId(cid)
		if(playerGroup < group) then
			doPlayerMoveBack(cid, position, fromPosition)
			local tmp = getGroupInfo(group)
			if(tmp ~= FALSE) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only " .. tmp.name .. "s can enter.")
			end
		end

		return TRUE
	end

	local vocation = item.actionid - 100
	if(vocation >= 0 and vocation <= 50) then
		local playerVocation = getVocationInfo(getPlayerVocation(cid))
		if(playerVocation.id ~= vocation and playerVocation.fromVocation ~= vocation) then
			local tmp = getVocationInfo(vocation)
			if(tmp ~= FALSE) then
				doPlayerMoveBack(cid, position, fromPosition)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only " .. tmp.name .. "s can enter.")
			end
		end

		return TRUE
	end

	if(item.actionid > 1000) then
		if(getPlayerLevel(cid) < item.actionid - 1000) then
			doPlayerSendCancel(cid, "You need " .. item.actionid - 1000 .. " level to enter here.")
			doPlayerMoveBack(cid, position, fromPosition)
		end
	elseif(getTileInfo(position).protection) then
		local depotPos = getPlayerLookPos(cid)
		depotPos.stackpos = 3 -- ground = 0, table = 1, depot should be 2
		--local depot = getThingFromPos(depotPos)
		local depot
		for i = 0, #depots do
			depot = getTileItemById(depotPos, depots[i])
			if(depot.uid > 0) then
				break
			end
		end

		if(depot.uid > 0 and isInArray(depots, depot.itemid) == TRUE) then
			local depotItems = getPlayerDepotItems(cid, getDepotId(depot.uid))
			if(depotItems < 2) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Your depot contains 1 item.")
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Your depot contains " .. depotItems .. " items.")
			end
		end
	end

	return TRUE
end

function onStepOut(cid, item, position, fromPosition)
	if(decreasingItems[item.itemid] ~= nil) then
		if(isPlayer(cid) ~= TRUE or isPlayerGhost(cid) ~= TRUE) then
			doTransformItem(item.uid, decreasingItems[item.itemid])
		end
	end

	return TRUE
end
 
Last edited:
Hm, add tile that player only with storage "UID" can pass, tiles only for FACC (yeah, FACC, rotflor xD). Tile for non skulled characters and skulled aswell (for some kind of quest on pvp servers).

Nice work!
 
-200+groupID - only for group
example - 102 - only TUTOR can pass.​

bug in description :/

Code:
You must spread some Reputation around before giving it to slawkens again.
:confused:
 
Updated!
*Added tiles and doors only for players with selected SKULL. (Example in first post)
*Changed doors for males and females id.
*Bugfix o_0 (Script wasn't working, now it is! Good that no one tested it vefore!)
 
add tile that checks storage value set up as uniqueid of the tile, if storage value is > 1 then player may pass :>
 
Cool, but what i need to add to movements.xml and actions.xml?Nothing?
And what with depot tiles?It work like other from TFS?

Sry for english(bad), I from Poland :p
 
what about make door that you need items to enter like pirate outfit to enter quest door in the pirate quest
 
how about to make a title where only players and monsters can walk (it will be use full to keep the npcs on thire places so thay dont walk away from thire shop atleast i have that problem you can find your shop npc outside the city sometimes o_O
 
how about to make a title where only players and monsters can walk (it will be use full to keep the npcs on thire places so thay dont walk away from thire shop atleast i have that problem you can find your shop npc outside the city sometimes o_O

ok, implemented :) More info in first post (actions id: 506,507,508)
 
cool buy how can i make dorf/tile for rp and ek in the same doors?
 
Back
Top