Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

One time giver

Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
10-07-2007 16:43
I want a giver/vender type thingee - that will give out a box of free sample items once only to each avatar that touches it. This would be used at an event - so it would be rezzed for a few hours then packed away. Each time it was rezzed the list of avatars who had touched it previously would be wiped clean. - hope that makes sense.

Is there a script that would do this? Or can I get some tips on how it may be achieved please?
Siann Beck
Beauty & Braiiiiinsss!
Join date: 14 Jul 2007
Posts: 140
10-07-2007 17:28
Well, it sounds pretty straightforward. Just keep a list of everyone who touches it; if someone touches it who's not in the list, give the item. Put llResetScript() in an on_rez event, and it's wiped clean each time you rez it.

list lstGiven;

default
{
touch_start(integer intDetected) {
key keyTouched = llDetectedKey(0);

if (llListFindList(lstGiven, [keyTouched]) == -1) {
llGiveInventory(keyTouched, "Item";);
lstGiven = (lstGiven=[]) + lstGiven + [keyTouched];
}

else {
llInstantMessage(keyTouched, "Sorry, you've already got one.";);
}
}

on_rez (integer intStartParam) {
llResetScript();
}
}
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
10-07-2007 17:45
the problem with using a list in-world is that it will eventually fill up, theres only 16kb minus the space the script actually uses

the solution above is something good to start out with, but if this is something that will be running, saving names for weeks/months on end with out a reset you may want to consider using outside servers
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-07-2007 18:48
From your description, this should be more then sufficient. It will keep a list up to 200 keys long. At the 200th entry it will delete the 1st 100 names and keep adding on to the end.. So basically, if you are at an event and over 100 people get items and then some of the 1st hundred touch it again, then they will get an extra item. I can't imagine that being a problem.


CODE

list lstGiven;

default
{
touch_start(integer intDetected) {
key keyTouched = llDetectedKey(0);
if (llListFindList(lstGiven, [keyTouched]) == -1) {
llGiveInventory(keyTouched, "Item");
integer list_length = llGetListLength(lstGiven);
if(list_length >= 200){
lstGiven = llDeleteSubList(lstGiven,0 , 100);
lstGiven = (lstGiven=[]) + lstGiven + [keyTouched];
}
lstGiven = (lstGiven=[]) + lstGiven + [keyTouched];
}

else {
llInstantMessage(keyTouched, "Sorry, you've already got one.");
}
}

on_rez (integer intStartParam) {
llResetScript();
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-08-2007 00:00
slightly more elegant way to limit the list
CODE

list Last50; //-- add to globals sectiom

//-- add to touch_start
touch_start( integer vIntDetected ){
key AvKey = llDetectedKey( 0 );
if ( llListFindList( Last50, AvKey ) > -1 ){
//--give stuff
last50 = [AvKey] + llList2List( Last50, 0, 48 );
}
}
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
10-08-2007 07:39
Thanks people - that was great feedback!
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-08-2007 08:49
From: Void Singer
slightly more elegant way to limit the list

Believe me, no one has ever accused me of being elegant! :cool:
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-08-2007 10:53
From: Jesse Barnett
Believe me, no one has ever accused me of being elegant! :cool:

::looks at user title under your name::
who needs elegant when you're that hot? ;)
Titania Bracken
Registered User
Join date: 25 Apr 2007
Posts: 152
10-09-2007 06:27
From: Jesse Barnett
From your description, this should be more then sufficient. It will keep a list up to 200 keys long. At the 200th entry it will delete the 1st 100 names and keep adding on to the end.. So basically, if you are at an event and over 100 people get items and then some of the 1st hundred touch it again, then they will get an extra item. I can't imagine that being a problem.


CODE

list lstGiven;

default
{
touch_start(integer intDetected) {
key keyTouched = llDetectedKey(0);
if (llListFindList(lstGiven, [keyTouched]) == -1) {
llGiveInventory(keyTouched, "Item");
integer list_length = llGetListLength(lstGiven);
if(list_length >= 200){
lstGiven = llDeleteSubList(lstGiven,0 , 100);
lstGiven = (lstGiven=[]) + lstGiven + [keyTouched];
}
lstGiven = (lstGiven=[]) + lstGiven + [keyTouched];
}

else {
llInstantMessage(keyTouched, "Sorry, you've already got one.");
}
}

on_rez (integer intStartParam) {
llResetScript();
}
}



Ive been looking for a similar thing. Now I don't understand scripts, so does this have to work WITH another script. like give contents? Or just put this in the item? I need a script for a treasure hunt, putting items in the chest, give someone the contents when touched and not let them have another go on the same box? Sorry if I sound stupid. I want to put lots of boxes around the land with different things in and for the treasure hunt and let people have the contents ONCE.

Titania xx
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
10-09-2007 06:32
From: Titania Bracken
Ive been looking for a similar thing. Now I don't understand scripts, so does this have to work WITH another script. like give contents? Or just put this in the item? I need a script for a treasure hunt, putting items in the chest, give someone the contents when touched and not let them have another go on the same box? Sorry if I sound stupid. I want to put lots of boxes around the land with different things in and for the treasure hunt and let people have the contents ONCE.

Titania xx


No, this script gives the contents itself. You will need to change the "Item" part where it says

llGiveInventory(keyTouched, "Item";);

to be the name of whatever you're giving to people.
_____________________
Titania Bracken
Registered User
Join date: 25 Apr 2007
Posts: 152
10-09-2007 06:34
AHA! Thank you very much. I'll never get the hang of scripts lol

Titania xx
Titania Bracken
Registered User
Join date: 25 Apr 2007
Posts: 152
10-09-2007 06:54
All I need now is a script that tells me who got what lol That way I can see if someone got ALL the hidden items and wins an extra prize.

Thank god I don't do this for a living lol

Titania xx
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
10-09-2007 07:20
Oh, am I right in thinking you only want the contents of each box to be won by one person? The script as it stands will give it to everybody who clicks it, but only once each per person.
_____________________
Trevor Langdon
Second Life Resident
Join date: 20 Oct 2004
Posts: 149
10-09-2007 10:15
Stephen--
The way I understand what Titania is asking is what Jesse's script will do, plus needing a way to have a list of what each player has received.

Titania--
The easiest way to keep track for each contest player would be to have each box send you an IM message with the pertinent info of what was given and to whom. Then you could manually check to see who got all of the items for an extra prize.

Otherwise, a multi-treasure box system could be used that relies on a master receiver to receive messages from all of the satellite treasure boxes when ever someone receives one of the treasure items. The master object code incorporate code that would keep track of items per contestant and either send the extra prize when appropriate or send you an IM so you could manual send the extra prize. More coding involved, but would not require manual review on your part.
Cordax Martinek
Registered User
Join date: 7 May 2007
Posts: 14
11-26-2007 18:51
From: Jesse Barnett
From your description, this should be more then sufficient. It will keep a list up to 200 keys long. At the 200th entry it will delete the 1st 100 names and keep adding on to the end.. So basically, if you are at an event and over 100 people get items and then some of the 1st hundred touch it again, then they will get an extra item. I can't imagine that being a problem.


CODE

list lstGiven;

default
{
touch_start(integer intDetected) {
key keyTouched = llDetectedKey(0);
if (llListFindList(lstGiven, [keyTouched]) == -1) {
llGiveInventory(keyTouched, "Item");
integer list_length = llGetListLength(lstGiven);
if(list_length >= 200){
lstGiven = llDeleteSubList(lstGiven,0 , 100);
lstGiven = (lstGiven=[]) + lstGiven + [keyTouched];
}
lstGiven = (lstGiven=[]) + lstGiven + [keyTouched];
}

else {
llInstantMessage(keyTouched, "Sorry, you've already got one.");
}
}

on_rez (integer intStartParam) {
llResetScript();
}
}





How would I add a counter to this so after so many items have been given say 50 it will stop working or delete itself ? ty
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-26-2007 21:09
From: Cordax Martinek
How would I add a counter to this so after so many items have been given say 50 it will stop working or delete itself ? ty


CODE

list vlstGiven;
integer vIntGiveLimit = 50;
integer vIntTrackLimit = 50; //-- never needs to be higher than give limit

default{
touch_start( integer vIntTouched ){
do{
--vIntTouched;
key vKeyToucher = llDetectedKey( vIntTouched );
if (~llListFindList( vlstGiven, (list)vKeyToucher )){
llInstantMessage( vKeyToucher, "Sorry, you've already got one.");
}else{
vlstGiven = (list)vKeyToucher + llList2List( vlstGiven, 0, vIntGiveLimit - 2);
llGiveInventory( vKeyToucher, "Item");
}
if (llGetListLength( vlstGiven ) == vIntGiveLimit){
llRemoveInventory( llGetScriptName() ); //-- removes this script from inventory
}
}while (vIntTouched);
}

on_rez( integer vIntStartParam ){
llResetScript();
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Cordax Martinek
Registered User
Join date: 7 May 2007
Posts: 14
Ty
11-27-2007 02:54
Thank You Everyone...ty very much.....works great......
Heron Halberstadt
Registered User
Join date: 7 Feb 2008
Posts: 4
searching for similar script
02-11-2008 23:10
I'm rather new and dunno much about scripts.
I want to limit the copies of items for RP.
(lets say a package of 10 fireworks rockets, bottles that are empty after 5-10 uses),
but also keeping inventory clean by limiting itemcopies that go back into inventory by auto clean sim or picking up in build mode.

So its got to be more or less perfect, and it should add "empty" to name tag of container and delete itself when left items=0 is reached, also deny a reset.

Not only for RP, but also:
- limit income by reselling items or by drag script into other items
or any other usage of a free script for profit.
- limit usage of free examples.
- preventing kick similar profit scripts from market by use of this non-profit type,
so also limited usage as helper for or inside other scripts/builds.

-------------edit----------
a second idea I have is a "fair-play-script"
there are already profit-splitters on market, even free ones.
But I haven't seen yet the one I need:
example:
5% to owner of the place,
10% to shopholder (if not same as land owner),
1 L$ each for the free script libs (or any organisation I can define, should be as easy as possible even for beginners),
10% /20 L$ for my group (also choise of define which, I'm member of more than one)

to make it short:
easy select/unselect of some predefined and up to 6 selfdefined persons/groups,
with selection of type (relative/absolute) profit they get and how much.

-------------edit----------

another script I need is that prevents giving out "rulers", so no scripts or textures are given out that define the appearance of the vendor/box the given/sold items are in.

I guess easiest way would be to define which kind of object is given away, but:
- could cause errors when these objects also include scripts and textures and filter filters them also.
- I don't want to have totally different containers when the items I sell/distribute are scripts
or textures.

----------
if such scripts are already on market, meet my requirements and I have enough money (no income yet) I will see if I can get them instead of begging for free help ;-)
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-12-2008 01:59
From: Heron Halberstadt
I'm rather new and dunno much about scripts.
I want to limit the copies of items for RP.
(lets say a package of 10 fireworks rockets, bottles that are empty after 5-10 uses),
but also keeping inventory clean by limiting itemcopies that go back into inventory by auto clean sim or picking up in build mode.

So its got to be more or less perfect, and it should add "empty" to name tag of container and delete itself when left items=0 is reached, also deny a reset.

Not only for RP, but also:
- limit income by reselling items or by drag script into other items
or any other usage of a free script for profit.
- limit usage of free examples.
- preventing kick similar profit scripts from market by use of this non-profit type,
so also limited usage as helper for or inside other scripts/builds.

From what I understand here, you simply want no-modify, no-copy objects. Unfortunately, I don't believe programmatic changes to the object name propogate back to inventory for some reason, at least for attachments. Script state does though. Of course, it's been a long time since I tried the name change because of the fact that it never worked when I did. LOL. Maybe it's been fixed by now.
Heron Halberstadt
Registered User
Join date: 7 Feb 2008
Posts: 4
02-13-2008 12:59
not only no mod no copy.
I need a limitation of how many objects are given out (RP) and how many uses (scripts)

I guess I already defined what I need. In RL you don't have a package with millions of objects inside, why here?