Jump to content

Gift Giver Script w/Password - Needs to Allow "No Copy" Items


TheGreatWolfFenrir
 Share

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

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

Recommended Posts

Hello,

I am new to scripting and bought this full-perm script recently, which I have lightly modified.  However, there is one problem that I can't seem to get around.  I need this script to be able to give "no copy" items, as the box I am creating is specifically designed for the purpose of delivering an engagement ring that is non-copyable.  Can anyone tell me how I might alter the following code to allow for this, please?

    touch_start(integer total_number)
    {
        if ( llDetectedKey( 0 ) == llGetOwner() )
        {
            llOwnerSay( "Please type the correct phrase in the following format to unlock my contents: /20 PHRASE!" );
        } else {
            llWhisper( 0, "You must type the right password on channel " +
                          (string)channel + " in order to get the package box." );
        }
    }
    
    listen( integer _c, string _n, key _i, string _m )
    {
        if ( _c == channel )
        {
            if ( _m == password )
            {
                list content;
                integer i;
                for ( ; i<llGetInventoryNumber(type); ++i )
                {
                    if ( llGetInventoryName( type, i ) != llGetScriptName() )
                        content += llGetInventoryName( type, i );
                }
                
                llGiveInventoryList(_i, name, content);
            }
        }
        
        if ( _c == pchannel )
        {
            password = _m;
            llOwnerSay( "The new password is: " + password );
        }
    }
}

Edited by TheGreatWolfFenrir
Erased part of the code to respectfully preserve the resale-ability for the creator
Link to comment
Share on other sites

As per the caveats on llGiveInventoryList's wiki page, that function does not work with no-copy items. However, llGiveInventory will. The difference between them (among other things) is that this function works with a single inventory item as opposed to a list of them. So you could move the give function inside the loop that constructs the list and just piecemeal give out each item right there.

Also, I would probably not post the script you purchased in full, as that kinda undercuts the creator's ability to sell future copies. Make sure they don't have some terms/conditions prohibiting you from reposting the script elsewhere.

Edited by Fenix Eldritch
  • Like 2
Link to comment
Share on other sites

Alright, I adjusted the script, but I think I'm missing something because now the box doesn't even attempt to deliver the item.

 

    touch_start(integer total_number)
    {
        if ( llDetectedKey( 0 ) == llGetOwner() )
        {
            llOwnerSay( "Please type the correct phrase in the following format to unlock my contents: /20 PHRASE!" );
        } else {
            llWhisper( 0, "You must type the right password on channel " +
                          (string)channel + " in order to get the package box." );
        }
    }
    
    listen( integer _c, string _n, key _i, string _m )
    {
        if ( _c == channel )
        {
            if ( _m == password )
    {
           llGiveInventory(llDetectedKey(0),"ITEM NAME");
}
 

Link to comment
Share on other sites

37 minutes ago, Gabriele Graves said:

I don't see anywhere that you are hooking up the listener.  It will not listen unless you do.

They've intentionally omitted the full script, since they purchased it with full-perms from someone else. But it was there in the original version of the OP.

@TheGreatWolfFenrir the "detected" category of functions only work in a subset of events: collision, collision_start, collision_end, sensor, touch, touch_start, touch_end. It won't work in a listen event. Instead, you can use the "_i" variable from the listen event handler which contains the key of the entity who spoke the triggering message.

 

Edited by Fenix Eldritch
  • Like 1
Link to comment
Share on other sites

4 minutes ago, Fenix Eldritch said:

They've intentionally omitted the full script, since they purchased it with full-perms from someone else. But it was there in the original version of the OP.

Thanks.  I think it was a fair question to ask though as there was no hint from my reading that they had omitted the listener hookup.  I expected that to be in the touch_start() and I didn't look any further until establishing that.

Edited by Gabriele Graves
Link to comment
Share on other sites

13 hours ago, Gabriele Graves said:

Thanks.  I think it was a fair question to ask though as there was no hint from my reading that they had omitted the listener hookup.  I expected that to be in the touch_start() and I didn't look any further until establishing that.

Thank you for your input anyway!

13 hours ago, Fenix Eldritch said:

They've intentionally omitted the full script, since they purchased it with full-perms from someone else. But it was there in the original version of the OP.

@TheGreatWolfFenrir the "detected" category of functions only work in a subset of events: collision, collision_start, collision_end, sensor, touch, touch_start, touch_end. It won't work in a listen event. Instead, you can use the "_i" variable from the listen event handler which contains the key of the entity who spoke the triggering message.

So it should read this way instead, if I understood correctly?

touch_start(integer total_number)
    {
        if ( _i == llGetOwner() )
        {
            llOwnerSay( "Please type the correct phrase in the following format to unlock my contents: /20 PHRASE!" );
        } else {
            llWhisper( 0, "You must type the right password on channel " +
                          (string)channel + " in order to get the package box." );
        }
    }
    
    listen( integer _c, string _n, key _i, string _m )
    {
        if ( _c == channel )
        {
            if ( _m == password )
    {
           llGiveInventory(_i,"ITEM NAME");
}

Edited by TheGreatWolfFenrir
  • Thanks 1
Link to comment
Share on other sites

Not quite, but almost.

Your listen event looks good. Just make sure you have the necessary closing brackets "}" to properly terminate the listen event. Every opening bracket "{" must have a closing counterpart. And as currently written, you'd need one more to close out the listen event (at least from what I'm seeing from your post). Consistent indentation can really help visualize that.

However your touch_start event now has a problem. It can't use the _i variable because that was only defined for the listen event. No other event knows about it and therefore cannot reference it. The thing is, you can use llDetectedKey(0) in a touch_start event, as I mentioned in my previous post. So your original code for that part was fine all along.

Whether you're writing scripts yourself or modifying existing ones, it really does help to have a basic knowledge on how these things work. I would highly recommend reading through the LSL wiki's tutorials to get an nice introduction on the basics. These two are pretty good:

 

Edited by Fenix Eldritch
typos
Link to comment
Share on other sites

6 hours ago, Fenix Eldritch said:

Not quite, but almost.

Your listen event looks good. Just make sure you have the necessary closing brackets "}" to properly terminate the listen event. Every opening bracket "{" must have a closing counterpart. And as currently written, you'd need one more to close out the listen event (at least from what I'm seeing from your post). Consistent indentation can really help visualize that.

However your touch_start event now has a problem. It can't use the _i variable because that was only defined for the listen event. No other event knows about it and therefore cannot reference it. The thing is, you can use llDetectedKey(0) in a touch_start event, as I mentioned in my previous post. So your original code for that part was fine all along.

Whether you're writing scripts yourself or modifying existing ones, it really does help to have a basic knowledge on how these things work. I would highly recommend reading through the LSL wiki's tutorials to get an nice introduction on the basics. These two are pretty good:

 

It worked like a charm!  And I will take your advice and do some more research.  Thank you for your time and patience.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 285 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...