• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

request Lua script TFS[1.2]

jackl90

Member
Joined
Jul 25, 2017
Messages
249
Reaction score
12
using Player:onMoveItem function on script.

Im looking for a script that block players to put different items on x container.

For example

Container id = 5050
Items allowed = 1203,1045,1345

if players try to add an item different of items allowed, a message appear
"You cannot add this type of item"


Note: i found one script like this here on forum, but people can add items not allowed directly on container, have this problem there.
 
using Player:eek:nMoveItem function on script.

Im looking for a script that block players to put different items on x container.

For example

Container id = 5050
Items allowed = 1203,1045,1345

if players try to add an item different of items allowed, a message appear
"You cannot add this type of item"


Note: i found one script like this here on forum, but people can add items not allowed directly on container, have this problem there.
Outside of function above:
LUA:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)

Add:
LUA:
local containers = {
    [5050] = {1203, 1045, 1345}
}
(You can add more containers here if you like)

Then after:
LUA:
if toPosition.x ~= CONTAINER_POSITION then
    return true
end

Add:
LUA:
if toCylinder and isContainer(toCylinder.uid) and containers[toCylinder.itemid] then
    if not isInArray(containers[toCylinder.itemid], item.itemid) then
        self:sendCancelMessage("You cannot add this type of item.")
        return false
    end
end

Untested, so let me know how it works out.
 
work, but i can put items not allowed, for example, the container is on arrow slot, a item not allowed on hand for example, i push directly on container without open, work normally.

just blocking if i push a item not allowed in slots of container opened :/
 
work, but i can put items not allowed, for example, the container is on arrow slot, a item not allowed on hand for example, i push directly on container without open, work normally.

just blocking if i push a item not allowed in slots of container opened :/
Try this instead, hopefully no errors

LUA:
    local toItem = toPosition.y <= 10 and self:getSlotItem(toPosition.y) or isInArray({64, 65, 66}, toPosition.y) and toCylinder:getItem(toPosition.z) or toCylinder
    if toItem and isContainer(toItem.uid) and containers[toItem.itemid] then
        if not isInArray(containers[toItem.itemid], item.itemid) then
            self:sendCancelMessage("You cannot add this type of item.")
            return false
        end
    end
 
Last edited:
Back
Top