Jump to content

How can i add listen to owner only to this script?


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

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

Recommended Posts

This script is control by a hud i have made.

All works well but.. I want to make sure that the item controlled by the hud only listens to the owner of the item.

Example a (Box on the ground) listens to the hud. The hud makes the script in the box activate in this case reset.

How to make the box only listen and react to the person who own it. Even if the other person has a similar item and a hud.

In case two people own the same item and have the same hud.  Does this make sense?

everything works perfect but want to make sure this problem wont happen.

This is the script in the item box on the ground.

 

integer rocking = TRUE;
default
{
    state_entry()
    {
        llListen( -200, "", NULL_KEY, "All" ); // Listens on Channel 2 for command 'reset'.
                                             // Owner controlled only!
                                              // Change the channel to channels 2-254 only!
                                              // and "reset" to anything.
        llRegionSay(-200, "Active!");
    }

    listen(integer channel, string name, key id, string m)
    {
        if(m == "reset")
            
    llRegionSay(-200, "Initializing...");
    llResetOtherScript("Script Name");       // Make sure you rename this to the
                                            // script you want to reset!
    llRegionSay(-200, "Done!");
    
        }

    }// END //

 

I have try to put in  (llGetOwnerKey(Id) == llGetOwner() but it breaks the script unless i am not puting it in the right place or wrong some how.

Any ideas?

 

 

Link to post
Share on other sites

You ought to be able to put that line in the listen event as the qualifying test:

    listen(integer channel, string name, key id, string m)
    {
        if (llGetOwnerKey(id) == llGetOwner() )
        {
            if(m == "reset")  
            llRegionSay(-200, "Initializing...");
            llResetOtherScript("Script Name");       // Make sure you rename this to the
                                            // script you want to reset!
            llRegionSay(-200, "Done!");
        }
    }

Again, as an aside,  be careful about formatting for easier readability.  Especially if you are as likely to make typos ( as I am! ), it is important to make your scripts as clean and readable as possible.

BTW, you wrote

19 minutes ago, TrinityReclusive said:

llListen( -200, "", NULL_KEY, "All" ); // Listens on Channel 2 for command 'reset'.
                                             // Owner controlled only!
                                              // Change the channel to channels 2-254 only!
                                              // and "reset" to anything.

But in fact that statement will open channel -200, not channel 2 and it will only hear the word "All" in chat, not the word "reset".  The "owner only" business is best handled in the listen event.

  • Like 1
Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 479 days.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...