Page 1 of 1

how to get backpack owner?

Posted: Wed Jun 02, 2010 4:06 pm
by Ispa
if i put an item inside a character backpack is there any way to link character just knowing the item reference? (i.e. something like GetOwner(item.container);)

Re: how to get backpack owner?

Posted: Wed Jun 02, 2010 10:00 pm
by CWO
I think I've always in that situation used item.container.container.

The container the item is in being the backpack and the container the backpack is in being the character.

Re: how to get backpack owner?

Posted: Thu Jun 03, 2010 1:45 am
by xeon
I've done a simple library function which recursively goes up till .container is Error.

Make sure to handle correctly the various situations anyway...item on the ground, item in backpack, item in a container on the floor.

Re: how to get backpack owner?

Posted: Thu Jun 03, 2010 3:59 pm
by Ispa
CWO wrote:I think I've always in that situation used item.container.container.

The container the item is in being the backpack and the container the backpack is in being the character.

i tried like this

var who := item.container.container;

but it doesn't work.


edit : ok now it works i made a loop while item exist each 5 sec it recalculates var who := item.container.container; so it work only when is contained in a backpack :) thank you alll