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

Lua Open door with iten on player

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
931
Solutions
7
Reaction score
127
Location
Brazil
YouTube
caruniawikibr
hello, I would like to create a place where the player only had access to the door if he was holding an item. in the bag or not, it doesn't matter.
tfs 1.5 7.72
 
For only one door you can use that:

Lua:
local action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
      if player:getItemCount(ITEM_ID) < 1 then
            return false
      end

      item:transform(DOOR_OPEN_ID)
      player:teleportTo(toPosition, true)

      return true
end
action:uid(11111)
action:register()
 
For only one door you can use that:

Lua:
local action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
      if player:getItemCount(ITEM_ID) < 1 then
            return false
      end

      item:transform(DOOR_OPEN_ID)
      player:teleportTo(toPosition, true)

      return true
end
action:uid(11111)
action:register()
hey hey, tested on 10,98 1,4+ . and aint working for me :(

maybe can try someone make for 10,98 1,4+ ?
 
tested on 10,98 1,4+
It's working fine for me. Which one do you want? If you have the ID, click the door to enter, and the item (key) will be removed.
Post automatically merged:

try!!
Lua:
local config = {
    ITEM_ID = 2400, -- Replace with the ID of the item you want to check
    DOOR_CLOSED_ID = 1209, -- Replace with the ID of the closed door
    DOOR_OPEN_ID = 1211, -- Replace with the ID of the open door
    UID = 6558, -- UID
    MESSAGE_SUCCESS = "You opened the door." -- Success message
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getId() ~= config.DOOR_CLOSED_ID or player:getItemCount(config.ITEM_ID) < 1 then
        player:sendCancelMessage("You cannot open this door.")
        return false
    end

    player:removeItem(config.ITEM_ID, 1) -- Remove 1 unit of the item from the inventory
    item:transform(config.DOOR_OPEN_ID) -- Transform the closed door into an open door
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, config.MESSAGE_SUCCESS) -- Send the success message

    return true
end

action:uid(config.UID)
action:register()
 
Last edited:
It's working fine for me. Which one do you want? If you have the ID, click the door to enter, and the item (key) will be removed.
i set in map on this doors actionid

script:

Lua:
local action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
      if player:getItemCount(40554) < 1 then
            return false
      end

      item:transform(6262)
      player:teleportTo(toPosition, true)

      return true
end
action:uid(24200)
action:register()

and for me nothing happens,

or its bad doors maybe, il test other doors...
Post automatically merged:

oke i fixed it + managed to upgrade it lol xd


Lua:
local action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)



      if player:getItemCount(40554) < 1 then
      player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You need vip coin to enter.")
      player:getPosition():sendMagicEffect(1006)
            return false
      end

      item:transform(6262)
      toPosition:sendMagicEffect(583)
      player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You Entered Vip Room.")
      player:removeItem(40554, 1)
      player:teleportTo(toPosition, true)
      return true
end
action:uid(24200)
action:register()
 
Last edited:
Back
Top