Jump to content
ChaosRaine

Limiting users

Recommended Posts

I am trying to make an object usable by anybody, but only one person at a time. I've seen sales boards that will go to a busy more while one person makes a purchase. How do I set up this busy mode?

Edited by ChaosRaine

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...