Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Creator Drops Stuff into Obj's Inventory

Ina Centaur
IC
Join date: 31 Oct 2006
Posts: 202
03-15-2007 03:25
Is there a way to limit so that only the creator can drop items into an object's inventory? (Where, the owner is different than the creator.)
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-15-2007 04:15
Yup. Check who created the inventory item then remove it if it's not the same as the creator. I don't think there's a getCreator function, so you'll need to hard code your key into the script.
Ged Larsen
thwarted by quaternions
Join date: 4 Dec 2006
Posts: 294
03-15-2007 04:23
From: AJ DaSilva
Yup. Check who created the inventory item then remove it if it's not the same as the creator. I don't think there's a getCreator function, so you'll need to hard code your key into the script.


There is: http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetCreator

But just be aware that anybody could bring your object onto no-script land, drop whatever they want into the object, remove your removal scripts, etc.

So, no really completely fool-proof way to do what you want, as far as I know.
_____________________
- LoopRez, flexi prim skirt generating tool
- LinkRez, a necklace chain generator
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-15-2007 04:26
Haha. Should have searched rather than just checked the pages I'd expect it to be. Might add it to the relavant page later (assuming I didn't just miss it because I'm half asleep). :)
EDIT: Heh, it's on the llGetInventoryCreator page... doh.

From: someone
But just be aware that anybody could bring your object onto no-script land, drop whatever they want into the object, remove your removal scripts, etc.
Does that still work? I thought they changed it so you couldn't remove things from a no-mod object?
Ina Centaur
IC
Join date: 31 Oct 2006
Posts: 202
03-15-2007 05:08
ok, so tell me if i have you guys right and please answer subsequent question:

start: llAllowInventoryDrop(TRUE); // this lets everyone drop items, so need to limit with if clause below

change: if( llGetInventoryCreator() == me) then allow drop
^ how do you detect when the inventory changes?
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-15-2007 05:15
That's right. When the inventory changes it'll fire the changed event with the CHANGED_INVENTORY flag set.

i.e.
CODE
changed( integer change )
{
if( change & CHANGED_INVENTORY )
{
//check and delete
}
}
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-15-2007 05:23
Oh yeah, don't forget you'll need to put the name of the inventory item you want to check into llGetInventoryCreator. llGetInventoryName should be useful.

Also, don't forget that the changed event is called for lots of inventory changes, not just when things are dropped (see page) so you'll need to take that into account.

All the functions dealing with inventory are listed here for reference.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-15-2007 06:16
I may be missing something here, so I apologise before hand, but if you only want you or at least the owner to be able to drop stuff then leaving llAllowInventoryDrop(FALSE) (the default) should already suffice?
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-15-2007 12:58
From: Newgate Ludd
I may be missing something here, so I apologise before hand, but if you only want you or at least the owner to be able to drop stuff then leaving llAllowInventoryDrop(FALSE) (the default) should already suffice?

You're missing the bit where the OP said "creator". ;)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-15-2007 14:27
From: AJ DaSilva
You're missing the bit where the OP said "creator". ;)



he He yep your right I'd apologise but I already did!
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
03-15-2007 14:48
I've actually got some very similar code in a product I made...

CODE

if(change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY))
{
integer cnt = llGetInventoryNumber(INVENTORY_ALL);
integer x;
for(x = 0; x < cnt; x++)
{
string sinv = llGetInventoryName(INVENTORY_ALL, x);
if(sinv != SCRIPT)
{
key kcreator = llGetInventoryCreator(sinv);
if(kcreator != <YOUR KEY HERE>) invalid(sinv);
else
{
//do your stuff
}
}
}
}


I've removed a lot of pieces of the actual production script...but left the parts that were helpful to the question..
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-15-2007 18:04
Couldn't resist:
CODE
if( change & CHANGED_INVENTORY )
{
integer cnt = llGetInventoryNumber( INVENTORY_ALL );
integer x = 0;

while( x < cnt )
{
sinv = llGetInventoryName( INVENTORY_ALL, x );

if( llGetInventoryCreator() != <YOUR KEY HERE> )
{
llRemoveInventory( sinv );
cnt--;
}
else
x++;
}
}

Can't remember if items' numbers correspond to when they're added but, if they do, you could speed it up a bit by making x's starting value one less than the number of items in the object's inventory. You could change INVENTORY_ALL to the type of item(s) you're particularly worried about too if there are specifics ones.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-16-2007 00:35
From: AJ DaSilva
Can't remember if items' numbers correspond to when they're added but, if they do, you could speed it up a bit by making x's starting value one less than the number of items in the object's inventory. You could change INVENTORY_ALL to the type of item(s) you're particularly worried about too if there are specifics ones.



Items are sorted into alpha order.
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
03-16-2007 04:00
That's just damned weird.

EDIT: Oh, wait, you probably mean alpha as in alphanumeric, not as in opacity...
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-17-2007 03:59
From: AJ DaSilva
That's just damned weird.

EDIT: Oh, wait, you probably mean alpha as in alphanumeric, not as in opacity...



ROFLMAO, I did but with the way LL are messing things around anything is possible