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

Solved How do I get Container owner onMoveItem?

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,454
Solutions
1
Reaction score
627
Location
Estonia
Another problem, since this onMoveItem fromPosition and toPosition has only 1 useful parameter..

How do I get the container owner where the item was moved out?
If the container is not on player, then it should be nil.
Problem is, i cant even get the container UID in first place.

Problem is that positions only give:
x = container or tile
y = kind of a bag id (but it only registrates the currently opened bags)
z = cylinder id (or in some occasion shows if the moveitem is container i guess)
stackpos = useless...


EDIT:

Alright so for now gona try something like this:
Code:
    local bag = player:getSlotItem(3)
    local playerContainers = {}

    if bag then
        table.insert(playerContainers, bag)
   
        for x=0, bag:getSize()-1 do
            if bag:getItem(x) then
                if bag:getItem(x):isContainer() then
                    table.insert(playerContainers, bag:getItem(x))
                end
            else break
            end
        end
    end
and then i'm gona check if the moved item came from bag.
If it does, then gona check all the player bags and try to find the match, if no match found then it means that was not player container where the item was moved from.

In theory it works, not sure does it actually work too xD

BTW, eve though you might see a mistake in my container making, its not. because in my server you cant put bags into bag. (unless its special type of bag) and into special type of bags you cant put any bags.


EDIT2:


Now the problem is: How do I get the owner of container where I move the object? xD

EDIT3:
Ok i have an idea.
Sending out prove first (item) and then checking did that item reach to player xD
if not then in theory the container has no owner.

edit4:
Grr. can't createItem to container which location i don't know >.>
 
Last edited:
Ok so source edit will be made for Whi World.
Maybe its possible to include something more. Which said to be happen for TFS 1.2, but seems it will take some time before it comes around.
Its a very hard one, so I don't expect any solutions, but just maybe.

So here is current function event in LUA:
function Player:onMoveItem(item, count, fromPosition, toPosition)

After sourceCode edit LUA code should look like this:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromContainer, toContainer)

fromContainer and toContainer is userdata for chest or bag or player if the item was moved into or from any of these parent locations

example:
apple is moved from player bag to random chest.

fromContainer = the bag userdata (which again we can use check to who this bag belongs to, in this case to player)
toContainr = the chest userdata(we can check now chest location, but if chest is inside chest then it will be a problem, which leads to 1 more new LUA function)

container:getParent()
This should return the userdata of an item or player where this container is inside.

Are these things possible to in SourceCode?
 
Back
Top