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

OnMoveItem support TFS 1.2

secondlife

Active Member
Joined
Aug 1, 2009
Messages
302
Reaction score
25
Hello,
how i can use more than one script OnMoveItem? If i use 2 scripts in events/player, the third script does not work. No have errors in console. Its possible?
 
Lets say you have:
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getId() == 1300 and toPosition.x ~= CONTAINER_POSITION then
        return false
    else
        self:sendTextMessage(MESSAGE_INFO_DESCR, "You moved item to inside a container.")
    end
    return true
end

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if toPosition.x == CONTAINER_POSITION and toCylinder and toCylinder:getId() == 17432 then
        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end
    return true
end

How to put them together easily:
1)If you want that both are true to work:
Code:
-- Rename both and call each of them in Player:onMoveItem()

function Player:onMoveItem1(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getId() == 1300 and toPosition.x ~= CONTAINER_POSITION then
        return false
    else
        self:sendTextMessage(MESSAGE_INFO_DESCR, "You moved item to inside a container.")
    end
    return true
end

function Player:onMoveItem2(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if toPosition.x == CONTAINER_POSITION and toCylinder and toCylinder:getId() == 17432 then
        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end
    return true
end

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local ret1 = self:onMoveItem1(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local ret2 = self:onMoveItem2(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    return ret1 and ret2
end

2) Just one needs to be true:
Change the and in
Code:
    return ret1 and ret2
To or:
Code:
    return ret1 or ret2
 

Similar threads

  • Question Question
Replies
5
Views
625
Back
Top