Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llRequestPermissions()

Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
09-27-2005 15:48
I am having some difficulty with a custom TP system that uses custom sit pose as well. I have the TP part setup but the animations part is really killing me. In order for animations to work out there needs to be permissions in place otherwise you get the permissions error, right?

As soon as I place the object, if I teleport then I have the script tell me if permissions was not found and that it is requesting them from llAvatarSitOnTarget. I got this message. The thing is the animation never took place and that I never recieved a permissions request dialog. Ok...

Now, if I TP a second time, the script tells me permissions were found and the animation actually plays this time. Yet I still did not recieve any kind of permissions request dialog. Weird, cause I thought it was supossed to.

How do I get the thing setup so that anyone can use the TP system and have it animate them without much hassle?

The following is my script. I added some stuff in it to kind of help with the debugging process so excuse that. You can disregard the listen() portion of the script as it has nothing to do with the actual animation stuff.

I was basing some of my work off from some poseballs I found. But mine requires a bit more custom work to setup so it doesn't work out as smoothly it seems.

Thanks much.

CODE

// Set this to how high up you want the teleport to go in meters
float distance_up = 100.0;

vector start_position;

default
{
state_entry()
{
llSitTarget(<0,0,0.1>, ZERO_ROTATION);
llSetSitText("Teleport");

llListen(0, "", llGetOwner(), "");
}

on_rez(integer param)
{
llResetScript();
}

listen(integer channel, string name, key id, string message)
{
list parsed = llParseString2List(message, [" "], []);

if(llGetListLength(parsed) > 0)
{
if(llList2String(parsed, 0) == "teleport")
{
if(llList2String(parsed, 1) == "distance")
{
float temp_up = (float)llList2String(parsed, 2);

if(temp_up > 0 && temp_up <= 768)
{
distance_up = temp_up;
llOwnerSay("Distance set to " + (string)distance_up + " meters");
}
else
{
llOwnerSay("Please enter a distance between 1 and 768.");
}
}
}
}
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
if(llAvatarOnSitTarget() != NULL_KEY)
{
vector target_position;
integer perm = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found. Requesting...");
llRequestPermissions(llAvatarOnSitTarget(), FALSE);
}

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found");
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llOwnerSay("Permissions Found");
llStopAnimation("sit");
llStartAnimation("dead sleep");
}

llSleep(1.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

start_position = llGetPos();
target_position = start_position + <0,0,distance_up>;

while(llVecDist(llGetPos(), target_position) > 0.001)
{
llSetPos(target_position);
}

llSleep(0.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llStopAnimation("dead sleep");
}

llUnSit(llAvatarOnSitTarget());

llSleep(1.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(0.5);

while(llVecDist(llGetPos(), start_position) > 0.001)
{
llSetPos(start_position);
}
}
}
}
}
_____________________
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-27-2005 16:09
Well, a couple of things. First, please use PHP tags instead of CODE tags, it makes the code easier to read :) Then, shouldn't:

CODE
llRequestPermissions(llAvatarOnSitTarget(), FALSE);


Be:

CODE
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);


That may be why you don't get the permissions dialog - you didn't ask for any permissions.

Also, if the person grants permissions, you'll be notified by the run_time_permissions event. What you seem to be doing is sleeping for 1.5 seconds and checking the same perms variable again. This variable hasn't changed in value (since you didn't set it to anything else, it got set up at the top), the second check will never produce a different result from the first check. But the second time you do ask for the right permissions.

Here's what I think this should look like:

CODE

changed(integer change)
{
if(change & CHANGED_LINK)
{
if(llAvatarOnSitTarget() != NULL_KEY)
{
vector target_position;
integer perm = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found. Requesting...");
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
// Permissions available, do all the custom sit/anim/whatever stuff
}

...

run_time_permissions(integer perms)
{
if(perm & PERMISSION_TRIGGER_ANIMATION)
{
// Permissions granted, do custom stuff here as well
}
else
{
// Request permissions again, print an error message and fail, whatever
}
}


P.S. If you want to just sleep for a while and check perms again instead of handling the run_time_permissions event, you'll need to re-check the permissions:

CODE

integer perm = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found. Requesting...");
// Fix this to request the correct permissions
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

// After the delay, check again to see what permissions we have now
perms = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found");
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llOwnerSay("Permissions Found");
llStopAnimation("sit");
llStartAnimation("dead sleep");
}
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
09-27-2005 16:20
From: Ziggy Puff
Well, a couple of things. First, please use PHP tags instead of CODE tags, it makes the code easier to read :) Then, shouldn't:

CODE
llRequestPermissions(llAvatarOnSitTarget(), FALSE);


Be:

CODE
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);



Apologies on that part. I tried it without as well and still the same thing. The reason I tried FALSE was to try and remove and requested permissions before reapplying them. FALSE can be used to remove permissions so to speak. I only added that line for testing. With this lsine removed it still had the same effect.

Quoted from http://secondlife.com/badgeo/wakka.php?wakka=llRequestPermissions
From: someone
Requesting permission FALSE (or 0) will result in all permissions being released.


I will try a few other things you mentioned though.
_____________________
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-27-2005 16:27
Ah. Didn't know that :) Thanks.
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
09-27-2005 16:31
Here's the code revised and added your suggestion about another llGetPermissions() check. Still same effect. Does not see permissions on first TP. But it does on the second TP although without any request dialogs coming up.

CODE

// Set this to how high up you want the teleport to go in meters
float distance_up = 100.0;

vector start_position;

default
{
state_entry()
{
llSitTarget(<0,0,0.1>, ZERO_ROTATION);
llSetSitText("Teleport");

llListen(0, "", llGetOwner(), "");
}

on_rez(integer param)
{
llResetScript();
}

listen(integer channel, string name, key id, string message)
{
list parsed = llParseString2List(message, [" "], []);

if(llGetListLength(parsed) > 0)
{
if(llList2String(parsed, 0) == "teleport")
{
if(llList2String(parsed, 1) == "distance")
{
float temp_up = (float)llList2String(parsed, 2);

if(temp_up > 0 && temp_up <= 768)
{
distance_up = temp_up;
llOwnerSay("Distance set to " + (string)distance_up + " meters");
}
else
{
llOwnerSay("Please enter a distance between 1 and 768.");
}
}
}
}
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
if(llAvatarOnSitTarget() != NULL_KEY)
{
vector target_position;
integer perm;

perm = llGetPermissions();

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found");
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llOwnerSay("Permissions Found");
llStopAnimation("sit");
llStartAnimation("dead sleep");
}

llSleep(1.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

start_position = llGetPos();
target_position = start_position + <0,0,distance_up>;

while(llVecDist(llGetPos(), target_position) > 0.001)
{
llSetPos(target_position);
}

llSleep(0.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

perm = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llStopAnimation("dead sleep");
}

llUnSit(llAvatarOnSitTarget());

llSleep(1.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(0.5);

while(llVecDist(llGetPos(), start_position) > 0.001)
{
llSetPos(start_position);
}
}
}
}
}
_____________________
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-27-2005 16:38
Well... I'm stumped :) I might try it in-world later this evening, maybe I'll have some more ideas then.
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
09-27-2005 16:52
Ok, I fixed this permissions issue by adding another llRequestPermissions() before the all the animation stuff. Seems good now.

Found another issue though. When someone else TP's with it it ends up animating my AV instead of theirs. lmao. I specified llAvatarSitOnTarget() for the permissions. Isn't this right?

CODE

// Set this to how high up you want the teleport to go in meters
float distance_up = 100.0;

vector start_position;

default
{
state_entry()
{
llSitTarget(<0,0,0.1>, ZERO_ROTATION);
llSetSitText("Teleport");

llListen(0, "", llGetOwner(), "");
}

on_rez(integer param)
{
llResetScript();
}

listen(integer channel, string name, key id, string message)
{
list parsed = llParseString2List(message, [" "], []);

if(llGetListLength(parsed) > 0)
{
if(llList2String(parsed, 0) == "teleport")
{
if(llList2String(parsed, 1) == "distance")
{
float temp_up = (float)llList2String(parsed, 2);

if(temp_up > 0 && temp_up <= 768)
{
distance_up = temp_up;
llOwnerSay("Distance set to " + (string)distance_up + " meters");
}
else
{
llOwnerSay("Please enter a distance between 1 and 768.");
}
}
}
}
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
//llOwnerSay("Permissions Found");
//llStopAnimation("sit");
//llStartAnimation("dead sleep");
}
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
if(llAvatarOnSitTarget() != NULL_KEY)
{
vector target_position;
integer perm;

perm = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found");
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

perm = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found");
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llOwnerSay("Permissions Found");
llStopAnimation("sit");
llStartAnimation("dead sleep");
}

llSleep(1.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

start_position = llGetPos();
target_position = start_position + <0,0,distance_up>;

while(llVecDist(llGetPos(), target_position) > 0.001)
{
llSetPos(target_position);
}

llSleep(0.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

perm = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found");
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llOwnerSay("Permissions Found");
llStopAnimation("dead sleep");
}

llUnSit(llAvatarOnSitTarget());

llSleep(1.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(0.5);

while(llVecDist(llGetPos(), start_position) > 0.001)
{
llSetPos(start_position);
}
}
}
}
}
_____________________
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
09-27-2005 17:08
Sweet! I got that animation issue fixed now. :P That permission removal came in handy on this issue. Hehe. Here's the revised code. Now to clean it up a bit.

CODE

// Set this to how high up you want the teleport to go in meters
float distance_up = 100.0;

vector start_position;

default
{
state_entry()
{
llSitTarget(<0,0,0.1>, ZERO_ROTATION);
llSetSitText("Teleport");

llListen(0, "", llGetOwner(), "");
}

on_rez(integer param)
{
llResetScript();
}

listen(integer channel, string name, key id, string message)
{
list parsed = llParseString2List(message, [" "], []);

if(llGetListLength(parsed) > 0)
{
if(llList2String(parsed, 0) == "teleport")
{
if(llList2String(parsed, 1) == "distance")
{
float temp_up = (float)llList2String(parsed, 2);

if(temp_up > 0 && temp_up <= 768)
{
distance_up = temp_up;
llOwnerSay("Distance set to " + (string)distance_up + " meters");
}
else
{
llOwnerSay("Please enter a distance between 1 and 768.");
}
}
}
}
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
//llOwnerSay("Permissions Found");
//llStopAnimation("sit");
//llStartAnimation("dead sleep");
}
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
if(llAvatarOnSitTarget() != NULL_KEY)
{
llOwnerSay(llKey2Name(llAvatarOnSitTarget()));

vector target_position;
integer perm;

perm = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found");
llOwnerSay(llKey2Name(llAvatarOnSitTarget()));
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

perm = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found");
llOwnerSay(llKey2Name(llAvatarOnSitTarget()));
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llOwnerSay("Permissions Found");
llStopAnimation("sit");
llStartAnimation("dead sleep");
}

llSleep(1.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

start_position = llGetPos();
target_position = start_position + <0,0,distance_up>;

while(llVecDist(llGetPos(), target_position) > 0.001)
{
llSetPos(target_position);
}

llSleep(0.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(1.5);

perm = llGetPermissions();

if(!(perm & PERMISSION_TRIGGER_ANIMATION))
{
llOwnerSay("Permissions Not Found");
llOwnerSay(llKey2Name(llAvatarOnSitTarget()));
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}
else
{
llOwnerSay("Permissions Found");
llStopAnimation("dead sleep");
}

llRequestPermissions(llAvatarOnSitTarget(), FALSE);

llUnSit(llAvatarOnSitTarget());

llSleep(1.5);

llMessageLinked(LINK_SET, 0, "!", NULL_KEY);

llSleep(0.5);

while(llVecDist(llGetPos(), start_position) > 0.001)
{
llSetPos(start_position);
}
}
}
}
}
_____________________
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-27-2005 17:12
Cool. Glad you fixed it. I'll remember this the next time I'm messing with permissions :)

You could also use llGetPermissionsKey to find out whose permissions you're reading with llGetPermissions.

http://secondlife.com/badgeo/wakka.php?wakka=llGetPermissionsKey

So maybe something like

CODE
if (llGetPermissionsKey() != llAvatarOnSitTarget())


Then you know that the permissions you have aren't from the current user, so clear and try again or something. Just an idea.
Ricky Shaftoe
Owner, "Rickymations"
Join date: 27 May 2005
Posts: 366
09-27-2005 23:25
I'm having a similar problem with my sync script. Someone gets off one of my two poseballs and stops animating; but then a new person hops on that ball, and the first rider suddenly starts animating while the second rider does nothing! When I'm more awake, I'll study this thread to see if a solution presents itself here. llGetPermissionsKey may help me.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
09-28-2005 00:03
Number one bug in poseballs (besides them borking on sim crash) is the misunderstanding of how the changed event works.

Number two bug is not checking if your agents are in the sim before trying to trigger animations on them.


Anytime a user stands up from sitting on an object which ever sit target they are sitting on, a changed event is fired in every script in the object that can handle it.


Take for example an object with 2 sit targets

User A sits on spot 1
change event fired in spot 1 script (llAvatarOnSitTarget()!=NULL_KEY)
change event fired in spot 2 script (llAvatarOnSitTarget()==NULL_KEY)
User B sits on spot 2
change event fired in spot 1 script (llAvatarOnSitTarget()!=NULL_KEY)
change event fired in spot 2 script (llAvatarOnSitTarget()!=NULL_KEY)
User A stands up
change event fired in spot 1 script (llAvatarOnSitTarget()==NULL_KEY)
change event fired in spot 2 script (llAvatarOnSitTarget()!=NULL_KEY)
User B stands up
change event fired in spot 1 script (llAvatarOnSitTarget()==NULL_KEY)
change event fired in spot 2 script (llAvatarOnSitTarget()==NULL_KEY)

The best way to determine what to do after you have checked the sit target.
CODE

integer perm = PERMISSION_TRIGGER_ANIMATION;
if((llGetPermissions & perm) == perm && llGetAgentSize(llGetPermissionsKey())!=ZERO_VECTOR)


after you are done stoping your animation, releasing your permissions or reseting your script is a good idea.

This is the sort of thing that drives me crazy.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-28-2005 11:13
Thanks. I didn't know either of those. Did I mention I haven't done any poseballs? :) This is useful for multi-seater vehicles too.