Jump to content

Help adding owner only to this script.


TrinityReclusive
 Share

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

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

Recommended Posts

I need a bit of help. How to add owner only to this script so only the only can activate it.

integer CountDownTime = 60;
float CountDownIncrements = 1;
integer StartTime;
integer Rounds;
 
// Script starts here ....
default
{
    touch_start(integer numbb)
    {
        llSay(0, (string)CountDownTime + " ...");
        llSetTimerEvent(CountDownIncrements);
        StartTime = llGetUnixTime();
    }
 
    timer()
    {
        if (llGetUnixTime() >= StartTime +CountDownTime)
        {
            llSay(0, "Bang");
            llSetTimerEvent(0);
        }
 
        else
        {
            Rounds++;
            llSay(0, (string)(CountDownTime -  Rounds) + " ...");
        }
    }
}


The script works fine but want it to only be run by the owner. I tried to add

{        if (llDetectedKey(0)==llGetOwner()){    


to it but then i get a syntax error on the timer.

 

 

 

Please help thanks a bit new to scripting but somewhat figured it out.

script error.png

Link to comment
Share on other sites

Mismatched braces (curly brackets). Remove the one in line 13, and put a closing brace after line 18.

You get the syntax error on the timer because that's where the compiler realises something's wrong: two lots of opening braces without their corresponding closing braces when it hits the timer event code.

  • Like 1
Link to comment
Share on other sites

Everything is fine.  You just have to watch that you are matching open { and closed }  brackets properly.  Use curly brackets to demarcate the start and end of a scope -- either the start and end of an event or state, or the code in a conditional step ( controlled by an if or while  condition, for example) .

  • Like 1
Link to comment
Share on other sites

3 hours ago, Kyrah Abattoir said:

If you are lazy like me you can also invert the check and drop early.


if( llDetectedKey(0) != llGetOwner() )
	return;

 

This is what I do, but it's not just about laziness!

I prefer having code that's not very "wide." Lots of nested scopes is messy to read, eg:

state
{
    event
    {
        if owner
        {
            if other condition
            {
                if other other condition
                {
                    // code;
                }
                // code;
            }
        }
    }
}

vs

state
{
    event
    {
        if not owner;

        if condition
        {
            // code;
        }

        if other condition
        {
            // code;
        }
    }
}

 

Edited by Wulfie Reanimator
Link to comment
Share on other sites

  • 3 years later...
You are about to reply to a thread that has been inactive for 397 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...