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

Oasis Tomb Lever Door Not Work

Azerty

Active Member
Joined
Apr 15, 2022
Messages
301
Solutions
4
Reaction score
31
Good night, I have a problem with this script that should work as follows: Find 3 carrots on the levers and go through the door.
However, when I find a carrot on one of the levers the door opens and when I try to go through the door I can't.
Can anyone help me with this problem?

oasis.jpg

Lua:
local doorPosition = Position(33122, 32765, 14)

local function revertCarrotAndLever(position, carrotPosition)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end

    local carrotItem = Tile(carrotPosition):getItemById(2684)
    if carrotItem then
        carrotItem:remove()
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1243 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You first must find the Carrot under one of the three hats to get the access!')
        return true
    end

    if item.itemid ~= 1945 then
        return true
    end

    if math.random(3) == 1 then
        local hatPosition = Position(toPosition.x - 1, toPosition.y, toPosition.z)
        hatPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        doorPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        Game.createItem(2684, 1, hatPosition)

        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You found the carrot! The door is open!')
        item:transform(1946)
        addEvent(revertCarrotAndLever, 4 * 1000, toPosition, hatPosition)


        local doorItem = Tile(doorPosition):getItemById(1243)
        if doorItem then
            doorItem:transform(1244)
        end
        return true
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You guessed wrong! Take this! Carrot changed now the Hat!')
    doAreaCombatHealth(player, COMBAT_PHYSICALDAMAGE, player:getPosition(), 0, -200, -200, CONST_ME_POFF)
    return true
end
 
Try my script, i made it out of cipsoft moveuse.dat file. It's Othire distro, not TFS btw.


Lua:
local MagicHat = 2662
local Carrot = 2684
local StuffedBunny = 2355
local Position_Door = {x = 33122, y = 32765,z = 14}

function onUse(cid, item, fromPosition, itemEx, toPosition)

    local Position_Target = {x = fromPosition.x-1, y = fromPosition.y, z = fromPosition.z, stackpos=2}
    local Target = getThingfromPos(Position_Target)

    for i = 2, 255 do
        local Position_Target_Iteration = {x = fromPosition.x-1, y = fromPosition.y, z = fromPosition.z, stackpos=2}
        local Target_Iteration = getThingfromPos(Position_Target_Iteration)
            if Target_Iteration.uid > 0 then
                doRemoveItem(Target_Iteration.uid)
            else
                break
            end
    end
    if item.actionid == 30008 and item.itemid == 1945 then
        if math.random(100) <= 70 then
            doCreateItem(StuffedBunny,1,Position_Target)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -200, -200, CONST_ME_HITBYFIRE)
        else
            doCreateItem(Carrot,1,Position_Target)
            doSendMagicEffect(Position_Target, CONST_ME_MAGIC_GREEN)
            doSendMagicEffect(Position_Door, CONST_ME_MAGIC_GREEN)
            setPlayerStorageValue(cid,30011,1)
        end
    elseif item.actionid == 30008 and item.itemid == 1946 then
        doCreateItem(MagicHat,1,Position_Target)
    end
end
 
Post automatically merged:


View attachment 67223
Ah, I see.

You'll need to modify this file


Something like this should work.

Lua:
function onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return false
    end
 
    -- carrot quest door exception
    if position == Position(33122, 32765, 14) then
        return true
    end
 
    if creature:getStorageValue(item.actionid) == -1 and not creature:getGroup():getAccess() then
        creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The door seems to be sealed against unwanted intruders.")
        creature:teleportTo(fromPosition, true)
        return false
    end
    return true
end
 
Ah, I see.

You'll need to modify this file


Something like this should work.

Lua:
function onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return false
    end
 
    -- carrot quest door exception
    if position == Position(33122, 32765, 14) then
        return true
    end
 
    if creature:getStorageValue(item.actionid) == -1 and not creature:getGroup():getAccess() then
        creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The door seems to be sealed against unwanted intruders.")
        creature:teleportTo(fromPosition, true)
        return false
    end
    return true
end
I don't understand, the original file is in the action folder.
 
I don't understand, the original file is in the action folder
The door you're using is called a 'quest door', based on storage values.

It's registered in data/movements.xml , so that the door will automatically close.

The edit I made above, will make an exception for your quest (that is not using a storage value), but still allow the door to function as expected everywhere else.
 
The door you're using is called a 'quest door', based on storage values.

It's registered in data/movements.xml , so that the door will automatically close.

The edit I made above, will make an exception for your quest (that is not using a storage value), but still allow the door to function as expected everywhere else.
The correct thing is to make the 3 carrots appear for the door to open and be able to pass...
 
How I do? Your script doesn't work in TFS 1.3
You can take the logic from my script and adapt it to your distro. In the other hand, you can check the moveuse.dat file and make your own.
According to cipsoft files, everytime you pull a lever, there is a 70% chance to get the stuffed rabbit and damage, and a 30% chance of get the hat and unlock the door. (Unlock the door for the player, not open the door).
 
You can take the logic from my script and adapt it to your distro. In the other hand, you can check the moveuse.dat file and make your own.
According to cipsoft files, everytime you pull a lever, there is a 70% chance to get the stuffed rabbit and damage, and a 30% chance of get the hat and unlock the door. (Unlock the door for the player, not open the door).
I don't know how to convert =/
 
Back
Top