• 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 1.2] onBrowseField

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hi everyone, I was trying make something like you cannot move items that are under the items ids configured by using browsefield, but it isn't working, you still can move the items. Check the code:

Code:
function Player:onBrowseField(position)
  local tile = Tile(position)
  if tile then
  local topItem = tile:getTopTopItem()
  if topItem and topItem:getId() == 8046 then
  return false
     elseif topItem and topItem:getId() == 1512 then
  return false
     elseif topItem and topItem:getId() == 1513 then
  return false
  end
  end

  return true
end

Thanks
 
Hi everyone, I was trying make something like you cannot move items that are under the items ids configured by using browsefield, but it isn't working, you still can move the items. Check the code:

Code:
function Player:onBrowseField(position)
  local tile = Tile(position)
  if tile then
  local topItem = tile:getTopTopItem()
  if topItem and topItem:getId() == 8046 then
  return false
     elseif topItem and topItem:getId() == 1512 then
  return false
     elseif topItem and topItem:getId() == 1513 then
  return false
  end
  end

  return true
end

Thanks
I cri everitiem.

Also the way you try todo, there is a problem. Maybe they throw a item over the "blockable" item, then it will count as topItem and they will be able to browsefield.

This way, it will make you able browsefield, if there is no item under the blocking item. But if there is then, you will not be able to browsefield.

Code:
function Player:onBrowseField(position)
    local tile = Tile(position)
    if not tile then
        return false
    end

    local tileItems = tile:getItems()
    for k, item in ipairs(tileItems) do
        if isInArray({8046, 1512, 1513}, item:getId()) and k < #tileItems then
            return false
        end
    end

    return true
end
 
Last edited:
I cri everitiem.

Also the way you try todo, there is a problem. Maybe they throw a item over the "blockable" item, then it will count as topItem and they will be able to browsefield.

This way, it will make you able browsefield, if there is no item under the blocking item. But if there is then, you will not be able to browsefield.

Code:
function Player:onBrowseField(position)
    local tile = Tile(position)
    if not tile then
        return false
    end

    local tileItems = tile:getItems()
    for k, item in ipairs(tile:getItems()) do
        if isInArray({8046, 1512, 1513}, item:getId()) and k < #tileItems then
            return false
        end
    end

    return true
end

And I cri when you call a function 2 times :p
You could just iterate the lenght of the array insted or use tileItems as the array in the loop.
 
Back
Top