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

Lua Vocation door not working tfs 1.2

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
922
Location
Chile
Hello guys, i have 2 vocations doors, one for knights and paladins, and the other for sorcerer and druid (and ofc the promotion versions)

this one of them:
Code:
-- Sorcerer Vocation Door by Vagox edited by Streamside (iam not scripter) --
function onUse(cid, item, frompos, item2, topos)
pvoc = getPlayerVocation(cid)
if item.aid == 5001 then
if pvoc == 3 or pvoc == 4 or pvoc == 7 or pvoc == 8 then
doPlayerSendTextMessage(cid, 22, "You can pass, you are a paladin or knight.")
pos = getPlayerPosition(cid)
if pos.x == topos.x then
if pos.y < topos.y then
pos.y = topos.y + 1
else
pos.y = topos.y - 1
end
elseif pos.y == topos.y then
if pos.x < topos.x then
pos.x = topos.x + 1
else
pos.x = topos.x - 1
end
else
doPlayerSendTextMessage(cid,22,'Please stand in front of the door.')
return 1
end
doTeleportThing(cid,pos)
doSendMagicEffect(topos,12)
else
doPlayerSendTextMessage(cid,22,'You cant pass, you arent paladin or knight.')
end
return 1
else
return 0
end
end

this doesn't work, but it doens't give me any console error :/
can someone help me fix this door or provide me a new one? i have door vocations that work, but none thats useful for 2 vocations at the same time
 
LUA:
local vocations = {1, 2, 5, 6}
local dir = 1 --1 = north/south door....2 = east/west door
function onUse(cid, item, fromPos, item2, toPos)
    if not isInArray(vocations, player:getVocation():getId()) then
        return doPlayerSendTextMessage(cid, 22, "You must be a sorcerer or druid to pass here.")
    end
 
    local pPos = getPlayerPosition(cid)
 
    if dir == 1 then
        if pPos.y < toPos.y then
            pos = {x = toPos.x, y = toPos.y + 1, z = toPos.z}
        elseif pPos.y > toPos.y then
            pos = {x = toPos.x, y = toPos.y - 1, z = toPos.z}
        end
    else
        if pPos.x < toPos.x then
            pos = {x = toPos.x + 1, y = toPos.y, z = toPos.z}
        elseif pPos.x > toPos.x then
            pos = {x = toPos.x - 1, y = toPos.y, z = toPos.z}
        end
    end
if pos then
    player:teleportTo(pos)
    doSendMagicEffect(toPos, 12)
end
return true
end


in actions.xml make sure you put in actionid="5001" or whatever you put the actionid in mapeditor for door.
 
Last edited:
LUA:
local vocations = {1, 2, 5, 6}
local dir = 1 --1 = north/south door....2 = east/west door
function onUse(cid, item, fromPos, item2, toPos)
    if not isInArray(vocations, player:getVocation():getId()) then
        return doPlayerSendTextMessage(cid, 22, "You must be a sorcerer or druid to pass here.")
    end
 
    local pPos = getPlayerPosition(cid)
 
    if dir == 1 then
        if pPos.y < toPos.y then
            pos = {x = toPos.x, y = toPos.y + 1, z = toPos.z}
        elseif pPos.y > toPos.y then
            pos = {x = toPos.x, y = toPos.y - 1, z = toPos.z}
        end
    else
        if pPos.x < toPos.x then
            pos = {x = toPos.x + 1, y = toPos.y, z = toPos.z}
        elseif pPos.x > toPos.x then
            pos = {x = toPos.x - 1, y = toPos.y, z = toPos.z}
        end
    end
if pos then
    player:teleportTo(pos)
    doSendMagicEffect(toPos, 12)
end
return true
end


in actions.xml make sure you put in actionid="5001" or whatever you put the actionid in mapeditor for door.




oohh i get an error here:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/vocdoorsorcdruid.lua:onUse
data/actions/scripts/vocdoorsorcdruid.lua:4: attempt to index global 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/actions/scripts/vocdoorsorcdruid.lua:4: in function <data/actions/scripts/vocdoorsorcdruid.lua:3>
 
Sorry was very late for me when I posed change this:

LUA:
if not isInArray(vocations, player:getVocation():getId()) then
        return doPlayerSendTextMessage(cid, 22, "You must be a sorcerer or druid to pass here.")
end

to

LUA:
if not isInArray(vocations getPlayerVocation(cid)) then
        return doPlayerSendTextMessage(cid, 22, "You must be a sorcerer or druid to pass here.")
end
 
Last edited by a moderator:
Sorry was very late for me when I posed change this:

LUA:
if not isInArray(vocations, player:getVocation():getId()) then
        return doPlayerSendTextMessage(cid, 22, "You must be a sorcerer or druid to pass here.")
end

to

LUA:
if not isInArray(vocations getPlayerVocation(cid)) then
        return doPlayerSendTextMessage(cid, 22, "You must be a sorcerer or druid to pass here.")
end
thank you!! no errors now, but i have a question, whattype of door should i use? because im using expertise door and this script doesn't work cos it ask me for lvl
 
In your actions.xml make sure you have it set up:

Code:
<action actionid="5001" event="script" value="voc_door"/>
 
Back
Top