Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Touch and Give Item in Inventory

Dioxide DeSantis
Registered User
Join date: 2 Feb 2007
Posts: 63
07-17-2007 20:36
I am looking for a script that I can use that will allow a random person to touch a box and then be given the notecard inside. I know I can do this with a simple give scripts but I want the item inside to be deleted from the inventory so only one person can get it.

Basically what I want to do is have a treasure hunt in my city and when someone clicks on the item I would like it to either give them a note card that tells them they won and have it deleted or have the item pay them an x amount of L$ and then not payout again unless refilled.

I tried to search the forums and didn't find anything that might fit the bill. Can anyone help me out and point me in the right direction?

Thanks
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
07-18-2007 00:29
take a normal give notecard script, but after the "give" part you can add llRemoveInventory

http://lslwiki.net/lslwiki/wakka.php?wakka=llRemoveInventory
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
07-18-2007 03:30
You would probably want to make the script fail gracefully in the event that the notecard has been deleted, rather than trying to give a non-existant item.
_____________________
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
07-18-2007 06:04
Set the notecard's permissions to no copy and then when the script gives it to someone, it will give the original and not a copy (meaning none are left inside the giving object).

But yes, have your scripts check to make sure the notecard exists before it try to give it away. Or have it turn itself off or llDie and kill the object itself.
Dioxide DeSantis
Registered User
Join date: 2 Feb 2007
Posts: 63
07-18-2007 12:43
Ok so here is the script that I came up with that I believe will do the job.
Basically it gives the notecard grom inventory then deletes the notecard from the inventory then removes the script so it cant be touched again.

CODE

default
{
touch_start(integer total_num)
{
llGiveInventory( llDetectedKey(0), "notecard" ); // Give the item from the contents of the prim
llRemoveInventory("notecard"); // delete the item named Object from the contents of the prim
llRemoveInventory(llGetScriptName()); // delete this script
}
}



Now I have not compiled it or anything just yet but does this look about right?
Damet Neumann
Registered User
Join date: 21 Apr 2006
Posts: 140
shoudl work
07-18-2007 16:16
but like was said if you just use llDie instead of the inventory remove 's it will do the ame thing i think plus remove the prim so you wont have to go back looking for it later
Dioxide DeSantis
Registered User
Join date: 2 Feb 2007
Posts: 63
07-18-2007 17:20
Ok so here is the script I have right now but for some reason I can't touch it and get the inventory so I must be missing something.

CODE

default
{
state_entry()
{
}

touch_start(integer total_number)
{
llGiveInventory( llDetectedKey(0), "Prize" ); // Give the item from the contents of the prim
llWhisper(0,"Congratulations You Won "+llDetectedName(0)+".");
llDie();
}
}