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

Max item on one title TFS1.2

Ichito123

New Member
Joined
Nov 25, 2013
Messages
36
Reaction score
3
If the topic is already there, I just hook it up and put it into a logical whole.

We enter the directory:
data/events/script/player.lua

then we look for a function:

Lua:
Player:onMoveItem

It might look like this:

Code:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
        if fromPosition:isInRange(MATCH.BOARD.from, MATCH.BOARD.to) then
            self:sendCancelMessage('Sorry, not possible.')
            return false
        end

        if toPosition:isInRange(MATCH.BOARD.from, MATCH.BOARD.to) then
            self:sendCancelMessage('Sorry, not possible.')
            return false
        end
    return true
end

We add another function under this one.

Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
    local tile = Tile(toPosition)
    local max = 4
    if tile then
        if #tile:getItems() >= max then
            self:sendTextMessage(MESSAGE_STATUS_SMALL, 'This tile has the max amount of items on it already.')
            return false
        end
    end
    return true
end


As you can imagine, this function allows you to put only 4 items on each other.

Code:
local max = 4

I was looking for a working code for a long time and this one flashes for me :) I hope it will be useful to someone.
 
I'd just put "You cannot throw there."/"Sorry, not possible." message to give it more native client/server feeling.
 
Back
Top