Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Adding owner only control?

Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
07-10-2009 15:21
The wiki keeps telling me page not found, so I'll turn to the forums for this. I managed to put a script together to play a sound on click. I'd like to set it up so only the owner can turn it off and on.
This is what I'm using.

CODE


integer playing = FALSE;
default {
touch_start(integer x) {
if (playing) llStopSound();
else llLoopSound("drone", 1.0);
playing = !playing;
}
on_rez(integer start_param)
{
llResetScript();
}
}

Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
07-10-2009 15:28
just a check of the key touching with the owner of the objects key. This is done simply

CODE

integer playing = FALSE;
default
{
touch_start(integer x)
{
if(llDetectedKey(0) == llGetOwner())
{
if (playing)
{
llStopSound();
}
else
{
llPlaySound("drone", 1.0);
}
playing = !playing;
}
}
}


Yes I'm rather anal about my brackets, but makes for easy reading code, especially in examples :)
Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
07-10-2009 15:34
Now, my other concern is making sure it detects the new owner when I sell or give the object to someone. Shouldn't the reset script call be left in there, for that issue? I'm trying to fit it in, but it won't compile. I think I'm locating brackets in the wrong places.
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
07-10-2009 15:43
You don't need a reset command for somehting like that,each time it's touched it checks the owner, llGetOwner returns the key of the owner, but it is not assigning it to any variable.
Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
07-10-2009 15:44
Awesome. Thank you.