Jump to content

Help: AllowDropInventory() Timer


Christopher Organiser
 Share

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

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

Recommended Posts

Try something like this:

integer lock;
default
{
  ...
  ...

  touch_start(integer total_num)
  {
    if(!lock)
      {
      lock = TRUE;
      llAllowInventoryDrop(TRUE);
      llSetTimerEvent(120.0);
      }
  }

  timer()
  {
    llSetTimerEvent(0.0);
    lock = FALSE;
    llAllowInventoryDrop(FALSE);
  }          
}

 

Link to comment
Share on other sites

2 answers already while I was typing? I am getting old.. ;) Well, at least, Ela's post made me think about a lock.

 

integer TimeLeft;
key Dropper;

default
{
    state_entry()
    {
        llSetText("Click to drop your object", <1.0, 1.0, 1.0>, 1.0);
    }
    
    touch_end(integer num)
    {
        if (Dropper) { return; } // Already busy.
        //
        llSetText("", <1.0, 1.0, 1.0>, 1.0);
        Dropper = llDetectedKey(0);
        llRegionSayTo(Dropper, 0, "/me -- You have 2 minutes to drop.");
        llAllowInventoryDrop(TRUE);
        TimeLeft = 90; // + 30 of timer = 120
        llSetTimerEvent(30.0); // No stress...
    }
    
    timer()
    {
        if (TimeLeft > 0)
        {
            llRegionSayTo(Dropper, 0, "/me -- Time left: " + (string)TimeLeft + " sec.");
            if (TimeLeft > 30)
            {
                TimeLeft -= 30;
            }
            else
            {
                TimeLeft -= 10;
                llSetTimerEvent(10.0); // Now, you can stress!
            }
        }
        else
        {
            llSetTimerEvent(0.0);
            llAllowInventoryDrop(FALSE);
            llRegionSayTo(Dropper, 0, "/me -- Time out!");
            Dropper = "";
            llSetText("Click to drop your object", <1.0, 1.0, 1.0>, 1.0);
        }
    }
    
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY)
        {
            if (Dropper) // is a valid key
            {
                llSetTimerEvent(0.0);
                llAllowInventoryDrop(FALSE);
                llRegionSayTo(Dropper, 0, "/me -- Thank you.");
                llSetText("Click to drop your object", <1.0, 1.0, 1.0>, 1.0);
            }
        }
    }
}

Compiled and tested in-world.

 

Link to comment
Share on other sites

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