I'm having trouble getting my head around the (llSameGroup(llDetectedKey(0)) in a mailbox script I'm trying to write, and I'm sure I must just be missing something simple again. I consulted the example on the wiki, and tried to do the same, but with a listen instead of touch_start. The listen's working (if I disable the if/else that checks the group, the message entered on channel 9 is hovertexted and emailed ok,) but llSameGroup(llDetectedKey(0)) seems to always return FALSE, even when I am definitely wearing the same group tag as the object is set to.
Am I just fundamentally misunderstanding how to implement the function? Or have I failed to typecast a variable properly somewhere? (that still confuses me sometimes.)
Any more expert advice would be very gratefully received.
integer position;
string avname;
string message;
string EMAIL = "whatever@somewhere.com";
default
{
touch_start(integer total_number)
{
}
state_entry()
{
llSetText("Waiting for message", <1.0,1.0,1.0>, 0.5);
llListen( 9, "", NULL_KEY, "" );
}
listen( integer channel, string name, key id, string message )
{
if (channel == 9) {
if(llSameGroup(llDetectedKey(0)))
{
string messageName = llKey2Name(id);
llSay( 0, "Thankyou, " + (string)messageName + ", your message has been sent."
;llSetText((string)message, <1.0,1.0,1.0>, 1.0); //TEMP TO TEST
string mailbody = message + " (" + messageName + "
";llEmail (EMAIL, "New message recorded", (string)mailbody);
}
else
{
llSay(0, "Wrong active group! If you belong to the group this object is set to, please activate your group tag. Otherwise please join the group."
;}
}
}
}
