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

TFS 0.X I don't want the player to throw items at top

ParrotPLPL

Banned User
Joined
May 19, 2024
Messages
8
Reaction score
2
Lua:
local config = {
    itemIds = {2445, 2550, 2436, 6101, 2408, 7435, 7429, 5803},
    position = {x = 156, y = 58, z = 7}
}

local currentIndex = 1

function onThink(cid, interval)
    local tile = getThingfromPos(config.position)
    local item = nil
    for _, id in ipairs(config.itemIds) do
        item = getTileItemById(config.position, id)
        if item.uid ~= 0 then
            doTransformItem(item.uid, config.itemIds[currentIndex])
            doSendMagicEffect(config.position, CONST_ME_MAGIC_GREEN)
            currentIndex = (currentIndex % #config.itemIds) + 1
            break
        end
    end
    return true
end

if you move item on top nothing happens

Lua:
function onAddItem(moveItem, tileItem, position, cid)
    if isPlayer(cid) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You cannot drop items on this tile.")
        -- Move the item back to the player's inventory
        local playerPosition = getPlayerPosition(cid)
        doTeleportThing(moveItem.uid, playerPosition, true)
    end
end

this item returns from below the player

I want nothing to happen



Untitled Project.gif


I wanted it to stay like this

Untitled Project.gif
 
Last edited:
You can modify the onAddItem function to check if the item is being placed on the designated table tile. If it is, you can prevent the item from being placed and return it to the player's inventory.

Try this:

Lua:
local config = {
    itemIds = {2445, 2550, 2436, 6101, 2408, 7435, 7429, 5803},
    tablePosition = {x = 156, y = 58, z = 7}
}

local currentIndex = 1

function onThink(cid, interval)
    local tileItem = getTileItemById(config.tablePosition, config.itemIds[currentIndex])
    if tileItem.uid ~= 0 then
        doTransformItem(tileItem.uid, config.itemIds[currentIndex])
        doSendMagicEffect(config.tablePosition, CONST_ME_MAGIC_GREEN)
        currentIndex = (currentIndex % #config.itemIds) + 1
    end
    return true
end

function onAddItem(moveItem, tileItem, position, cid)
    if isPlayer(cid) then
        if position.x == config.tablePosition.x and position.y == config.tablePosition.y and position.z == config.tablePosition.z then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You cannot drop items on this tile.")
            doTeleportThing(moveItem.uid, getPlayerPosition(cid), true) -- Teleport item back to player
        end
    end
end
 
Back
Top