Jump to content

Limiting users


ChaosRaine
 Share

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

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

Recommended Posts

If you know how to make something owner-only, it's essentially the exact same thing.. just without llGetOwner.

key current_user = NULL_KEY;
float timeout_seconds = 180.0;

default
{
    touch_start(integer n)
    {
        if(current_user)
        {
            // This object is currently being used by someone.
        }
        else
        {
            // No one is using this object yet, set the user.
            current_user = llDetectedKey(0);
            llSetTimerEvent(timeout_seconds);
        }
    }

    timer()
    {
        current_user = NULL_KEY;
        llSetTimerEvent(0);
    }
}

You didn't specify if the object should be "released" after a set amount of time, but that's one example. You can also use the llSetTimerEvent call again to refresh the timer whenever the user takes some kind of an action.

Edit; I'm looks like everybody had a great timing!

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

key user;

default
{
    state_entry()
    {
        user = NULL_KEY;
    }
    touch_start(integer total_number)
    {
        key toucher = llDetectedKey(0);
        if (user == NULL_KEY)
        {
            user = toucher;
            llSay(0, "object was not in use toucher is now the current user");
        }
        else if (user) 
            llSay(0, "touched again by curent user");
        else 
            llSay(0, "object inuse wait your turn");
    }
}

this is how i do it, has an option for it the current user retouches,  adding a timer would be good to reset

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

Disable the touch_start event.  You can do that in a number of ways. Perhaps the easiest is to set a toggle switch to be OFF as soon as someone touches the object and then becomes ON again when the transaction is complete or a specific time period has passed.
 

touch_start (integer num)
{
    if ( !iTouched )
    {
        iTouched = TRUE;    // Just be sure that you make iTouched a g;lobal integer variable
        llSetTimerEvent(15.0);
        // Do your sales stuff or whatever
    }
}

timer()
{
    llSetTimerEvent(0.0);
    iTouched = FALSE;
}

Turn iTouched TRUE again in whatever event (a money event? a listen event?) handles your sales transaction too.

  • Thanks 1
Link to comment
Share on other sites

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