Whose permission does llGetPermissions get?
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-15-2005 22:38
If "if (!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))" was under touch event, I could know that it checked the avatar who touched. But what if it were under listen or link_message event? I needed to give a permission to multiple ppl and prepared several scripts to give it to each avatar. Those scripts communicate by llMessageLinked. If someone touches the object, the script which has a touch event sends his id, and receiving it, the script which has a link_message event gives a permission to the avatar who is sent his id unless he has had it yet. But now I'm just wondering if this is really checking out his permission. link_message(integer sender_num, integer num, string str, key id) { if (!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) { llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION); } }
_____________________
 Seagel Neville 
|
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
|
08-15-2005 23:08
That would depend on the key identified by "id". llRequestPermissions will request permissions of the agent whose id you give it. If you don't give it a valid id, it won't work.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-15-2005 23:17
Catherine, thank you. Yeah, I understand llRequestPermissions part. But what I want to know is llGetPermissions. There is a case that I don't use llRequestPermissions. OK, that example was my wrong. What about this? link_message(integer sender_num, integer num, string str, key id) { if (!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) { llSay(0, "Hey, you don't have the permission!"); } }
_____________________
 Seagel Neville 
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-16-2005 00:08
You're looking for llGetPermissionsKey(), which returns which agent the script has permissions for.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-16-2005 00:33
Hi Jillian, Well... should I use it like this? link_message(integer sender_num, integer num, string str, key id) { if (!((id == llGetPermissionsKey())&((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)))) { llSay(0, "Hey, you don't have the permission!"); } } EDIT: hmm... this is strange... I thought this again. if((id & PERMISSION_TRIGGER_ANIMATION) != llGetPermissionKey()) Does this make sense? Oh, but it has not yet explained whose key this llGetPermissonKey gets. hmm...? 
_____________________
 Seagel Neville 
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-16-2005 02:48
From: Seagel Neville link_message(integer sender_num, integer num, string str, key id) { if (!((id == llGetPermissionsKey())&((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)))) { llSay(0, "Hey, you don't have the permission!"); } } Is the closest I think, although I've not tried it I think you want: link_message(integer sender_num, integer num, string str, key id) { if (!(id == llGetPermissionsKey() && (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)==PERMISSION_TRIGGER_ANIMATION)) { llSay(0, "Hey, you don't have the permission!"); } } llGetPermissionsKey() returns the key of the agent the script currently has permissions for. This lets you check the ID of the person is being passed properly (depending on your application the logic of this might be wrong too, if this is for your dance machine I think it's wrong and you want to separate the if statements since you're passing keys to all scripts and you're trying to make it so only the one with the right person triggers I guess). You need the && because they're two statements you're trying to evaluate as true, not bitwise compare. Similarly you need something to have both parts evaluate. I'm also not sure this is quite what you need. What are you actually trying to do with it?
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-16-2005 04:41
Thank you, Eloise, From: Eloise Pasteur if this is for your dance machine I think it's wrong and you want to separate the if statements since you're passing keys to all scripts and you're trying to make it so only the one with the right person triggers I guess Yup. So I let it store the number of touching person and send the both num and key. And each script works when just specific each num receiving. From: someone You need the && because they're two statements you're trying to evaluate as true, not bitwise compare. It makes sense. I was wrong. But consider if it is possible that "id == llGetPermissionKey()". llGetPermissionsKey() returns the key of the agent + the permission the agent has. But how can it know who is the agent and what is the permission under such link_message event. That is my question. From: someone I'm also not sure this is quite what you need. What are you actually trying to do with it? The former, I believe you understand me. And the latter, hehe, no. I need friends. But once I tested it, I would have to consider and write a script again, and it would come to need friends to test. lol. Where are there such convenient friends? hmm... I need an alt? 
_____________________
 Seagel Neville 
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-16-2005 06:30
Well I'll test when the grid is back up, as I've already said. Reading the wiki tells me that llGetPermissionsKey() gets the key of the person that the script holds permissions for. llGetPermissions() tells you what they are (strictly it returns the sum of the permissions values granted). Most, but not all scripts, I've written so far only ask for one or two permissions, although I suppose something that attaches, takes money and animates you is possible all in one. So I know what permissions have been asked for, and I'm just checking they've actually given permission so I avoid rude messages and chat spam. The times it might get tricky are if you ask for multiple permissions at different times. Then you might need to know both for more active reasons. So using you're example: link_message(integer sender_num, integer num, string str, key id) { if (id == llGetPermissionsKey()) { if((llGetPermissions() & PERMISSION_DEBIT)==PERMISSION_DEBIT) { llSay(0, llKey2Name(id)+" has given debit permissions."); } if((llGetPermissions() & PERMISSION_TAKE_CONTROLS) == PERMISSION_TAKE_CONTROLS) { llSay(0, llKey2Name(id)+" has given permission to take controls."); } // etc. etc. for the other permissions. llSay(0, "All permissions checked."); } } For a dance machine I'm guessing you *only* use PERMISSION_TRIGGER_ANIMATION, but I'd still use this structure and rather than saying something I'd presumably stop the current dance and start the next one. You could use something where you pay to dance I suppose, but they've not invaded SL yet, nor are they likely.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-16-2005 07:11
Eloise, thank you. See them anytime that is covenient for you.
Then, what do you think of "id == llGetPermissionsKey()"? The avatar's key is like that "66864f3c-e095-d9c8-058d-d6575e6ed1b8" and PERMISSION_TRIGGER_ANIMATION's value 16, that is, 0x0010? Though I don't know how to sum both, if it is true between id and llGetPermissionsKey(), llGetPermissionsKey() must have the both informations. Is that possible? How does llGetPermissionsKey get the information of "66864f3c-e095-d9c8-058d-d6575e6ed1b8" at least? That's what I don't know.
_____________________
 Seagel Neville 
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-16-2005 09:04
It doesn't.
llGetPermissionsKey() returns a key, e.g. 66864f3c-e095-d9c8-058d-d6575e6ed1b8.
llGetPermissions() returns the permissions granted.
Since each script can only hold permissions from one agent they don't need further ID, the first lets you check which agent's permissions are being held (if you need to), the second which permissions it is that the script holds.
In the context of your dance machine you have a master script that sorts which animator script is holding which person's permissions, and a series of animator scripts I think?.
As long as the master script is doing its job you don't need to pass the keys around, it knows which animator script it needs to talk to and passes a link message with the correct integer to reach that script. It could, almost as easily, however just pass key information, and you could use llGetPermissionsKey() to check it's the right script it's talking to.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-16-2005 20:14
Hello Eloise,
Ok, I got llGetPermissionsKey() was just a key of the avatar and had no other informations. But how does the script know who is the person to get his key? Let's see other llGet something functions.
llGetPos : Returns the position info of the object the script is attached to. llGetOwner : Returns the key of the owner of the object the script is attached to. llGetLinkNumber : Returns the number in link set of the object the script is attached to. llGetNumberOfPrims : Returns the number of prims of the object the script is attached to.
According to the manner of those llGets above, llGetPermissionsKey returns the key of the avatar...hmm...when, where, and how is the avatar connected with the object the script is attached to?
I guess it is absolutely needed llRequestPermissions function in that script. And the script doesn't know who is the person granted some permissions until the person accept it. If so, my second example was a nonsense because there wasn't llRequestPermissions. Right? And if there is llRequestPermissions in it, I think the both below is possible but it doesn't need the both.
1. if (!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)) 2. if (id != llGetPermissionsKey())
_____________________
 Seagel Neville 
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-17-2005 03:41
Yes, you use llRequestPermissions(key of agent) to request the permissions.
And yes, either llGetPermissionsKey(), or llGetPermissions() & PERMISSION_TRIGGER_ANIMATION ought to work.
It's probably more sensible to use the latter, it's more generally applicable and it actually asks the question you really want answered.
Your previous questions might have made sense, it wasn't clear what you wanted and why. For example checking that the various people are registered and that that the keys you have in your master script would use a logic similar to that you were describing.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-17-2005 05:36
Thank you, Eloise, All was cleard for me. My wrong was that I took llGetPermissions for the same thing as llGetOwner. So just putting down this in the script, I thought that it would recognize AV's permission. But if its format was like llGetPermissions(key id), I got soon that it would recognize the permission of the AV who had that id. But it was not like that. So I wondered which AV's permission it would recognize. I didn't think that it cannot be told without llRequestPermissions. I think the Wiki needs to add Q&A like below. Question: Which AV's permissions does this look through? Answer: The last person who was requested permissions by llRequestPermissions on the same script and accepted. 
_____________________
 Seagel Neville 
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-17-2005 07:33
It is the nature of Wiki's to allow people to add to them, feel free.
I suspect you're problems are with the English. The Wiki is clear to me, but if it's not clear to you then add your comments to it.
|
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
|
08-17-2005 09:07
 Eloise, you're right! Anyway, thank you for having answerd me. 
_____________________
 Seagel Neville 
|