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

I'm Looking for help with Rookgaard katana room quest script

olje

New Member
Joined
Dec 26, 2016
Messages
38
Reaction score
1
Hi guys
I have problems with katana room quest script
pNxAIFA.jpg

closed door's id is 5107 and when you pull lever to the left the door opens and door id is 5109 then when pull lever to the right the door closes and lock so is needed doSetItemActionId(uid, actionid) I think
and I created something like this
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1946 then
doRemoveItem(getTileItemById({x=32177, y=32148, z=11}, 5107).uid)
doCreateItem(5109, 1, {x=32177, y=32148, z=11})
doTransformItem(item.uid,item.itemid-1)
elseif item.itemid == 1945 then
doRemoveItem(getTileItemById({x=32177, y=32148, z=11}, 5109).uid)
doCreateItem(5107, 1, {x=32177, y=32148, z=11})
doTransformItem(item.uid,item.itemid+1)
but sometimes it's messed up look:
JZB32VF.jpg


I need your help thanks!
 
Solution
pull to the left good door is open but to the right luadoremove item not found ;p
Woot? How you can get error luadoremove... if there's no such function at all. Are you using 0.4? If yes, keep in mind that 0.4 is bugged.

Try again then:
Code:
local doorPosition = {x=32177, y=32148, z=11}
local locked = 5107
local nonlocked = {5108, 5109}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local doorlocked = getTileItemById(doorPosition, locked).uid
    local doornonlocked1 = getTileItemById(doorPosition, nonlocked[1]).uid
    local doornonlocked2 = getTileItemById(doorPosition, nonlocked[2]).uid

    if doorlocked > 0 then
        doTransformItem(doorlocked, nonlocked[2])
    elseif doornonlocked1 > 0 then...
Not sure if I did it properly for 0.4 but try this: (ur using 0.4 or 0.3 right?)

Code:
local config = {
    doorPosition = {x=32177, y=32148, z=11}, -- position of door
    doorOpenId = 5109, -- open door ID
    doorCloseId = 5107 -- closed door ID
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local doorOpen = getTileItemById(config.doorPosition, config.doorOpenId)
    local doorClosed = getTileItemById(config.doorPosition, config.doorCloseId)
    
    if doorOpen then
        doTransformItem(doorOpen.uid, config.doorCloseId)
    elseif doorClosed then
        doTransformItem(doorClosed.uid, config.doorOpenId)
    else
        doPlayerSendCancel(cid, "Well, this is awkward ... couldn't find a door.")
    end
    
    return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
ye using 0.4 3884
doesn't work lever moving left right and just error
<LuaDoTransformItem> Item not found

Does it say which line? Try removing the .uid from doorOpen.uid and doorClosed.uid, since I don't remember how things worked in 0.4

If that doesn't work then Undo that and change:
if doorOpen to if doorOpen > 0 and the same for the doorClosed check


Edit:

Try this:
Code:
local config = {
    doorPosition = {x=32177, y=32148, z=11}, -- position of door
    doorOpenId = 5109, -- open door ID
    doorCloseId = 5107 -- closed door ID
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local doorOpen = getTileItemById(config.doorPosition, config.doorOpenId).uid
    local doorClosed = getTileItemById(config.doorPosition, config.doorCloseId).uid
 
    if doorOpen > 0 then
        doTransformItem(doorOpen, config.doorCloseId)
    elseif doorClosed > 0 then
        doTransformItem(doorClosed, config.doorOpenId)
    else
        doPlayerSendCancel(cid, "Well, this is awkward ... couldn't find a door.")
    end
 
    return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end

Try this one too if you got time:
Code:
local config = {
    doorPosition = {x=32177, y=32148, z=11}, -- position of door
    doors = {
        [5109] = 5107,   -- [doorId] = transformId
        [5107] = 5109
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    for k,v in pairs(config.doors) do
        local door = getTileItemById(config.doorPosition, k).uid
        if door > 0 then
            doTransformItem(door, v)
            break
        end
    end   
    return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Last edited:
thanks man second script works but how to implement doSetItemActionId(uid, actionid) to lock the door only when pulling lever to the right like on rl but don't lock when do this manually but for the first time I still need to set actionid 100 in RME
and locked door id is 5108 ;s
 
Last edited:
thanks man second script works but how to implement doSetItemActionId(uid, actionid) to lock the door only when pulling lever to the right like on rl but don't lock when do this manually but for the first time I still need to set actionid 100 in RME
and locked door id is 5108 ;s

There is a config table on the top where you can change the IDs, positions, and action id to whatever is the correct ones.

Code:
local config = {
    doorPosition = {x=32177, y=32148, z=11}, -- position of door
    doorOpenId = 5109, -- open door ID
    doorCloseId = 5108, -- closed door ID
    lockedDoorAID = 100 -- Action Id for when closing door with lever
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local doorOpen = getTileItemById(config.doorPosition, config.doorOpenId).uid
    local doorClosed = getTileItemById(config.doorPosition, config.doorCloseId).uid
 
    if doorOpen > 0 then
        doTransformItem(doorOpen, config.doorCloseId)
        doSetItemActionId(doorOpen, config.lockedDoorAID) -- setting Action Id to closed door
    elseif doorClosed > 0 then
        doTransformItem(doorClosed, config.doorOpenId)
        doItemEraseAttribute(doorClosed, 'aid') -- remove action Id when it's open (no clue if this is right key for 0.4)
    else
        doPlayerSendCancel(cid, "Well, this is awkward ... couldn't find a door.")
    end
 
    return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
this script working sorry ;p
Code:
local config = {
    doorPosition = {x=32177, y=32148, z=11}, -- position of door
    doors = {
        [5109] = 5107,   -- [doorId] = transformId
        [5107] = 5109
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    for k,v in pairs(config.doors) do
        local door = getTileItemById(config.doorPosition, k).uid
        if door > 0 then
            doTransformItem(door, v)
            break
        end
    end   
    return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
this script working sorry ;p
Code:
local config = {
    doorPosition = {x=32177, y=32148, z=11}, -- position of door
    doors = {
        [5109] = 5107,   -- [doorId] = transformId
        [5107] = 5109
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    for k,v in pairs(config.doors) do
        local door = getTileItemById(config.doorPosition, k).uid
        if door > 0 then
            doTransformItem(door, v)
            break
        end
    end 
    return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end

Code:
local config = {
    doorPosition = {x=32177, y=32148, z=11}, -- position of door
    doorActionId = 100,
    doors = { -- [doorId] = {closeId, setAction = true/false}
        [5109] = {5108, true}, -- open to close & set Aid
        [5108] = {5109, false} -- close to open & remove Aid
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    for k,v in pairs(config.doors) do
        local door = getTileItemById(config.doorPosition, k).uid
        if door > 0 then
            -- close or open door
            doTransformItem(door, v[1])
            -- set or remove aid
            if v[2] then
                doItemSetActionId(door, config.doorActionId)
            else
                doItemEraseAttribute(door, 'aid')
            end
            break
        end
    end  
    return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Last edited:
mhm is one problem when I close door manually script don't work anymore and lever moving left right
sJzbaTb.jpg

and weird think description It is locked without actionid but door aren't locked
rrEhE7D.jpg
 
mhm is one problem when I close door manually script don't work anymore and lever moving left right
sJzbaTb.jpg

and weird think description It is locked without actionid but door aren't locked
rrEhE7D.jpg

change doSetItemActionId for doItemSetActionId
 
Why do we even need the aid?
I'm so confused.

try this.
Code:
local config = {
   doorPosition = {x=32177, y=32148, z=11}, -- position of door
   doors = { -- [doorId] = {closeId, setAction = true/false}
       [5107] = {5109}, -- closed&locked to open
       [5108] = {5107}, -- closed to closed&locked
       [5109] = {5107} -- open to closed&locked
   }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   for k,v in pairs(config.doors) do
       local door = getTileItemById(config.doorPosition, k).uid
       if door > 0 then
           doTransformItem(door, v[1])
           break
       end
   end
   return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Last edited:
nope when I pull lever to the left nothing happens just door transform from 5108 to 5107 I click on it and see and pull to the right nothing happens and again pull ot the left then door opens but when I close door manually door is locked but shouldn't
should lock only when pull lever
 
I literally just tested it, minus the missing comma in the table, everything is working perfectly?

5107 = locked door
5108 = closed door
5109 = open door

Use 5107. Door is locked.
Use lever. Door transforms to 5109.
Use 5109. Door transforms to 5108.
Use 5108. Door transforms to 5109.
Use 5109. Door transforms to 5108.
Use lever. Door transforms to 5107.
Use 5107. Door is locked.
Use lever. Door transforms to 5109.
Use lever. Door transforms to 5107.
Use 5107. Door is locked.

Congratulations. I just tested everything, and everything is working as intended.

Further, I went onto real tibia, and tested this all on my level 56.
Works exactly the same as the script above.

Here's exactly what I have in my test server.
I suggest that you double check it's installed correctly on your server.

Code:
00:43 You see a closed door.
ItemID: [5107].
Position: [X: 1352] [Y: 1411] [Z: 7].

00:43 You see a switch.
ItemID: [1946], ActionID: [45725].
TransformTo: [1945] (onUse).
Position: [X: 1356] [Y: 1410] [Z: 7].
Code:
<action actionid="45725" event="script" value="aaXikiniExampleScripts/katana_door_thing.lua"/>
Code:
local config = {
   doorPosition = {x = 1352, y = 1411, z = 7}, -- position of door
   doors = {
       [5107] = {5109}, -- closed&locked to open
       [5108] = {5107}, -- closed to closed&locked
       [5109] = {5107} -- open to closed&locked
   }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   print(1)
   for k,v in pairs(config.doors) do
       print(2)
       local door = getTileItemById(config.doorPosition, k).uid
       if door > 0 then
           print(3)
           doTransformItem(door, v[1])
           break
       end
   end
   return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
doesn't work as it should :(
I tested with putting door 5108 and 5107 in map editor and still the same
by the way 5107 has description (locked) but is not locked I need to add action id 100 in map editor because on rl when you enter the room for the first time door is locked
 
Your server is weird then.
Cuz in mine, 5107 is locked.
Check your items.xml and/or replace with what my items.xml is.

If that doesn't work, try the aid method below.. cuz I can't test it.
Code:
   <item id="5107" article="a" name="closed door">
       <attribute key="type" value="door"/>
       <attribute key="blockprojectile" value="1"/>
       <attribute key="description" value="It is locked."/>
   </item>
   <item id="5108" article="a" name="closed door">
       <attribute key="type" value="door"/>
       <attribute key="blockprojectile" value="1"/>
       <attribute key="transformUseTo" value="5109"/>
   </item>
   <item id="5109" article="an" name="open door">
       <attribute key="type" value="door"/>
       <attribute key="transformUseTo" value="5108"/>
   </item>

Only use this, if the door fix doesn't work. (make sure to revert the door changes)
Code:
local config = {
   doorPosition = {x = 32177, y = 32148, z = 11}, -- position of door
   doorActionId = 100,
   doors = { -- [doorId] = {closeId, setAction = true/false}
       [5107] = {5109, false},
       [5108] = {5107, true},
       [5109] = {5107, true}
   }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   for k,v in pairs(config.doors) do
       local door = getTileItemById(config.doorPosition, k).uid
       if door > 0 then
           doTransformItem(door, v[1])
           if v[2] then
               doItemSetActionId(door, config.doorActionId)
           else
               doItemEraseAttribute(door, 'aid')
           end
           break
       end
   end 
   return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Last edited:
alright i fixed 5107 door now is locked but is one problem when pull lever to the left i should be able to open and close door open and clos all the timee but when I close the door is locked is 5107 but should be locked only when pull the lever to the right not manually

so I need to start with door 5108 with actionid 100 in map editor and then combine 5107 5108 5109 in script ;d
 
Last edited:
problem is when I close the door manually and at the same time the lever is to the left and now when I pull the lever to the right door transform to 5109 so is open but the door should just lock so transform to 5108 with actionid
it's tricky to combine these three 5107 5108 5109 in script so we need soemthing like [5107] = {5108} but there is already [5107] = {5109} and 5107 can't be duplicated ;p
 
Last edited:
then change it to 5108?
also you dont need arrays that hold 1 value when you can have a single value
aka
[5107] = 5108 instead of [5107] = {5108}
 
then change it to 5108?
also you dont need arrays that hold 1 value when you can have a single value
aka
[5107] = 5108 instead of [5107] = {5108}
[5107] = 5108 close door
[5107] = 5109 open door
doesn't work in one script can't be duplicated 5107
 
Back
Top