problem with key id in link message
|
|
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
|
07-03-2008 06:41
Hi folks. I'm trying to use an access list in a link message event. I have it working fine so far but need a pointer here.
link_message(integer sender, integer num, string str, key AllowEntry)//Is this ok? { key id = llDetectedKey(0); //if ((AllowEntry(id)) && if (((AllowEntry(id)) && (str=="Int_One"))) { llSetLinkTexture(sender,llGetInventoryName(INVENTORY_TEXTURE,0),side1); } //snip } else llWhisper(0,"Sorry, but only listed people are allowed"); }
no matter how I format this part, the user (who is not on the list) can still perform the function. i.e change the texture on the remote prim but not the prim this script is in. of course the dialog appears on the remote prim but I want the list to block the call. I probably have it all wrong as usual and have been trying many variations hoping to jag it, but is it a simple formatting fix or is there more to it? Thanks team.
_____________________
SCOPE Homes, Bangu -----------------------------------------------------------------
|
|
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
|
07-03-2008 07:02
Hi Kornscope!
First off .. not quite sure what ' AllowEntry(id) ' is supposed to do? Isn't AllowEntry defined as a key type and the parameter passed to the event?
Apart from that the llDetected function only works in touch and collision events.
So what you need to do is capture the key of the toucher in the touch_start event and pass that along. Then check it against the list in your event.
|
|
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
|
07-03-2008 07:25
Hi SD, thanks for the quick response.
Well, the AllowEntry(id) part, I used in the touch event in this script and worked. I just tried to use it again in this part, in much the same way assuming it is the correct way to go.
So..."the llDetected function only works in touch and collision events"..I know that now and I will try to capture and pass the key in my next session tomorrow.
Not sure how to go about it but another 12 hour day bashing at it might help.
Thanks for your help.
_____________________
SCOPE Homes, Bangu -----------------------------------------------------------------
|
|
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
|
07-03-2008 07:39
Kornscope ... Does the script that this event is in already have the list of users? Or is that list what you are passing in the parameter AllowEntry? If the list of allowed users is in the originating script .. then you should check there. But if the list of users is in this script then ... Get the user key in the touch event .. and pass it to the link_messgae in the key paramter and check against the list there .. so:
link_message (integer sender, integer num, string str, key user) {
integer idx = llListFindList(UserList, [user]);
if (idx != -1) { //Do what an authorized user can do } else { //Tell them they can't }
}
//
|
|
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
|
07-04-2008 04:26
i do have the list in the main script which receives a linked message through a dialog choice from the other prim. if (message=="Int_One") { llMessageLinked(LINK_SET, 0,"Int_One",id); }
I put in id where it had NULL_KEY before. The dialog has the key detect? llDialog(llDetectedKey(0), "Inside Window Settings.", MENU_INSIDE, CHANNEL);
Am I supposed to do more than that? ----- link_message(integer sender, integer num, string str, key user){
integer idx = llListFindList(allowedNames, [user]);
if (idx != -1){ if (str=="Int_One") { llSetLinkTexture(sender,llGetInventoryName(INVENTORY_TEXTURE,0),side1);}
I put the above in and nobody can use it and even owner gets the Can't do message. This is the access part; list allowedNames; string notecard = "AccessList"; integer AllowEntry(key id) { string name = llToLower(llKey2Name(id)); integer iIndex = llListFindList(allowedNames, [ name ]); if(llGetOwner() == id) iIndex = 9999; // Always allow the owner integer result = FALSE; if(iIndex >= 0) result = TRUE; return result;
}
I think the wall is cracked and my heads hurts. I thought I was close 2 days ago.
_____________________
SCOPE Homes, Bangu -----------------------------------------------------------------
|
|
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
|
07-04-2008 07:12
Kornscope, I am still not clear in which scripts you have what so here is how I would do it: SCRIPT 1
//Global Variables //Will hold list of authorized user names list gAllowedNames = [];
//Holds the key of the AV that has touched the prim key gCurKey;
default {
//Other code and methods //I assume that the global list variable gAllowedNames is filled by some function/notecard //As well assume that a listen has been set up on channel CH
touch_start(integer num_detected) { gCurKey = llDetectedKey(0); llDialog(llDetectedKey(0), "Inside Window Settings.", MENU_INSIDE, CH); llListen(CH, "", gCurKey, ""); }//End touch_start
listen(integer channel, string name, key id, string message) { if (channel == CH && message == "Int_One") { //Check against the list if (gCurKey == llGetOwner() || llListFindList(gAllowedNames, [llKey2Name(gCurKey)] != -1) {
//Tell the other script to do the work //Since we have already checked the list in this script no need to pass the key llMessageLinked(LINK_SET, 0,"Int_One",NULL_KEY); } else { llSay(0, "You do not have permissions to do this"); } }//End listen
}//End default
SCRIPT 2
default {
//Other code & events
link_message(integer sender, integer num, string message, key user) {
//Check to see what was sent and act ... if (message == "Int_One") { llSetLinkTexture(sender,llGetInventoryName(INVENTO RY_TEXTURE,0),side1); }
}//End link_message }//End default
Alternately if the list gAllowedList is in SCRIPT 2, then we move the check into the link_message of this script and instead of passing NULL_KEY, we pass gCurKey. Hope this helps ...
|
|
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
|
07-06-2008 00:18
Yeah, Im obviously hopeless at this. can't explain the problem let alone get it to work. No matter how I format the code either the owner cant use it or the list just doent work. It work fine from the prim the list is in with the dialog but the link message dont work right. The slave prim sends this listen(integer channel, string name, key gCurKey, string message) { gCurKey = llDetectedKey(0); if (llListFindList(MENU_INSIDE + MENU_OUTSIDE + MENU_ALPHAS, [message]) != -1) { else if (message == "Inside"){llDialog(gCurKey, "Set the Internal Texture.", MENU_INSIDE, CHANNEL); llSetTimerEvent(30.0); } //----------//----------------------------------------------//---------->Set Interior Texture if (message=="Int_One") { llMessageLinked(LINK_SET, 0,"Int_One",gCurKey); } if (message=="Int_Two") { llMessageLinked(LINK_SET, 0,"Int_Two",gCurKey); }
The main prim recieves, has the list and executes //-----------//-----GLOBAL VARIABLES-----------//-----------//
integer lineCounter; key dataRequestID; integer CHANNEL = -03072008; // Date used for channel# integer listen_handle; integer side1; integer side2;
//-----------//-----MENUS-------//-----------
list MENU_INSIDE = ["Int_Seven","Int_Eight","Int_Nine","Int_Four","Int_Five","Int_Six","Int_One","Int_Two","Int_Three","Alpha","Outside"]; //-----------//----ACCESS-----//-----------// list allowedNames; string notecard = "AccessList"; key gCurKey; integer AllowEntry(key gCurKey) { string name = llToLower(llKey2Name(gCurKey)); integer iIndex = llListFindList(allowedNames, [ name ]); if(llGetOwner() == gCurKey) iIndex = 9999; // Always allow the owner integer result = FALSE; if(iIndex >= 0) result = TRUE; return result;
}
//----------//----DEFAULT STATE------//----------//-
default { state_entry() { state ReadConfig; } }
//-------------//-----MAIN RUNNING STATE-----//----------//- state Running { state_entry() { side1 = 0;//Set interior side here side2 = 4;//Set exterior side here }
touch_start(integer total_number) { CHANNEL = (integer) llFrand (1000000)+1; gCurKey = llDetectedKey(0); listen_handle = llListen(CHANNEL, "",gCurKey, ""); if(AllowEntry(gCurKey)) { llDialog(llDetectedKey(0), "Set the Interior Texture", MENU_INSIDE, CHANNEL); llSetTimerEvent(30.0); } else { llInstantMessage((llDetectedKey(0)),"Not Allowed, Ask the owner!"); } } timer() { llListenRemove(listen_handle); //Remove that dialog listener llSetTimerEvent(0);}
listen(integer channel, string name, key gCurKey, string message) { if (llListFindList(MENU_INSIDE , [message]) != -1) { if (message == "Inside"){llDialog(gCurKey, "Set the Interior Texture", MENU_INSIDE, CHANNEL); llSetTimerEvent(30.0); } //----------//---------DIALOG ---------//----------//----------//-
if (message=="Int_One") { llSetLinkTexture(-3,llGetInventoryName(INVENTORY_TEXTURE,0),side1);} else if (message=="Int_Two") { llSetLinkTexture(-3,llGetInventoryName(INVENTORY_TEXTURE,1),side1);} else if (message=="Int_Three") { llSetLinkTexture(-3,llGetInventoryName(INVENTORY_TEXTURE,2),side1);} } else llSay(0, name + " picked invalid option '" + llToLower(message) + "'."); } //----------//---------LINK MESSAGE ----------//----------//----------// link_message(integer sender, integer num, string str, key gCurKey){
I have tried many variations of this but can't get it right. I don't know which of the below to use to check the list. Sometimes it works for the owner but I still get the Sorry line in chat.Or syntax errors when i think it looks right.help
//if (gCurKey == llGetOwner() || llListFindList(allowedNames, [llKey2Name(gCurKey)] != -1) integer idx = (llListFindList(allowedNames, [gCurKey])); if (idx != -1) if (str=="Int_One") { llSetLinkTexture(sender,llGetInventoryName(INVENTORY_TEXTURE,0),side1);} else if (str=="Int_Two") { llSetLinkTexture(sender,llGetInventoryName(INVENTORY_TEXTURE,1),side1);} else if (str=="Int_Three") { llSetLinkTexture(sender,llGetInventoryName(INVENTORY_TEXTURE,2),side1);} else llWhisper(0,"Sorry, but only listed people allowed");
}} //----------//---------INITIALISE NOTECARD----------//----------//----------//-
state ReadConfig { state_entry() { lineCounter = 0; allowedNames = []; // List of Allowed Users integer itemtype = llGetInventoryType(notecard); if(INVENTORY_NOTECARD == itemtype) { dataRequestID = llGetNotecardLine(notecard, lineCounter); llSetTimerEvent(15); } } dataserver( key query_id, string data ) // read from the notecard { if(query_id == dataRequestID) { if (data != EOF) { if(llGetSubString(data, 0,0) != ";") { allowedNames = (allowedNames = []) + allowedNames + [ llToLower(data) ]; llOwnerSay("Allowing "+data); } lineCounter++; dataRequestID = llGetNotecardLine( notecard, lineCounter ); } else { llSetTimerEvent(0); state Running; } } } timer() { llOwnerSay("ERROR - Dataserver time out! aborting"); llSetTimerEvent(0); state Running; }
}
I really appreciate the help.
_____________________
SCOPE Homes, Bangu -----------------------------------------------------------------
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
07-06-2008 05:03
It LOOKS like you might be using keys in some places and names in others. For example, in AllowedEntry() you are searching 'allowedNames' for a name, but in the 'link_message' handler you are searching in the list of names for a key. I'm not sure if that key parameter is really the resident ID or actually a name (string) cast to a key, but either way searching for a key in a list that contains only strings will always fail. Not only the value, but also the exact type, has to match in order for llListFindList() to return with success. See http://www.lslwiki.net/lslwiki/wakka.php?wakka=llListFind
|
|
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
|
07-06-2008 11:34
Kornscope, Ok ... startig to get there I think. Still a mite bite confused over how the execution order here works. Is it: a) Slave Prim is touched by user and passes to main prim. Main prim never responds to touches b) Slave Prim is touched by user and passes to main prim. Main prim as well can be touched and responds c) Slave Prim hears a call from a user and passes to main prim. Based on this, unless its option c) you need to get the key of the touching AV in the touch_start of the slave prim, if it is option c) then use the key parameter of the event, that is the key of the speaking AV, the llDetectedKey in listen does nothing. Now .. if the main prim does not respond to touches you can remove that event, but assuming that it does here is the proper code for that event: touch_start(integer total_number) {
gCurKey = llDetectedKey(0); if(AllowEntry(gCurKey)) {
//Don't start listening on the dialog channel until we are sure we are going to show CHANNEL = (integer) llFrand (1000000)+1; listen_handle = llListen(CHANNEL, "",gCurKey, "");
//We have already grabbed the key .. so no need to keep calling the method llDialog(gCurKey, "Set the Interior Texture", MENU_INSIDE, CHANNEL); llSetTimerEvent(30.0); } else { llInstantMessage(gCurKey,"Not Allowed, Ask the owner!"); } }//End touch_start
Now the link message, which I assume is responding to the call from the slave: link_message(integer sender, integer num, string str, key curAV) {
//Don't use a global variable name in a function or its definition .. leads to confusion, and problems
//Use the same function here as in the touch_start event ... if (AllowEntry(curAV)) { if (str=="Int_One") { llSetLinkTexture(sender,llGetInventoryName(INVENTO RY_TEXTURE,0),side1); } else if (str=="Int_Two") { llSetLinkTexture(sender,llGetInventoryName(INVENTO RY_TEXTURE,1),side1); } else if (str=="Int_Three") { llSetLinkTexture(sender,llGetInventoryName(INVENTO RY_TEXTURE,2),side1) } else { llInstantMessage(curAV,"Sorry, but only listed people allowed"); }
}//End link_message
And last but not least your AllowEntry function: //Again .. change the function variable name away from the global integer AllowEntry(key curAV) { string name = llToLower(llKey2Name(curAV)); integer iIndex = llListFindList(allowedNames, [name] ); integer result = FALSE;
if(llGetOwner() == gCurKey || iIndex != -1) { result = TRUE; }
return result;
}//End AllowEntry
|
|
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
|
07-06-2008 21:51
Thanks Shifting for your continued help.(as you mutter expletives under your breath) Once again, or still, Im totally lost, confused and frustrated. I had to stop or i would do some damage. I've re-read this page, the wiki and more many times but it just don't sink in, I don't 'see' it properly but I usually 'get it' eventually. It's not fun being so code dyslexic. moving on.... From: someone a) Slave Prim is touched by user and passes to main prim. Main prim never responds to touches b) Slave Prim is touched by user and passes to main prim. Main prim as well can be touched and responds c) Slave Prim hears a call from a user and passes to main prim.
a) was working but allowing when it shouldn't. is where my problems began. b)yes, changing texture on all linked prims c)yes, which should change the texture on the slave I replaced the code with the above but I still can't get it to work correctly. The av (my alt) is in the list but gets the deny message this time on main prim and nothing happens on second prim. The main prim is where the textures and the access list is stored. It has its own dialog which changes all the linked prims with the choice. The slave prim/s each have a script with a dialog that asks the main script for the change to it only. (it took me a very long time to get the texture changing to work. Now I have moved on to the access list and I seem to do the same bad coding. anyway....) Reset the script and All fixed...
_____________________
SCOPE Homes, Bangu -----------------------------------------------------------------
|
|
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
|
07-07-2008 03:44
Kornscope, Ok .. first thing first. If by 'nothing happens on second prim.' you mean that you do not even get the non-authorized message, that is because the else that gives that message is inside the if (AllowEntry(curAv)) check .. drop it outside so that it works as an else teher and at least you'll get the message (sirry if I messed that up earlier): link_message(integer sender, integer num, string str, key curAV) { //Don't use a global variable name in a function or its definition .. leads to confusion, and problems //Use the same function here as in the touch_start event ... if (AllowEntry(curAV)) { if (str=="Int_One") { llSetLinkTexture(sender,llGetInventoryName(INVENTO RY_TEXTURE,0),side1); } else if (str=="Int_Two") { llSetLinkTexture(sender,llGetInventoryName(INVENTO RY_TEXTURE,1),side1); } else if (str=="Int_Three") { llSetLinkTexture(sender,llGetInventoryName(INVENTO RY_TEXTURE,2),side1); } } else { llInstantMessage(curAV,"Sorry, but only listed people allowed"); } }//End link_message
Now as to the Alt not being authorized and being inthe list ... cannot see wht that would happen. Are you sure the list has loaded? I would do some value dumps to chat to see what actually is happening. i.e in the AllowEntry function: ...
llSay(0, name); llSay(0, (string)iIndex);
llSay(0, llDumpList2String(allowedNames, "@");
This should show if thwe values are actually in the list or not .. as well saw one more small problem in the Allow Entry function. The check against owner should be on curAv not gCurKey.
|
|
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
|
07-07-2008 03:48
After a rest and returning:
After previously removing some code, namely the changed event that reset the access list to shorten the testing. I tested again with a manual save/reset and it does seem to work now. Also having two clients running which slows thing down didn't help either. But thanks immensely for your help SD! I have working code. And thanks Hewee, I will take note of that.
_____________________
SCOPE Homes, Bangu -----------------------------------------------------------------
|
|
Shifting Dreamscape
Always questioning ...
Join date: 12 Dec 2007
Posts: 266
|
07-07-2008 06:28
Great! Hope I was of some help .. 
|