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()