Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Give Inventory to certain number of Avs only

Dnali Anabuki
Still Crazy
Join date: 17 Oct 2006
Posts: 1,633
10-28-2007 14:57
Hi everyone, I've been to the Script Library and 30 pages of forum and must have missed how to do this.

Sometimes I need to limit how many students get supplies. Can someone tell me where to start modifying this script so that I can limit how many unique Avatars get the supplies? I have been trying to modify the Touch integer assuming I could put in a set number but of course its not that easy!

I also would like to add a price for some occasions. If someone could point me to where this would be added using what function, I would be ridiculously grateful.



string SUPPLY_FOLDER_NAME = "";

default
{
state_entry()
{
llSetTouchText("Get supplies";);
llSetText("", < 1.0, 1.0, 0.0>, 1.0);
}

touch_start(integer total_number)
{
llInstantMessage(llGetOwner(), llKey2Name(llDetectedOwner(0)) + " ordered supplies!";);
integer cnt = llGetInventoryNumber(INVENTORY_ALL);
list supply =[];
integer i = 0;
for(; i < cnt; ++i)
{
supply += [llGetInventoryName(INVENTORY_ALL, i)];
}

llGiveInventoryList(llDetectedOwner(0), SUPPLY_FOLDER_NAME, supply);
}
}

Thanks!
Abba Thiebaud
PerPetUal NoOb
Join date: 20 Aug 2006
Posts: 563
10-28-2007 18:30
From: Dnali Anabuki
Hi everyone, I've been to the Script Library and 30 pages of forum and must have missed how to do this.

Sometimes I need to limit how many students get supplies. Can someone tell me where to start modifying this script so that I can limit how many unique Avatars get the supplies? I have been trying to modify the Touch integer assuming I could put in a set number but of course its not that easy!

I also would like to add a price for some occasions. If someone could point me to where this would be added using what function, I would be ridiculously grateful.



I'm a scripting noob myself, don't even know if it's possible, but put the items in labeled as "class supplies 1", "class supplies 2" etc (hint: if you start with just "class supplies" and keep adding, the contents will automagically add the number at the end, then delete the one without a number). Then have an llRemoveInventory?

I know I've used llRemoveInventory to delete a script, but not sure if it can do a +1 count to delete them one by one as it's touched and items are delivered.

Just a thought, ignore me if I'm way off base.

A
_____________________
http://www.ponystars.com/abbathiebaud Pony Up.
Dnali Anabuki
Still Crazy
Join date: 17 Oct 2006
Posts: 1,633
10-28-2007 19:03
Thanks Abba, that's an approach I didn't think of..limiting how many supplies are in the inventory. Interesting.

I was thinking that it would be a touch event of some kind that would be limited..after so many touches, turn off...

or only give inventory this many times.

I appreciate your help...I will continue to fiddle and see what I come up with.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-29-2007 04:38
you could include a counter, check if it's over X value, if it isn't, give a copy & increment the counter each time, if it is give a nice little "sorry all out" msg ...

you could even have it llDie to remove the supply box on the last take

the only issue here is if people click accidentally and decline the inventory, it still counts so it's not perfect

however using Abba's idea, if the supplies are no-copy you don't even have to delete them in the above example... but the items must be no-copy...

if the must be copiable, use a dialog on touch to prevent accidental declined inventory deletion

EDIT: the below idea doesn't work
it might be possible to use coalesence to take copiable items as a single object, then set no copy on the resulting object, while retaining the originals copiable status... haven't tested that
nvm, doesn't work, coalesced permissions update all object permissions
_____________________
|
| . "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...
| -
Abba Thiebaud
PerPetUal NoOb
Join date: 20 Aug 2006
Posts: 563
10-29-2007 09:37
Actually, if you have it advancing the item's name by a value of +1 (again, don't know if that's possible) you don't have to worry about it being no copy or not. There's one copy of class_supplies 1 and then the script looks for class_supplies 2, not for 1. They can be full perms, for all this is concerned. It's the object name (or inventory name, to be specific) that matters. Once it reaches the end though, I'm not sure how you'd close it out without an error. I'm not that advanced. Sorry.

A
_____________________
http://www.ponystars.com/abbathiebaud Pony Up.
Dnali Anabuki
Still Crazy
Join date: 17 Oct 2006
Posts: 1,633
10-29-2007 09:49
I really liked the version I saw that someone had and it is things like this that make me appreciate what good scriptors can do. I was thinking along of the lines of setting up an if/then statement. I'm not a scriptor so I'm thinking just logically.

If a unique avatar touches the prim
and if it is less than 15 avatars
then give inventory.

So I have to have something that gets the Av key, stores it and compares it to who touches the prim and then have something that tracks how many unique avatars..

Dnali goes to look at the insert functions to see if anything gathers a Av key and then stores it as well as trying to understand if and then statements. I am so not a scriptor but I love learning.

Still really hoping for any ideas or do any of the good scriptors want to give me some paid lessons?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-29-2007 11:28
From: Dnali Anabuki
I really liked the version I saw that someone had and it is things like this that make me appreciate what good scriptors can do. I was thinking along of the lines of setting up an if/then statement. I'm not a scriptor so I'm thinking just logically.

If a unique avatar touches the prim
and if it is less than 15 avatars
then give inventory.

So I have to have something that gets the Av key, stores it and compares it to who touches the prim and then have something that tracks how many unique avatars..

Dnali goes to look at the insert functions to see if anything gathers a Av key and then stores it as well as trying to understand if and then statements. I am so not a scriptor but I love learning.

Still really hoping for any ideas or do any of the good scriptors want to give me some paid lessons?

in the globals:
list vLstKeys;

in the touch event:
if (llGetListLength( vLstKeys ) < 15){
key vKeyTest = llDetectedKey( 0 );
vLstKeys = (vLstKeys=[]) + vLstKeys + (list)vKeyTest ;
llGiveInventory( vKeyTest, "stuff" );
}


it really should still have a dialog confirmation to prevent declined inventory, and it should check to see if the person already grabbed them to prevent duplicate grabs
_____________________
|
| . "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...
| -
Dnali Anabuki
Still Crazy
Join date: 17 Oct 2006
Posts: 1,633
10-29-2007 21:13
Thanks to everyone, a kind scriptor has come to rescue me and I'm actually understanding some of it. It amazes me what scripts can do in SL.