Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Removing invetory item after it is delivered ?

Ardra Allen
Registered User
Join date: 5 Jun 2008
Posts: 15
09-07-2008 23:34
how do I get the script to automatically delete a note card after it gives it to the owner?
I wanted to make my own drop box script and it works.. however after it gives me the inventory that someone else dropped into it...that inventory is still in the object... so how do I get it to remove the inventory once it gives it to me?
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
09-08-2008 00:28
After your script gives you the notecard call llRemoveInventory("notecard's name";);
Ardra Allen
Registered User
Join date: 5 Jun 2008
Posts: 15
The name of th enotecard will vary.
09-08-2008 00:41
The note card will be job applications that people drop into it. every one will have a different name because before anyone drops an application off they're supposed to put their own name in the title
I have a different object to give out the applications to people wanting a job... they take it.. fill it out.. rename it adding their name to the title.. and then drop it off in the box .. I click the box to get the note card.. that part all works...I just want the notecard in the box to go away after i check it.
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
09-08-2008 00:50
Yes...I realize that. What I am saying is your current script is obviously going through the object's inventory and giving you the notecards which requires it to know their names so all you need to do is have that script remove the notecard right after it's given to you.
Ardra Allen
Registered User
Join date: 5 Jun 2008
Posts: 15
it diddnt work.
09-08-2008 01:12
the give inventory part of the script was a freebie I got and I just modified it to notify me when a notecard is dropped.. and to have hover text... Im still new at scripting.. Never actually made my own before. this is my first.. and its more of a modded script than anything else... only a few lines were mine.


// Copyright 2004, Trimming Hedges. Released to the public domain.

// This is a simple script that gives everything in a box to the person who clicked.
// By default, it will only give items to the owner of the box.

// I wrote this because of all the texture bundles that are given out. It's really a PAIN
// to move a lot of textures or other contents out of a box. This speeds that up.

// This is NOT a vending script. You can use this script to give everything in a box to someone, by changing 'owneronly' to be 0. BUT:
//
// I suggest not using this script in an area where several people are going to touch it at once, because giving inventory is slow.
// Version 2.0 of this script now detects multiple simultaneous touches: it is still slow, but it should work better at classes or events.

// THIS IS NOT A VENDING SCRIPT. It gives items away, it does NOT SELL THEM. (You don't need a script for most vending anyway.)
// This script doesn't give itself away. If you want it to, put it in the box, and set it to not running.
// Then rename a copy and put that in the box too. The renamed copy should be the running one.
// Rename it FIRST, I had weird issues with renaming it when it was already in
// the box. (version 1.2.12 of SL.)

integer owneronly = 1;
key owner;

default
{
state_entry()
{
llAllowInventoryDrop(TRUE);
}
state_entry()
{
llSetText("ENTER TEXT HERE", <0.0,1.0,0.0>, 1);
}
changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llOwnerSay("Someone has left you a notecard.";);
}
}
state_entry()
{
owner = llGetOwner();
}

touch_start(integer total_number)
{
integer i;
for (i=0;i<total_number;i++)
{
key target = llDetectedKey(i);

if ( (target != owner) && (owneronly == 1) ) // person clicking isn't owner and owneronly is set;
{
llInstantMessage(target,"Sorry, only the owner is allowed to get my contents.";);
return;
}
list inventory_types = [INVENTORY_BODYPART,INVENTORY_CLOTHING,INVENTORY_LANDMARK,INVENTORY_NOTECARD,INVENTORY_OBJECT,INVENTORY_SCRIPT,INVENTORY_SOUND,INVENTORY_TEXTURE];
integer inventory_count = llGetListLength(inventory_types);
integer j;
integer k;
integer type;
integer typecount;
string myname = llGetScriptName();
string objectname;

for (j=0; j<inventory_count;j++)
{
type = llList2Integer(inventory_types,j); // get the next inventory type from the list
typecount = llGetInventoryNumber(type); // how many of that kind of inventory is in the box?
if (typecount > 0)
{
for (k=0; k<typecount;k++)
{
objectname = llGetInventoryName(type,k);
if (objectname != myname) // don't give self out so the user doesn't get fifty thousand copies.
{
llGiveInventory(target,objectname);
}
}
}
}
}
}
}


this script gives all its invetory to the owner when clicked so where in here do I use llremoveInvetory, and WHERE in there is the invetory name?
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
Try it like this:
09-08-2008 02:17
CODE

// Copyright 2004, Trimming Hedges. Released to the public domain.

// This is a simple script that gives everything in a box to the person who clicked.
// By default, it will only give items to the owner of the box.

// I wrote this because of all the texture bundles that are given out. It's really a PAIN
// to move a lot of textures or other contents out of a box. This speeds that up.

// This is NOT a vending script. You can use this script to give everything in a box to someone, by changing 'owneronly' to be 0. BUT:
//
// I suggest not using this script in an area where several people are going to touch it at once, because giving inventory is slow.
// Version 2.0 of this script now detects multiple simultaneous touches: it is still slow, but it should work better at classes or events.

// THIS IS NOT A VENDING SCRIPT. It gives items away, it does NOT SELL THEM. (You don't need a script for most vending anyway.)
// This script doesn't give itself away. If you want it to, put it in the box, and set it to not running.
// Then rename a copy and put that in the box too. The renamed copy should be the running one.
// Rename it FIRST, I had weird issues with renaming it when it was already in
// the box. (version 1.2.12 of SL.)

integer owneronly = 1;
key owner;

default
{
state_entry()
{
llAllowInventoryDrop(TRUE);
llSetText("ENTER NOTECARD HERE", <0.0,1.0,0.0>, 1);
owner = llGetOwner();
}
changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llOwnerSay("Someone has left you a notecard.");
}
}
touch_start(integer total_number)
{
integer i;
for (i=0;i<total_number;i++)
{
key target = llDetectedKey(i);

if ( (target != owner) && (owneronly == 1) ) // person clicking isn't owner and owneronly is set;
{
llInstantMessage(target,"Sorry, only the owner is allowed to get my contents.");
return;
}
integer notecard_count = llGetInventoryNumber(INVENTORY_NOTECARD);
integer j;
string notename;

for (j=0; j<notecard_count;j++)
{
notename = llGetInventoryName(INVENTORY_NOTECARD,j);
llGiveInventory(target,notename);
llRemoveInventory(notename);
}
}
}
on_rez(integer start_param)
{
llResetScript();
}
}



This only gives out the notecards in inventory.
Ardra Allen
Registered User
Join date: 5 Jun 2008
Posts: 15
thank you
09-08-2008 09:46
that actually makes sense. :P
Even with my beginner scripting knowledge I can roughly understand that.
thanks.

Darn.. syntax Error.

Fixed it :P
problem was this:

[/code]

This only gives out the notecards in inventory.
I just commented that out and it works now :P thank you
Ardra Allen
Registered User
Join date: 5 Jun 2008
Posts: 15
Hmm... I just thought of something...
09-08-2008 10:33
WE got other people who might need to be able to get the notecards.. how can I change it to give notecard only to members of the objects group?
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
09-08-2008 11:07
I knocked this up earlier but Ron beat me to the send Button.
The code is almost identical so I have added the group detect for you.

CODE

key owner;

default
{
state_entry()
{
llAllowInventoryDrop(TRUE);
owner = llGetOwner();
llSetText("ENTER TEXT HERE", <0.0,1.0,0.0>, 1);
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llInstantMessage(owner,"Inventory has changed.");
}
}

touch_start(integer total_number)
{
key target = llDetectedKey(0);

if (target == owner || llSameGroup(target))
{
integer k;
integer typecount;
string objectname;

typecount = llGetInventoryNumber(INVENTORY_NOTECARD); // how many of that kind of inventory is in the box?
if (typecount > 0)
{
for (k=0; k < typecount; k++)
{
objectname = llGetInventoryName(INVENTORY_NOTECARD,k);
llGiveInventory(target,objectname);
llRemoveInventory(objectname);
}
}
else llInstantMessage(owner,"No Notecards Found");
}
else llInstantMessage(target,"Sorry, only the owner or a Group member with an active tag is allowed to get my contents.");
}
}



notes. The
CODE
 and 
are not part of the script, they are supposedly for forum formatting.
The object must be deeded to the group.
The group member must have the group active, it is the only way to detect a group that I know of.
Ardra Allen
Registered User
Join date: 5 Jun 2008
Posts: 15
well that script works.. but....
09-08-2008 11:31
stil.. only the owner is able to get the NC... I had my alt who is in same group as I deeded the object to... and nothing happens.. no NC> not even a mesage sying not in right group.
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
09-08-2008 11:39
From: Ardra Allen
stil.. only the owner is able to get the NC... I had my alt who is in same group as I deeded the object to... and nothing happens.. no NC> not even a mesage sying not in right group.

Strange, I looked over the logic and it should work.
I will go in world just now and test it.
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
09-08-2008 12:06
The object needs to be set to group, not deeded. If you deed it the group becomes the owner and the owner check fails silently because there's a bug with llInstantMessage() failing when being used by a deeded object.
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
09-08-2008 12:09
I have updated my original script to reverse the logic, so that it is easier to read, and tested it in world. It works deeded to group but Talon has a valid point with regards IM.
Try it set to group, it will still work, and avoids the second issue in that you can no longer edit the object once deeded.