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

Solved [TFS 1.2]Movement script assistance

Caduceus

Unknown Member
Joined
May 10, 2010
Messages
321
Solutions
2
Reaction score
24
I have the wall removing/resetting, however, if the wall is removed, it will not return false. So the event keeps appling on reset.

Code:
  local storage = 15009
  local wallPos = {
            [1] = {x=1227, y=768, z=5, stackpos=1}
        }

        local time_ = 20 -- 10 seconds

        function onStepIn(cid, item, position, fromPosition)
         local player = Player(cid)
            if not player then
                return true
            end
          
            local function reset()
                -- reset wall
                    Game.createItem(3492, 1, wallPos[1])
                end
              
                -- check if player has storage
            if player:getStorageValue(storage) < 1 then
                player:sendTextMessage(MESSAGE_INFO_DESCR, "You Must Complete the Frozen Hell Quest!")
                player:teleportTo(fromPosition, false)
                doSendMagicEffect(pos, CONST_ME_POOF)
                return false
             end
            -- [[If wall is down, then can not reuse again while down.
                  This is my problem area]]
             if not item.itemid == 3492 then
             player:sendTextMessage(MESSAGE_INFO_DESCR, "The wall is down.")
             return false
           end

            -- add reset
            addEvent(reset, time_ * 1000)
 
            -- remove walls, send message
            for i = 1, #wallPos do
            item:getPosition():sendMagicEffect(CONST_ME_SOUND_BLUE)
                doRemoveItem(getThingfromPos(wallPos[i]).uid)
            end
          
            player:sendTextMessage(MESSAGE_INFO_DESCR, "It's dangerous out there. Enter at your own risk!")
            return true
        end
 
Code:
local storage = 15009
local wallPos = {
    [1] = {x=1227, y=768, z=5, stackpos=1}
}

local time_ = 20 -- 10 seconds

function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    if not player then
        return true
    end
        
    local function reset()
        -- reset wall
        Game.createItem(3492, 1, wallPos[1])
    end
            
    -- check if player has storage
    if player:getStorageValue(storage) < 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You Must Complete the Frozen Hell Quest!")
        player:teleportTo(fromPosition, false)
        doSendMagicEffect(pos, CONST_ME_POOF)
        return true
    end

    -- if wall is up
    if getTileItemById(wallPos[1], 3492).uid > 0 then
        -- add reset
        addEvent(reset, time_ * 1000)

        -- remove walls, send message
        for i = 1, #wallPos do
            item:getPosition():sendMagicEffect(CONST_ME_SOUND_BLUE)
            doRemoveItem(getThingfromPos(wallPos[i]).uid)
        end
        
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It's dangerous out there. Enter at your own risk!")
    else
    -- if wall is down
        player:sendTextMessage(MESSAGE_INFO_DESCR, "The wall is down.")
        return true
    end

    return true
end

Good luck.
 
Back
Top