Jump to content

Play sound on chat command


Rafael Tower
You are about to reply to a thread that has been inactive for 1696 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

// www.lsleditor.org  by Alphons van der Heijden (SL: Alphons Jano)
integer listener;

integer channel = 7;
string msg = "play";
string soundName = "sound";

default
{
    state_entry()
    {
        listener = llListen(channel,"","",msg); 
    }

    listen(integer channel, string name, key id, string message)
    {
        llPlaySound(soundName,1.0);
    }
}

This is from the archive. But how to restric this script to owner only. (The sound will play only when something that belongs to owner emits the message.

Link to post
Share on other sites

// www.lsleditor.org  by Alphons van der Heijden (SL: Alphons Jano)

integer listener;

 

integer channel = 7;

string msg = "play";

string soundName = "sound";

key ownerid;

 

default

{

state_entry()

{

ownerid = llGetOwner();//just the way i prefer

listener = llListen(channel, "", ownerid, "");

//listener = llListen(channel, "", llGetOwner(), "");// can do it this way also

}

 

listen(integer channel, string name, key id, string message)

{

llPlaySound(soundName,1.0);

}

}

Link to post
Share on other sites

and when I use this

// www.lsleditor.org  by Alphons van der Heijden (SL: Alphons Jano)integer listener;integer channel = 7;string msg = "play";string soundName = "sound";key        ownerid;default{	state_entry()	{		listener = llListen(channel, "", ownerid, "");		//listener = llListen(channel, "", llGetOwner(), "");// can do it this way also	}	listen(integer channel, string name, key id, string message)	{		llPlaySound(soundName,1.0);	}}

It still plays a sound but from people's objects too.

Link to post
Share on other sites

Rather than  rewrite read Roligs explaination

https://community.secondlife.com/t5/LSL-Scripting/llPlaySound-or-llTriggerSound/td-p/2334469

Short answer is if the object is stationary use llTriggerSound else use llPlaySound if it is moveing, BTW you can limit the sound broadcast by using llTriggerSoundLimited. that will restrict the sound to a hard cut off

Link to post
Share on other sites

Try this instead:

// www.lsleditor.org  by Alphons van der Heijden (SL: Alphons Jano)integer listener;integer channel = 7;string msg = "play";string soundName = "sound";default{    state_entry()    {        listener = llListen(channel,"","",msg);     }    listen(integer channel, string name, key id, string message)    {
if ( llGetOwnerKey( id) == llGetOwner() ) llPlaySound(soundName,1.0); }}

Will only play on messages from an object with same owner

:smileysurprised::):smileyvery-happy:

Link to post
Share on other sites

The llListen is allready set to owner only communications

This clearly states that limit.

ownerid = llGetOwner();//just the way i prefer		listener = llListen(channel, "", ownerid, "");		//listener = llListen(channel, "", llGetOwner(), "");// can do it this way also
Link to post
Share on other sites

This is the OPs and by agent chat on  channel 7 and not by an object.

" But how to restric this script to owner only. (The sound will play only when something that belongs to owner emits the message."

 listenHandle = llListen(0, "", llGetOwner(), "");    }     listen(integer channel, string name, key id, string message)    {//      we filtered to only listen on channel 0//      to the owner's chat in the llListen call above
Link to post
Share on other sites


steph Arnott wrote:

This is the OPs and by agent chat on  channel 7 and not by an object.

" But how to restric this script to owner only. (The sound will play only when
something that belongs to owner
emits the message."

Something that belongs to the owner is an object

An object and an Avatar do NOT have the same id, so when you filter for the Avatar id only, no messages with any other id comes through and nothing that belongs to the owner can trigger the sound

:smileysurprised::):smileyvery-happy:

 

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...