07-19-2006 21:59
Purpose of this script is not for a veihicles, or attachments but used in a stationary object.
Take contol by touch.
If in use by Owner it will not allow a Someone to take control.
If in use by Someone, Owner can and kick person off but not Someone else can not use.
Also once in use it can toggle some code by touch.

Now here is the problem Permission are not release after a person Teleports to another sim. And once teleported The "release keys" button does not work as well as left and right turn. Either a relog or use another object must be used to take controlls and release control to gain full control back of your AV. That is one SL Major Bug.

Now the script bug. The script still thinks it is undercontrol of the perosn no longer in the sim. and llGetPermissionsKey does not return a NULL_KEY. the only other thing I can think of doing is Useing a Sensor or llKey2Name which would return an empty string. But if the person returns to the sim for some reason Key2Name would not work. And a sensor well is more of a mess. Any better ideas or wait for llGetPermissionsKey to be fixed. which has been broken for a long time now.

Here is te stripped down code test at your own risk.
CODE

integer LISTEN_CHECK_USER = 10;
integer listen_event;
key owner_key;
key detected_key;
string detected_name;
key user_key;
string user_name;
integer in_use;
integer handle = 0;

SetupListen(float time, key id)
{
llListenRemove (handle);
handle = llListen(0, "", id, "");
llSetTimerEvent(time);
if(handle >= 2147483000) llResetScript();
}

PermissionSetup()
{
user_key = llGetPermissionsKey();
if (user_key == NULL_KEY) in_use = FALSE;
if (!in_use) // if not is use Ask permissions
{
llRequestPermissions(detected_key, PERMISSION_TAKE_CONTROLS);
}
if (in_use && detected_key != user_key)//Tell who current user is
{
llSay(0, "In use by " + user_name + ".");
}
if (in_use && detected_key == owner_key && detected_key != user_key)// Allow Owner to kick user off
{
listen_event = LISTEN_CHECK_USER;
llSay(0,"Kick " + user_name + " off? Y or N.");
SetupListen(15.0, owner_key);
}
if (in_use && detected_key == user_key)
{
llSay(0,"Somthing is toggled here");
}
}

default
{
on_rez(integer param)
{
in_use = FALSE;
llReleaseControls();
}
state_entry()
{
}
touch_start(integer touch_num)
{
llSay(0,(string)llGetPermissions());
owner_key = llGetOwner();
detected_key = llDetectedKey(0);
detected_name = llDetectedName (0);
PermissionSetup();
}
timer()
{
llSetTimerEvent(0.0);
llListenRemove (handle);
llSay(0,"time out");
}
listen(integer ch, string name, key id, string message)
{
if (listen_event == LISTEN_CHECK_USER)
{
message = llToUpper(message);
if (message == "Y") llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
}
}
run_time_permissions(integer perms)
{
integer desired_controls = CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LEFT | CONTROL_RIGHT;
if (perms & PERMISSION_TAKE_CONTROLS)
{
llTakeControls(desired_controls, TRUE, FALSE);
llInstantMessage(detected_key, "controll taken");
user_key = detected_key;
user_name = detected_name;
in_use = TRUE;
}
else
{
in_use = FALSE;
llSay(0,"Permissions not set");
llReleaseControls();
}

}
control(key id, integer down, integer new)
{
llOwnerSay("Code Here");
}
}