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

Key open Magic door

freddzor11

Member
Joined
May 25, 2009
Messages
695
Reaction score
5
Hello!

I wonder if it's possible to use key at magic door, key disappear, you teleports into it and can enter the room
I use 0.3.6 if that even matter
 
Just a question, are you not suposed to leave? Since the key is destroyed, u can't open the door again if you want to leave o_O
 
Here's the script, I tested it and works:
actions/scripts/other magicdoorkey.lua
Code:
function onUse(cid, item, frompos, item2, topos)
    otherside = {x=241, y=143, z=7}
    if item2.actionid == 3400 and item2.itemid == 1257 then
        doTeleportThing(cid, otherside)
        doRemoveItem(item.uid,2086)
    else
        doPlayerSendTextMessage(cid, 22, "wrong door")
    end
 
    return 1
end

actions.xml:
Code:
<action itemid="2086" script="other/magicdoorkey.lua" />

Now, I will get an error for duplicated registered items, because all doors and keys alredy have their own script. So we need to change this. In my case, it's the 2086 item id (purple key)
so I will go to actions xml and go here:
Code:
<!-- Doors -->
    <action fromid="1209" toid="1214" event="script" value="other/doors.lua"/>
    <action fromid="1219" toid="1262" event="script" value="other/doors.lua"/>
    <action fromid="1539" toid="1542" event="script" value="other/doors.lua"/>
    <action fromid="2086" toid="2092" event="script" value="other/doors.lua"/>
    <action fromid="3535" toid="3552" event="script" value="other/doors.lua"/>
    <action fromid="4913" toid="4918" event="script" value="other/doors.lua"/>
and change this line:
Code:
<action fromid="2086" toid="2092" event="script" value="other/doors.lua"/>
to this line:
Code:
<action fromid="2087" toid="2092" event="script" value="other/doors.lua"/>
so now we removed the purple key from the normal door script (used for locked doors normally) and can use it for our magic door.
 
That is the location you get teleported to. sorry I ment to explain.
In my script "otherside" is the other side of the door:p but those are my coordinations, you'll ahve to put your map cordinations there instead, to where you want to go when key used on the door xd

edit: AFF I forgot to tell you, you need to put action id on the door on ur mapeditor to: 3400
v019.png


@ freddzor11

You may also add a text to show and a magic effect like this:
Code:
function onUse(cid, item, frompos, item2, topos)
    otherside = {x=241, y=143, z=7}
    if item2.actionid == 3400 and item2.itemid == 1257 then
        doTeleportThing(cid, otherside)
        doRemoveItem(item.uid,2086)
        doPlayerSendTextMessage(cid, 22, "The key was destroyed.. But you passed through the door!")
        doSendMagicEffect(temple, 12)
    else
        doPlayerSendTextMessage(cid, 22, "wrong door")
    end
   
    return 1
end
 
Last edited:
@Swiff brahhh when i tried this i can only do it with one door????

Sorry if that sounds stupid but when put the action id as 3400 its take me to same room as my first door....
but another script with different postion annd still takes me there?
That is the location you get teleported to. sorry I ment to explain.
In my script "otherside" is the other side of the door:p but those are my coordinations, you'll ahve to put your map cordinations there instead, to where you want to go when key used on the door xd

edit: AFF I forgot to tell you, you need to put action id on the door on ur mapeditor to: 3400
v019.png


@ freddzor11

You may also add a text to show and a magic effect like this:
Code:
function onUse(cid, item, frompos, item2, topos)
    otherside = {x=241, y=143, z=7}
    if item2.actionid == 3400 and item2.itemid == 1257 then
        doTeleportThing(cid, otherside)
        doRemoveItem(item.uid,2086)
        doPlayerSendTextMessage(cid, 22, "The key was destroyed.. But you passed through the door!")
        doSendMagicEffect(temple, 12)
    else
        doPlayerSendTextMessage(cid, 22, "wrong door")
    end
 
    return 1
end
 
@Swiff brahhh when i tried this i can only do it with one door????

Sorry if that sounds stupid but when put the action id as 3400 its take me to same room as my first door....
but another script with different postion annd still takes me there?
Try this.
XML:
<action actionid="3400" script="teleportingDoorKey.lua" />
Lua:
local keyId = 2086
local doorActionId = 3400

function onUse(cid, item, fromPosition, itemEx, toPosition) 
    if itemEx.actionid == doorActionId and item.itemid == keyId then
        local playerPosition = getThingPos(cid)
        if playerPosition.x - toPosition.x ~= 0 and playerPosition.y - toPosition.y ~= 0 then
            doPlayerSendTextMessage(cid, 22, "You must be standing in front of the door to see the keyhole.")
            return true
        end
        local otherSide
        if playerPosition.x < toPosition.x then
            otherSide = {x = toPosition.x + 1, y = toPosition.y, z = toPosition.z}
        elseif playerPosition.x > toPosition.x then
            otherSide = {x = toPosition.x - 1, y = toPosition.y, z = toPosition.z}
        elseif playerPosition.y < toPosition.y then
            otherSide = {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}
        else
            otherSide = {x = toPosition.x, y = toPosition.y - 1, z = toPosition.z}
        end
        doTeleportThing(cid, otherside)
        doPlayerSendTextMessage(cid, 22, "The key was destroyed.. But you passed through the door!")
        doSendMagicEffect(getThingPos(cid), 12)
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, 22, "Key does not fit.")
    end
    return true
end
 
Try this.
XML:
<action actionid="3400" script="teleportingDoorKey.lua" />
Lua:
local keyId = 2086
local doorActionId = 3400

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.actionid == doorActionId and item.itemid == keyId then
        local playerPosition = getThingPos(cid)
        if playerPosition.x - toPosition.x ~= 0 and playerPosition.y - toPosition.y ~= 0 then
            doPlayerSendTextMessage(cid, 22, "You must be standing in front of the door to see the keyhole.")
            return true
        end
        local otherSide
        if playerPosition.x < toPosition.x then
            otherSide = {x = toPosition.x + 1, y = toPosition.y, z = toPosition.z}
        elseif playerPosition.x > toPosition.x then
            otherSide = {x = toPosition.x - 1, y = toPosition.y, z = toPosition.z}
        elseif playerPosition.y < toPosition.y then
            otherSide = {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}
        else
            otherSide = {x = toPosition.x, y = toPosition.y - 1, z = toPosition.z}
        end
        doTeleportThing(cid, otherside)
        doPlayerSendTextMessage(cid, 22, "The key was destroyed.. But you passed through the door!")
        doSendMagicEffect(getThingPos(cid), 12)
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, 22, "Key does not fit.")
    end
    return true
end
Can you be star and put my pos on were they go??? Sorry mate XDDD i've tryed to do it but its taking me upto to know to ask you XDD

All my door id's are 5288 (if thats needed)

1108 1109 7
1120 1195 7
1073 1177 7
1048 1134 7

All used by the same key 8046

Kind regards ! <3
 
Can you be star and put my pos on were they go??? Sorry mate XDDD i've tryed to do it but its taking me upto to know to ask you XDD

All my door id's are 5288 (if thats needed)

1108 1109 7
1120 1195 7
1073 1177 7
1048 1134 7

All used by the same key 8046

Kind regards ! <3
There is no position required.

Just put the ActionId on the doors in remere's.
The script will automatically teleport the player to the correct location when you use the key on the door.
 
It didnt work big man XDDD
There is no position required.

Just put the ActionId on the doors in remere's.
The script will automatically teleport the player to the correct location when you use the key on the door.
i have the key that works that the first guy posted.. one door works... but i did try to do yours and it didnt do anything..
i just want the key to do the same as the first door i've done.. click the key on the door and it tps you to that pos... but each door i have is a different pos.

and yeah i put the action id on the door! haha !
 
It didnt work big man XDDD

i have the key that works that the first guy posted.. one door works... but i did try to do yours and it didnt do anything..
i just want the key to do the same as the first door i've done.. click the key on the door and it tps you to that pos... but each door i have is a different pos.

and yeah i put the action id on the door! haha !

Not sure what the issue was, but we decided on a workaround, to use the door instead of the key on the door.
Lua:
local keyId = 2086

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerItemCount(cid, keyId) < 1 then
        doPlayerSendTextMessage(cid, 22, "This door requires a special key to enter.")
        return true
    end
    
    local playerPosition = getThingPos(cid)
    if playerPosition.x - toPosition.x ~= 0 and playerPosition.y - toPosition.y ~= 0 then
        doPlayerSendTextMessage(cid, 22, "You must be standing in front of the door to see the keyhole.")
        return true
    end
    local otherSide
    if playerPosition.x < toPosition.x then
        otherSide = {x = toPosition.x + 1, y = toPosition.y, z = toPosition.z}
    elseif playerPosition.x > toPosition.x then
        otherSide = {x = toPosition.x - 1, y = toPosition.y, z = toPosition.z}
    elseif playerPosition.y < toPosition.y then
        otherSide = {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}
    else
        otherSide = {x = toPosition.x, y = toPosition.y - 1, z = toPosition.z}
    end
    doTeleportThing(cid, otherSide)
    doPlayerSendTextMessage(cid, 22, "The key was destroyed.. But you passed through the door!")
    doSendMagicEffect(getThingPos(cid), 12)
    doPlayerRemoveItem(cid, keyId, 1)
    return true
end
 
Back
Top