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

Action Voc-Based Door

Call Me Taffy

Call Me Maybe
Joined
Aug 9, 2009
Messages
651
Reaction score
123
Umm well I just perfected my Voc-Based Door scripts thanks to some (unknowingly) help by Cybermaster. I'm 100% sure there's a easier way to do this, but here it is for those who want it.

Tested, and works perfectly on 0.3.5+.

In actions.xml you place the UID (of door) and name of script:
Code:
<action uniqueid="19001" event="script" value="door1.lua"/>

And in the door1.lua file you place:
Code:
local newPos = {x=995, y=1000, z=9}

function onUse(cid, item, frompos, item2, topos)
local vocation = getPlayerVocation(cid)
    if item.itemid == 1259 and item.uid == 19001 then
		if vocation == 1 then
            doTeleportThing(cid, newPos)
            doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67))
        else
            doPlayerSendCancel(cid, "Wrong vocation...")
        end
	end
    return TRUE
end

local newPos = Area you'll be after using the door.
item.itemid = The ID of the door (In my case, the marble door facing east/west.
item.uid = the UID I used on that marble door in RME or SimOne's.
if vocation = Set to w/e vocation you want to be able to use the door.
doSendMagicEffect = Sends random effect on the person after using the door, 1-67 = alot, and you can check em all out.
else = Sends message "Wrong vocation..." if it's the wrong vocation.

Pretty simple eh xD
 
Lua:
local newPos = {x=995, y=1000, z=9}

function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 1259 and item.uid == 19001 then
		return doTeleportThing(cid, newPos) and doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67)) and TRUE or doPlayerSendCancel(cid, "Wrong vocation...")
	end
end

But nice anyway, :thumbup:.
 
Lua:
local newPos = {x=995, y=1000, z=9}

function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 1259 and item.uid == 19001 then
		return doTeleportThing(cid, newPos) and doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67)) and TRUE or doPlayerSendCancel(cid, "Wrong vocation...")
	end
end

But nice anyway, :thumbup:.

But where does your script check for vocations? And what about us nubs that don't like scrolling all the way over lol...

And thanks for good comment xD
 
But where does your script check for vocations? And what about us nubs that don't like scrolling all the way over lol...

And thanks for good comment xD
Lua:
local newPos = {x=995, y=1000, z=9}

function onUse(cid, item, frompos, item2, topos)
        if item.itemid == 1259 and item.uid == 19001 then
                return getPlayerVocation(cid) == 1 and doTeleportThing(cid, newPos) and doSendMagicEffect(getCreaturePosition(cid), math.random(1, 67)) and TRUE or doPlayerSendCancel(cid, "Wrong vocation...")
        end
end
My miss ;D, and no problem :).
 
@Shawak:
This script don't do exactly that's what you think.
 
Thanks for the door, will help with my vocation quest when people try and take rewards ;)
 
How do you add more than one vocation for each door?

made you an easy version.

Lua:
function onUse(cid, item, frompos, item2, topos)
local newPos = {x= , y= , z= } -- change the coordinates to where the character shall be teleported to.
local doorId = xx -- id of the door which you want to use
local uniqueId = xxx -- uniqueId which the door has to have
local vocations {1,2,5,6} -- example table, you can add as much vocations as you want to.
	if item.itemid == doorId and item.uid == uniqueId then
		if isInArray(getPlayerVocation(cid), vocations) == TRUE then
			doTeleportThing(cid,newPos,FALSE)
		else
			doPlayerSendCancel(cid,"Wrong Vocation...")
		end
	end
	return TRUE
end


kind regards, Evil Hero
 
I cant get it to work.
It just says Wrong Vocation.

Any one know how to fix that ?

using tfs 0.3.5pl1 server
 
Why do you post already existing scripts? :D
I think its in TFS from 0.3beta.
TFS has vocation, level, group, gender, premium, skull doors in actions already.
How to use? Make 'level doors' (one of doors that look like level doors on real tibia) in map editor. If you want be sure you selected right ID of doors open items.xml in TFS and find door id. All level doors have special parameter:
<item id="7047" article="a" name="gate of expertise">
<attribute key="type" value="door"/>
<attribute key="levelDoor" value="1000"/>
<attribute key="blockprojectile" value="1"/>
</item>
Now you can set ActionID of level doors.
Level doors (1000 + level):
Action id 1002 - lvl 2 required to pass
Action id 1120 - lvl 120 required to pass
Vocation doors (100 + vocation id):
Action id 101 - only player with vocation id 1 or fromVoc id 1(sorcerer and master sorcerer) can pass
Action id 104 - only player with vocation id 4 or fromVoc id 4(knight and elite knight) can pass
Skull doors (180 + skull id):
Action id 184 - only player with red skull can pass
Action id 180 - only player with none skull can pass
SKULL_NONE = 0
SKULL_YELLOW = 1
SKULL_GREEN = 2
SKULL_WHITE = 3
SKULL_RED = 4
Premium doors - Action id 189 - only players with premium account can pass

NOT blocked doors look like level doors - Action ID 190 - all can pass
:)
 
wouldnt it be better if the new pos jsut like getPlayerPosition.x+1
and like that?
 
wouldnt it be better if the new pos jsut like getPlayerPosition.x+1
and like that?
Did you read my post ? xD
TFS doors code:
PHP:
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)

	return (item.uid == thing.uid or thing.itemid < 100 or field.itemid == 0)
end

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

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(fromPosition.x ~= CONTAINER_POSITION and isPlayerPzLocked(cid) and getTileInfo(fromPosition).protection) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		return true
	end

	if(getItemLevelDoor(item.itemid) > 0) then
		if(item.actionid == 189) then
			if(not isPremium(cid)) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
				return true
			end

			doorEnter(cid, item, toPosition)
			return true
		end

		local gender = item.actionid - 186
		if(isInArray({PLAYERSEX_FEMALE,  PLAYERSEX_MALE, PLAYERSEX_GAMEMASTER}, gender)) then
			if(gender ~= getPlayerSex(cid)) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
				return true
			end

			doorEnter(cid, item, toPosition)
			return true
		end

		local skull = item.actionid - 180
		if(skull >= SKULL_NONE and skull <= SKULL_BLACK) then
			if(skull ~= getCreatureSkullType(cid)) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
				return true
			end

			doorEnter(cid, item, toPosition)
			return true
		end

		local group = item.actionid - 150
		if(group >= 0 and group < 30) then
			if(group > getPlayerGroupId(cid)) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
				return true
			end

			doorEnter(cid, item, toPosition)
			return true
		end

		local vocation = item.actionid - 100
		if(vocation >= 0 and vocation < 50) then
			local playerVocationInfo = getVocationInfo(getPlayerVocation(cid))
			if(playerVocationInfo.id ~= vocation and playerVocationInfo.fromVocation ~= vocation) then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
				return true
			end

			doorEnter(cid, item, toPosition)
			return true
		end

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

		return true
	end

	if(isInArray(specialDoors, item.itemid)) then
		if(item.actionid == 100 or (item.actionid ~= 0 and getPlayerStorageValue(cid, item.actionid) > 0)) then
			doorEnter(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)) then
		if(itemEx.actionid > 0) then
			if(item.actionid == itemEx.actionid and doors[itemEx.itemid] ~= nil) then
				doTransformItem(itemEx.uid, doors[itemEx.itemid])
				return true
			end

			doPlayerSendCancel(cid, "The key does not match.")
			return true
		end

		return false
	end

	if(isInArray(horizontalOpenDoors, item.itemid) and checkStackpos(item, fromPosition)) 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
			local pzDoorPosition = getTileInfo(doorPosition).protection
			local pzNewPosition = getTileInfo(newPosition).protection
			if((pzDoorPosition and not pzNewPosition and doorCreature.uid ~= cid) or
				(not pzDoorPosition and pzNewPosition and doorCreature.uid == cid and isPlayerPzLocked(cid))) then
				doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			else
				doTeleportThing(doorCreature.uid, newPosition)
				if(not isInArray(closingDoors, item.itemid)) 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) and checkStackpos(item, fromPosition)) 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(getTileInfo(doorPosition).protection and not getTileInfo(newPosition).protection and doorCreature.uid ~= cid) then
				doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			else
				doTeleportThing(doorCreature.uid, newPosition)
				if(not isInArray(closingDoors, item.itemid)) 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)) 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
 
Back
Top