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

[EVENT] antiTrash - antiTheft system for houses [TFS 1.x]

I was also having trouble with a list with multiple names:
For me it was only working with one player on the list and that's because if you print(#accessList) you'll receive the number of characters/spaces in each name.

For examples the 2 names below are on the accessList --> #accessList = 22
jack in the box
godric

To fix that I replaced this line and used string.find:
Code:
if house ~= self:getHouse() and self:getName():lower() ~= house:getAccessList(SUBOWNER_LIST):lower() then

with:
Code:
if (house ~= self:getHouse() and not string.find(house:getAccessList(SUBOWNER_LIST):lower(), self:getName():lower())) then

You'll have to replace the other line that performs the same function.

You're right, the original code only works if there's one character invited / subowner.
The code snippet you provided works better, but would also allow my character "Red" to move an item if their invite list had a character named "Predator"

Red
 
Code:
if (house ~= self:getHouse() and not string.find(house:getAccessList(SUBOWNER_LIST):lower(), "%f[%a]" .. self:getName():lower() .. "%f[%A]") then
if you want to match exact name, should work
 
@Red @Zothion
Thanks guys for pointing that out, completely overlooked that! Something I'll keep in mind next time I use string.find().

Now that you guys reminded me about this system (I no longer use it) there was one other thing that players were doing but I forgot to post here:
If you place a backpack/bag down on top of a tile --> open it --> then in the inventory area press the "up arrow" you can bypass the onBrowseField check and take the items from the browse field window.

Maybe you guys have a solution for that one?

Edit:
Maybe an onUse check when trying to open the container following the same criteria as other checks could do it.
 
I implemented something like this to TFS 1.3, so if you wish to use this feature, you can get latest TFS 1.3 sources :)
 
I can not 1.3 because I have 1.2 already relegated and covered for the 792 version
 
Lua:
local antiTrash = true
        local antiTheft = true
        if antiTrash then
        local tile = Tile(toPosition)
        print(title)
        print(tile:hasFlag(TILESTATE_HOUSE))
        if tile and tile:hasFlag(TILESTATE_HOUSE) then
            local house = tile:getHouse()
            print(house)
            if house then
                print(house)
                local accessList = House.getAccessList
                local playerName = self:getName():lower()
                print(accessList)
                print(house:getAccessList(SUBOWNER_LIST))
                if (house ~= self:getHouse() and not string.find(house:getAccessList(SUBOWNER_LIST):lower(), "%f[%a]" .. self:getName():lower() .. "%f[%A]")) then
                    self:sendTextMessage(MESSAGE_STATUS_SMALL, "You cannot throw items into players houses, which you are not invited to.")
                    return false
                end
            end
        end
    end
    
    if antiTheft then
        local tile = Tile(fromPosition)
        if tile and tile:hasFlag(TILESTATE_HOUSE) then
            local house = tile:getHouse()
            if house then
                if (house ~= self:getHouse() and not string.find(house:getAccessList(SUBOWNER_LIST):lower(), "%f[%a]" .. self:getName():lower() .. "%f[%A]")) then
                    self:sendTextMessage(MESSAGE_STATUS_SMALL, "You cannot move items from house, which you are only guest to.")
                    return false
                end
            end
        end
    end

1611025140571.png
Can anyone tell me why he is returning me nill and false using Tile ()?
 
No one got this to work for tfs 1.2? I can't move items at all when I have this script with tfs 1.2 like I can't move eq or items in general :)
 
Last edited:
Back
Top