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

Vocation Door TFS 1.2

Light Relief

New Member
Joined
May 5, 2024
Messages
2
Reaction score
2
Hi guys,

Sorry if there is already an answer posted somewhere for this but I'm struggling.
I was following this thread regarding vocation doors:

The OP came across an error similar to the one I'm having below:
Lua Script Error: [Action Interface]
data/actions/scripts/other/berserkerdoor.lua:onUse
data/actions/scripts/other/berserkerdoor.lua:24: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/other/berserkerdoor.lua:24: in function <data/actions/scripts/other/berserkerdoor.lua:3>

In the thread, they changed 1 line of code and then reported it was working for them.
I changed that line of code and still get the exact same error.
I have 1 door for each of the 7 vocations I've made(and no voc able to open all doors). Apart from actually being able to open the door that matches your vocation, it seems to be working fine.

Am I missing something obvious? Here is the one I'm using for berserker(0 = no voc, 9 = berserker):

LUA:
local vocations = {0, 9}
local dir = 1 --1 = north/south door....2 = east/west door
function onUse(cid, item, fromPos, item2, toPos)
    if not isInArray(vocations, getPlayerVocation(cid)) then
        return doPlayerSendTextMessage(cid, 22, "You must be a berserker 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

Thank you in advance!
 
Solution
X
Immediate fix is changing
LUA:
player:teleportTo(pos)
to
LUA:
cid:teleportTo(pos)

Better long term fix is using all 1.0+ functions, instead of the older 0.x functions.
Immediate fix is changing
LUA:
player:teleportTo(pos)
to
LUA:
cid:teleportTo(pos)

Better long term fix is using all 1.0+ functions, instead of the older 0.x functions.
 
Solution
Back
Top