Leander Tyles Posted August 3, 2012 Share Posted August 3, 2012 no matter what i do, i cant make this code work properly,long story short it says im not the owner but as you can see from the localchat below llGetOwner() and USERID both match.but then thiers blank lines for some reason so somethings wrongUSERID is a global variable so i dont know what else i can do[15:20] : 3e777790-f352-4571-bb1e-460048a4d8fe[15:20] : 3e777790-f352-4571-bb1e-460048a4d8fe[15:20] :[15:20] : 3e777790-f352-4571-bb1e-460048a4d8fe[15:20] :[15:20] SECURITY: sorry this is a owner only function. the blankline looks like its forgetting the USERID listen(integer channel, string name, key id, string message) { list data = llParseStringKeepNulls(message, ["|"], []); message = llList2String(data, 0); USERID = llList2String(data, 1); llSay(0,(string)USERID); llSay(0,(string)llGetOwner()); if (channel == secretchannel) { if (message == "request:Security") { llSetObjectName("SECURITY MENU"); llDialog(USERID,"\nSECURITY MENU:\n\n* you have 60 seconds to make a choice.\n* issue cmds within chatrange.\n* if only 1 person nearby they autotargetted.\n* doesnt work on yourself",order_buttons(buttons),secretchannel); llSetObjectName(housename); // llSetTimerEvent(60); ALWAYS LISTENING ANYWAY } else if(message == "Eject") { state eject; } else if(message == "TP Home") { state tp_home; } else if(message == "Unsit") { state unsit; } else if(message == "Cancel") { state cancel; } else if(message == "Ban" && llGetOwner() == USERID) { state ban; } else if(message == "Ban" && llGetOwner() != USERID) { llSay(0,(string)USERID); llSetObjectName("SECURITY"); llSay(0,"sorry this is a owner only function."); llSetObjectName(housename); state default; } } } } Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted August 3, 2012 Share Posted August 3, 2012 I'm not sure if this is it, but In the following line, you set USERID to a string: USERID = llList2String(data, 1); Make sure USERID is a key when you declare it and try USERID = (key)llList2String(data, 1); Link to comment Share on other sites More sharing options...
Leander Tyles Posted August 3, 2012 Author Share Posted August 3, 2012 thnx for the responce, but unfortunatly didnt fix it Link to comment Share on other sites More sharing options...
Niall Braveheart Posted August 3, 2012 Share Posted August 3, 2012 If it only fails on the Ban option, then it might be because llGetOwner() returns a key and USERID is a string, so your comparing two different data types, which can cause problems. You're you're just trying to check that the listen event was triggered by the owner, then you can compare the id passed to the event to llGetOwner else if(message == "Ban" && id == llGetOwner() ) { state ban; } else if(message == "Ban" && id != llGetOwner() ) Link to comment Share on other sites More sharing options...
Leander Tyles Posted August 3, 2012 Author Share Posted August 3, 2012 thanks that fixed that particular hiccup, but it only leads to further complications because USERID was used for everything.... like in the ban state it was used to ensure the user wasnt stupid enough to ban himself for example. cant use ID thier because its not defined within scope ill post the complete code, but i know the problem is with that tiny snippet i posted earlier COMPLETE CODE integer secretchannel = -1000;key USERID;string housename;integer houserange = 40;integer notifyowner = TRUE;list buttons = ["Ban","Eject","Unsit","TP Home","Cancel"];list victims;integer listenvar;integer menu_handler; integer menu_channel;list order_buttons(list buttons){ return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) + llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);}default{ on_rez(integer start_param) { llResetScript(); housename = llGetObjectName(); } state_exit() { llSetTimerEvent(0.0); // unneccasery precuation } state_entry() { llSetObjectName(housename); if (USERID == NULL_KEY) llListen(secretchannel, "", "", "" ); else llListen(secretchannel, "", USERID, "" ); } timer() { llSetObjectName("SECURITY"); llSay(0,"took to long, timed-out"); llSetObjectName(housename); llSetTimerEvent(0.0); state default; } listen(integer channel, string name, key id, string message) { list data = llParseStringKeepNulls(message, ["|"], []); message = llList2String(data, 0); USERID = (key)llList2String(data, 1); if (channel == secretchannel) { if (message == "request:Security") { llSetObjectName("SECURITY MENU"); llDialog(USERID,"\nSECURITY MENU:\n\n* you have 60 seconds to make a choice.\n* issue cmds within chatrange.\n* if only 1 person nearby they autotargetted.\n* doesnt work on yourself",order_buttons(buttons),secretchannel); llSetObjectName(housename); // llSetTimerEvent(60); ALWAYS LISTENING ANYWAY } else if(message == "Eject") { state eject; } else if(message == "TP Home") { state tp_home; } else if(message == "Unsit") { state unsit; } else if(message == "Cancel") { state cancel; } else if(message == "Ban" && id == llGetOwner()) { state ban; } else if(message == "Ban" && id != llGetOwner()) { llSay(0,(string)USERID); llSetObjectName("SECURITY"); llSay(0,"sorry this is a owner only function."); llSetObjectName(housename); state default; }}}}// ALL CODE BELOW IS REPETITIVE //// TODO// * (localchatmsg) if avatar not llovermyland//-----------------state eject { on_rez(integer start_param) { llResetScript(); } state_entry() { llSensor("","",AGENT,houserange,PI); } state_exit() { llSetTimerEvent(0.0); } timer() { llSetObjectName("SECURITY"); llSay(0,"took to long, timed-out"); llSetObjectName(housename); llSetTimerEvent(0.0); listenvar = llListen(-11,"",USERID,""); llListenRemove(listenvar); state default; } sensor(integer num_detected) { if(num_detected > 1) { victims = []; integer i; for(i=0;i < num_detected;i++) { if(llDetectedKey(i) != USERID) { victims = victims + llDetectedName(i); } } if(i == num_detected) { llListen(-11,"",USERID,""); llDialog(USERID,"\nChoose Your Target",victims,-11); } } if(num_detected == 1 && llDetectedName(0) != llKey2Name(USERID)) { llSay(0,llDetectedName(0) + " has been ejected from parcel"); llEjectFromLand(llDetectedKey(0)); if (notifyowner == TRUE) { llSetObjectName("SECURITY CONTROL"); llInstantMessage(llGetOwner(),llKey2Name(USERID) + " [Ejected] " +llDetectedName(0)); llSetObjectName(housename); state default; } } if(num_detected == 1 && llDetectedName(0) == llKey2Name(USERID)) { state default; }} listen(integer channel,string name,key id,string message) { llSensor(message,"",AGENT,houserange,PI); } no_sensor() { llSay(0,"Nobody detected within " + (string)houserange +"m"); state default; } } state ban { on_rez(integer start_param) { llResetScript(); } state_entry() { llSensor("","",AGENT,houserange,PI); } state_exit() { llSetTimerEvent(0.0); // unneccasery precuation } timer() { llSetObjectName("SECURITY"); llSay(0,"took to long, timed-out"); llSetObjectName(housename); llSetTimerEvent(0.0); listenvar = llListen(-11,"",USERID,""); llListenRemove(listenvar); // unneccasery but good practise state default; } sensor(integer num_detected) { if(num_detected > 1) { victims = []; integer i; for(i=0;i < num_detected;i++) { if(llDetectedKey(i) != USERID) { victims = victims + llDetectedName(i); } } if(i == num_detected) { llListen(-11,"",USERID,""); llDialog(USERID,"\nChoose Your Target",victims,-11); } } if(num_detected == 1 && llDetectedName(0) != llKey2Name(USERID)) { llSay(0,llDetectedName(0) + " has been banned from parcel"); llAddToLandBanList(llDetectedKey(0),0); state default; // owner only feature so a pointless notification // if (notifyowner == TRUE) { // llSetObjectName("SECURITY CONTROL"); // llInstantMessage(llGetOwner(),llKey2Name(USERID) + " [banned] " +llDetectedName(0)); } if(num_detected == 1 && llDetectedName(0) == llKey2Name(USERID)) { state default; }} listen(integer channel,string name,key id,string message) { llSensor(message,"",AGENT,houserange,PI); } no_sensor() { llSay(0,"Nobody detected within " + (string)houserange +"m"); state default; } } state tp_home { on_rez(integer start_param) { llResetScript(); } state_entry() { llSensor("","",AGENT,houserange,PI); } state_exit() { llSetTimerEvent(0.0); } timer() { llSetObjectName("SECURITY"); llSay(0,"took to long, timed-out"); llSetObjectName(housename); llSetTimerEvent(0.0); llListenRemove(listenvar); state default; } sensor(integer num_detected) { if(num_detected > 1) { victims = []; integer i; for(i=0;i < num_detected;i++) { if(llDetectedKey(i) != USERID) { victims = victims + llDetectedName(i); } } if(i == num_detected) { listenvar = llListen(-11,"",USERID,""); llDialog(USERID,"\nChoose Your Target",victims,-11); llSetTimerEvent(60); } } if(num_detected == 1 && llDetectedName(0) != llKey2Name(USERID)) { llSay(0,llDetectedName(0) + " has been sent home"); llTeleportAgentHome(llDetectedKey(0)); if (notifyowner == TRUE) { llSetObjectName("SECURITY CONTROL"); llInstantMessage(llGetOwner(),llKey2Name(USERID) + " [sent Home] " +llDetectedName(0)); llSetObjectName(housename); state default; } } if(num_detected == 1 && llDetectedName(0) == llKey2Name(USERID)) { state default; }} listen(integer channel,string name,key id,string message) { llSensor(message,"",AGENT,houserange,PI); } no_sensor() { llSay(0,"Nobody detected within " + (string)houserange +"m"); state default; } } state unsit { on_rez(integer start_param) { llResetScript(); } state_entry() { llSensor("","",AGENT,houserange,PI); } state_exit() { llSetTimerEvent(0.0); } timer() { llSetObjectName("SECURITY"); llSay(0,"took to long, timed-out"); llSetObjectName(housename); llSetTimerEvent(0.0); llListenRemove(listenvar); state default; } sensor(integer num_detected) { if(num_detected > 1) { victims = []; integer i; for(i=0;i < num_detected;i++) { if(llDetectedKey(i) != USERID) { victims = victims + llDetectedName(i); } } if(i == num_detected) { listenvar = llListen(-11,"",USERID,""); llDialog(USERID,"\nChoose Your Target",victims,-11); llSetTimerEvent(60); } } if(num_detected == 1 && llDetectedName(0) != llKey2Name(USERID)) { llUnSit(llDetectedKey(0)); if (notifyowner == TRUE) { llSetObjectName("SECURITY CONTROL"); llInstantMessage(llGetOwner(),llKey2Name(USERID) + " [unsat] " +llDetectedName(0)); llSetObjectName(housename); state default; } } if(num_detected == 1 && llDetectedName(0) == llKey2Name(USERID)) { state default; }} listen(integer channel,string name,key id,string message) { llSensor(message,"",AGENT,houserange,PI); } no_sensor() { llSay(0,"Nobody detected within " + (string)houserange +"m"); state default; } } state cancel{ on_rez(integer start_param) { llResetScript(); } state_exit() { llSetTimerEvent(0.0); // unneccasery precuation } state_entry() { state default; }} Link to comment Share on other sites More sharing options...
Niall Braveheart Posted August 3, 2012 Share Posted August 3, 2012 If thats all you use USERID for then define it as a global variable (make sure its a key) and set it in the listen event USERID = id Link to comment Share on other sites More sharing options...
Leander Tyles Posted August 3, 2012 Author Share Posted August 3, 2012 lindens just restarted the sim so i cant get online to play around a mo but this is a plugin, another script contacts this one... sending the persons key so we know who to send the first dialog too since that part works i dont know at what stage i would use your method but i guess i could try creating more variables to hold the id yes Link to comment Share on other sites More sharing options...
Niall Braveheart Posted August 3, 2012 Share Posted August 3, 2012 Ah ok .... Well scanning the code quickly, the only time the USERID is in the body of the message will be when it's recieved from the other script, and it appears that only happens when thesecuruty menu requested, so maybe this will work listen(integer channel, string name, key id, string message) { list data = llParseStringKeepNulls(message, ["|"], []); message = llList2String(data, 0); USERID = id; llSay(0,(string)USERID); llSay(0,(string)llGetOwner()); if (channel == secretchannel) { if (message == "requestecurity") { USERID = (key)llList2String(data, 1); llSetObjectName("SECURITY MENU"); llDialog(USERID,"\nSECURITY MENU:\n\n* you have 60 seconds to make a choice.\n* issue cmds within chatrange.\n* if only 1 person nearby they autotargetted.\n* doesnt work on yourself",order_buttons(buttons),secretchannel); llSetObjectName(housename); // llSetTimerEvent(60); ALWAYS LISTENING ANYWAY } else if(message == "Eject") { state eject; } else if(message == "TP Home") { state tp_home; } else if(message == "Unsit") { state unsit; } else if(message == "Cancel") { state cancel; } else if(message == "Ban" && id == llGetowner() ) { state ban; } else if(message == "Ban" && id != llGetOwner() ) { llSay(0,(string)USERID); llSetObjectName("SECURITY"); llSay(0,"sorry this is a owner only function."); llSetObjectName(housename); state default; }}}} Link to comment Share on other sites More sharing options...
Rolig Loon Posted August 3, 2012 Share Posted August 3, 2012 I don't see the problem. USERID is defined globally, so it's within the scope of the entire script. Key type variables and string type variables are almost always interchangeable. The only time you need to be truly careful is when you want to guarantee that you really are using a valid key. You're most likely to run into problems if you have stored a UUID in a list and are reading it out. In those cases, it's often wise to typecast explicitly, as in..... key My_UUID = (key)llList2String(list_of_keys,0); It should be easy to do a global search for USERID through your script and make that small change where necessary. Read https://wiki.secondlife.com/wiki/Category:LSL_Key Link to comment Share on other sites More sharing options...
Ron Khondji Posted August 4, 2012 Share Posted August 4, 2012 The id in the first listen is not the same as the id that gets send back from the dialog. Either try this: listen(integer channel, string name, key id, string message) { list data = llParseStringKeepNulls(message, ["|"], []); message = llList2String(data, 0); USERID = (key)llList2String(data, 1); if (channel == secretchannel) { if (message == "requestecurity") { llSetObjectName("SECURITY MENU"); llDialog(USERID,"\nSECURITY MENU:\n\n* you have 60 seconds to make a choice.\n* issue cmds within chatrange.\n* if only 1 person nearby they autotargetted.\n* doesnt work on yourself",order_buttons(buttons),secretchannel); llSetObjectName(housename); // llSetTimerEvent(60); ALWAYS LISTENING ANYWAY } else if(message == "Eject") { USERID = id; state eject; } else if(message == "TP Home") { USERID = id; state tp_home; } else if(message == "Unsit") { USERID = id; state unsit; } else if(message == "Cancel") { USERID = id; state cancel; } else if(message == "Ban" && id == llGetOwner()) { USERID = id; state ban; } else if(message == "Ban" && id != llGetOwner()) { llSetObjectName("SECURITY"); llSay(0,"sorry this is a owner only function."); llSetObjectName(housename); state default; } } }} Or use a different listen channel for your dialog. (I hope that´ll do it ) Link to comment Share on other sites More sharing options...
Ela Talaj Posted August 8, 2012 Share Posted August 8, 2012 Your listen event is very badly coded. Rewrite like this: listen(integer channel, string name, key id, string message){ list data = llParseStringKeepNulls(message, ["|"], []); message = llList2String(data, 0); USERID = llList2String(data, 1); llSay(0, USERID); llSay(0, (string)llGetOwner()); if (channel != secretchannel) return; if (message == "request security") { llSetObjectName("SECURITY MENU"); llDialog(USERID,"\nSECURITY MENU:\n\n* you have 60 seconds to make a choice.\n* issue cmds within chatrange.\n* if only 1 person nearby they autotargetted.\n* doesnt work on yourself",order_buttons(buttons),secretchannel); llSetObjectName(housename); // llSetTimerEvent(60); ALWAYS LISTENING ANYWAY return; } if(message == "Eject") state eject; if(message == "TP Home") state tp_home; if(message == "Unsit") state unsit; if(message == "Cancel") state cancel; if(message != "Ban") return; if(llGetOwner() == (key)USERID) state ban; llSay(0, USERID); llSetObjectName("SECURITY"); llSay(0,"sorry this is a owner only function."); llSetObjectName(housename); state default; } Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now