Jump to content

Access control for multiple user


Elisabeth Ohmai
 Share

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

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

Recommended Posts

Hello! I want make for my project an access control based on dialog. When someone to touch an attached prim, owner will see confirmation window and can grant permissions for do something or deny it by simple clicking Ok or Cancel button. Its easy for one user:

integer Handle;
integer Channel;

openMenu(key id, string text, list buttons){
    Channel = (integer)llFrand(DEBUG_CHANNEL)*-1;
    Handle = llListen(Channel, "", id, "");
    llDialog(id, text, buttons, Channel);
    llSetTimerEvent(90.0);
}

closeMenu(){
    llSetTimerEvent(0.0);
    llListenRemove(Handle);
}

default{
    touch_start(integer num_detected)
    {
        openMenu(llGetOwner(), "Don't ask, just click Ok button", ["Ok", "Cancel"]);
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if (message == "Ok"){
            llOwnerSay("Hello!");
            closeMenu();
        }
        else if (message == "Cancel"){
            closeMenu();    
        }
    }
    
    timer(){
        closeMenu();
    }
}

Problem starts when another user (or users) touch this prim before owner react on first window... What the best way to do it? And i see another problem, if we will have a few listener open and waiting for owner reaction, we have only one timer, and can close only last listener by time-out.

Link to comment
Share on other sites

there is quite a few ways to code this. The general idea tho is to ignore further touches from other people until the owner has responded

one way it can be done, example:
 

// global
integer waiting_for_owner;


touch_start( ... )
{
   integer isOwner = (llDetectedKey(0) == llGetOwner());
   if (isOwner)
   {
       ... do the owner menu ...
   }
   else // is some other person
   {
      if (!waiting_for_owner)
      {
         waiting_for_owner = TRUE;  // this goes here so that other people will be blocked immediately
         ... show the person menu dialog ...
      }
   }
}

listen (..., string text, key id)
{
   if (id == llGetOwner())
   {
      ... do if (text == ...) ...
      waiting_for_owner == FALSE; // only accept new touches when owner has responded

   }
   else  // id is other person
   {
      ... do if (text == ...) ...
   }  
}

 

Link to comment
Share on other sites

10 minutes ago, Mollymews said:

there is quite a few ways to code this. The general idea tho is to ignore further touches from other people until the owner has responded

one way it can be done, example:

Thanks! I thought about this way, but decide to keep it as a last means if I cant find another.

Link to comment
Share on other sites

if you want so that anyone can touch at any time, and they wait for the owner to respond to their touch, which could be some time later then a way to do this is to add each unique person to a list, and then at some time (later) the owner can go thru the list and approve/disapprove the touch requests in the list

 

 

Link to comment
Share on other sites

Everybody can touch it and the owner gets a dialog - if in the same sim. The dialog answer will only be processed if the owner is within 20m around the root of the object though.

Is it supposed to work that way?

Maybe a distance check and ignore when owner is too far away makes sense - depends what it is for.

I wouldn't open a new listen for every dialog - one is sufficient - if the timer triggers then close.

You will get a runtime error if you exceed 65 listens - do you expect excessive use?

There is a possibility to close all listens at once:

In the timer event: state closeall;

and the closeall state:

state closeall {
	state_entry {
		state default;
	}
}

State change closes all open listens.

 

Link to comment
Share on other sites

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