Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Can I limit the residents that communicate with my object

Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
01-02-2007 15:12
I will keep it short. I wanna make sure that the first resident, who touches my object, will be the only one who communicates with it, until he goes away. I do not want concurrent interactions...


thank you so much
Thraxis Epsilon
Registered User
Join date: 31 Aug 2005
Posts: 211
01-02-2007 15:28
In the simplest form you would do something like the following:

CODE

key currentUser
default {
state_entry()
{
currentUser = NULL_KEY;
}

touch_start(integer num_detected)
{
if ((currentUser == NULL_KEY) || (currentUser == llDetectedKey(0)))
{
llSetTimerEvent(0);
llInstantMessage(llDetectedKey(0),"You are the current user of this system");
currentUser = llDetectedKey(0);
llSetTimerEvent(60);
}
else
{
llInstantMessage(llDetectedKey(0),"This system is already in use");
}
}

timer()
{
currentUser = NULL_KEY;
}
}
Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
01-02-2007 15:39
ok thx. but with your proposal only a message appears right? so if the second resident wants to communicate anyway, he can? or did i get this wrong?

after 60 seconds the current user will be "logged off" and the object is free again?
Thraxis Epsilon
Registered User
Join date: 31 Aug 2005
Posts: 211
01-03-2007 01:10
This was just an example, which I thought was pretty self-explanatory.


The idea is to store the current user of the object, you enclose the bodies of your interactions with the check to see if the person attempting to do an action is your current user, if not you can either simply ignore them, or do as I did and give them a message as to why they can't interact with the object.

60 seconds after the last interaction the current user is cleared.