try that one.....
integer limit = 10;
integer autorized;
key id;
default
{
on_rez (integer param)
{
llResetScript();
}
state_entry ()
{
llSetClickAction(CLICK_ACTION_TOUCH);
llSitTarget(<0.0, 0.0, 1.0>, ZERO_ROTATION);
}
touch_start (integer total_number)
{
id = llDetectedKey(0);
vector mypos = llGetPos ();
vector yourpos = llList2Vector (llGetObjectDetails (llDetectedKey (0), [OBJECT_POS]), 0);
if ((llAbs ((integer) (yourpos.x-mypos.x))> limit) || (llAbs ((integer) (yourpos.y-mypos.y))> limit) || (llAbs ((integer) (yourpos.z-mypos.z))> limit))
{
autorized = 0;
llSetClickAction(CLICK_ACTION_TOUCH);
llInstantMessage (id, "You are too far away. Move closer and touch again.");
}
else
{
llSetClickAction(CLICK_ACTION_SIT);
autorized = 1;
llInstantMessage (id, "You're close enough, thanks! click again to sit");
llSetTimerEvent(10.0);
}
}
changed(integer change)
{
if(change & CHANGED_LINK)
{
key Av = llAvatarOnSitTarget();
if(Av == id)
{
if(autorized == 0)
{
llUnSit(Av);
llInstantMessage (Av, "Not allowed to sit");
}
else
{
llSetClickAction(CLICK_ACTION_TOUCH);
}
}
else
{
llUnSit(Av);
llResetScript();
}
}
}
timer()
{
llSetClickAction(CLICK_ACTION_TOUCH);
autorized = 0;
llInstantMessage (id, "Too late, try again");
llSetTimerEvent(0.0);
}
}
|