Jump to content

Give one no-copy object on touch to avatar on list


Kyomi Kohime
 Share

You are about to reply to a thread that has been inactive for 1329 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Okay, here goes.

So, I have a lovely couple of scripts that I have found in these forums (neither is mine, I am not selling the script in anything, it is for personal use).  One is a avatar list to specify who can receive something, and the other is a script for giving a single no copy item from the object until they are gone.  I have smashed them together, and reached the end of my scripting knowledge (which is sadly very limited).

Any help with the below would be wonderful. (and forgive my ingnorance)

list Names = ["Mulligan Silversmith","Mulligan Linden","Mulligan Pimp"]; // The names of people you want give items too
/*
For the name you need type it how it is on their profile with Caps and lower Cases
*/
default
{
    touch_start(integer total_number)
    {
        integer who; // Who is touching me!
        integer Index;
        Index = llListFindList(Names, [llDetectedName(who)]);
            if (Index > -1)
                {            llGiveInventory(who, item); // Give it.
        }        else // ...otherwise, complain.
                {            llRegionSayTo(who, 0, "Sorry, the box is empty.");        }    }}

Link to comment
Share on other sites

change who from integer to key and set it by llDetectedKey().

 

I also think you need a state_entry

 


default
{
    state_entry()
    {

    }
....
// then inside the touch event 

    key who = llDetectedKey(total_number - 1);
    integer index = llListFindList(names, [llKey2Name(who)]);

}

notice that you can declare the variables and assign to them at the same time.

notice also that there are square brackets around the function converting the key of the toucher to their name, because both arguments must be lists.

 

The subsequent calls to llGiveInventory and llRegionSayTo both need to know the key of the avatar they are going to deal with.

Link to comment
Share on other sites

as these are no-copy items, we may want to ensure that a person only receives one item, otherwise a person on the list could empty the vendor and the others get nothing

in this case then a way is to remove the person from the list after giving the item

adding on to what Prof has written. We have the agent list index. So after give then:  names = llDeleteSubList(names, index, index);

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1329 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...