• 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

Code:
function onUse(cid, item, frompos, item2, topos)

if item.uid == 10092 then
if getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 then
doPlayerSendTextMessage(cid, 22, "You can pass, you are a Paladin.")
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 can\'t pass, you aren\'t a Paladin.')
end
return 1
else
return 0
end
end
Code:
function onUse(cid, item, frompos, item2, topos)

if item.uid == 10093 then
if getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6 then
doPlayerSendTextMessage(cid, 22, "You can pass, you are a Druid.")
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 can\'t pass, you aren\'t a Druid.')
end
return 1
else
return 0
end
end
Code:
function onUse(cid, item, frompos, item2, topos)

if item.uid == 10094 then
if getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 5 then
doPlayerSendTextMessage(cid, 22, "You can pass, you are a Sorcerer.")
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 can\'t pass, you aren\'t a Sorcerer.')
end
return 1
else
return 0
end
end
Code:
function onUse(cid, item, frompos, item2, topos)

if item.uid == 10091 then
if getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
doPlayerSendTextMessage(cid, 22, "You can pass, you are a 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 can\'t pass, you aren\'t a Knight.')
end
return 1
else
return 0
end
end
 
You have to put the item id of the door there.

The door you are using as a vocation door has an item ID xxxx. You have to put it in the script eg. item.uid == xxxx.
 
Soo i have to Do 4 .lua files for every vocation 1 (without promotion vocations). Should i do that on data/movements/scripts right? Now.. How do i add that on the movements.xml?
 
Lua:
-- Made by Cain
-- Otfans.net
-- Vocation door script

-- CONFIG --

-- Door unique ID - Change to an unused uniqe ID --
local door = 9880

local druid = {1, 5} -- Druid vocation ID's
local sorc = {2, 6} -- Sorcerer vocation ID's
local paladin = {3, 7} -- Paladin vocation ID's
local knight = {4, 8} -- Knight vocation ID's

-- Errors --
local errors {
    druid = "Only druids can enter this door."
    sorc = "Only sorcerers can enter this door."
    paladin = "Only paladins can enter this door."
    knight = "Only knights can enter this door."
}

-- END CONFIG --

function onUse(cid, item, frompos, item2, topos)

    if isPlayer(cid) == TRUE then
    
        if item.uid == door and getPlayerVocation(cid) == druid then
            doPlayerSendTextMessage(cid, 22, "You can pass.")
            
        else
            if lookdir == 0 then
                doTeleportThing(cid, playerPos.y -= 1)
                doPlayerSendCancel(cid, errors.druid)
            elseif lookdir == 1 then
                doTeleportThing(cid, playerPos.x -= 1)
                doPlayerSendCancel(cid, errors.druid)
            elseif lookdir == 2 then
                doTeleportThing(cid, playerPos.y += 1)
                doPlayerSendCancel(cid, errors.druid)
            elseif lookdir == 3 then
                doTeleportThing(cid, playerPos.x += 1)
                doPlayerSendCancel(cid, errors.druid)
            end
        end
        
        if item.uid == door and getPlayerVocation(cid) == sorc then
            doPlayerSendTextMessage(cid, 22, "You can pass.")
        else
            if lookdir == 0 then
                doTeleportThing(cid, playerPos.y -= 1)
                doPlayerSendCancel(cid, errors.sorc)
            elseif lookdir == 1 then
                doTeleportThing(cid, playerPos.x -= 1)
                doPlayerSendCancel(cid, errors.sorc)
            elseif lookdir == 2 then
                doTeleportThing(cid, playerPos.y += 1)
                doPlayerSendCancel(cid, errors.sorc)
            elseif lookdir == 3 then
                doTeleportThing(cid, playerPos.x += 1)
                doPlayerSendCancel(cid, errors.sorc)
            end
        end
        
        if item.uid == door and getPlayerVocation(cid) == paladin then
            doPlayerSendTextMessage(cid, 22, "You can pass.")
        else
            if lookdir == 0 then
                doTeleportThing(cid, playerPos.y -= 1)
                doPlayerSendCancel(cid, errors.paladin)
            elseif lookdir == 1 then
                doTeleportThing(cid, playerPos.x -= 1)
                doPlayerSendCancel(cid, errors.paladin)
            elseif lookdir == 2 then
                doTeleportThing(cid, playerPos.y += 1)
                doPlayerSendCancel(cid, errors.paladin)
            elseif lookdir == 3 then
                doTeleportThing(cid, playerPos.x += 1)
                doPlayerSendCancel(cid, errors.paladin)
            end
        end
        
        if item.uid == door and getPlayerVocation(cid) == knight then
            doPlayerSendTextMessage(cid, 22, "You can pass.")
        else
            if lookdir == 0 then
                doTeleportThing(cid, playerPos.y -= 1)
                doPlayerSendCancel(cid, errors.knight)
            elseif lookdir == 1 then
                doTeleportThing(cid, playerPos.x -= 1)
                doPlayerSendCancel(cid, errors.knight)
            elseif lookdir == 2 then
                doTeleportThing(cid, playerPos.y += 1)
                doPlayerSendCancel(cid, errors.knight)
            elseif lookdir == 3 then
                doTeleportThing(cid, playerPos.x += 1)
                doPlayerSendCancel(cid, errors.knight)
            end
        end
    end
    
    return TRUE
    
end

HTML:
<!-- Vocation door -->
<action uniqueid="9880" script="other/vocation_door.lua"/>


EDIT: After looking over the code(not being able to test it since im on a mac) i discovered that you should be able to walk through the door if it is open, since this is only onUse. When you use the door the first time it will open and teleport you 1 sqm away. So then its just for the player to walk right in since its already open.

Fixing this tomorrow. Need some sleep now.
 
Last edited:
Back
Top