Jump to content

llAvatarOnSitTarget issue


Silvarian Ort
 Share

You are about to reply to a thread that has been inactive for 4706 days.

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

Recommended Posts

I have this script that when an avatar sits on it , it will send out a message. The problem is that it is only speaking to the owner and i need it to speak to anyone who sits on the object with this script in it. Can someone please help me with this darn thing into getting the message to speak to anyone who sits on the object and not just the owner? Thanks.

key agentKey = NULL_KEY;
integer permissionResult = FALSE;
string theAnim = "sit";
string sitText = "sit";
vector sittingPosition = <-0.1,0.0,-0.2>;

init()
{
    //Change the text shown on the pie menu to what we've specified in sitText
    llSetSitText(sitText);
       llSitTarget(sittingPosition,<0,0,0,1>);
}

default
{
   
    state_entry()
    {
        init();
    }
      
    on_rez(integer times)
    {
        init();
}

    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key agent = llAvatarOnSitTarget();
            
            if ( agentKey != NULL_KEY && agent == NULL_KEY) {
                
                agentKey = agent;
                 {

}
               
                llRequestPermissions(agentKey,PERMISSION_TRIGGER_ANIMATION);
            } else if ( agentKey != NULL_KEY && agent == NULL_KEY) {
                
                if (permissionResult) {
                  
                    llStopAnimation(theAnim);
            
                }
               
                llResetScript();
            }
    }        
   }


    run_time_permissions(integer value)
    {
 
    if (value == PERMISSION_TRIGGER_ANIMATION)
    {
        permissionResult = TRUE;
        llStopAnimation("sit");
        llStartAnimation(theAnim);
                                 
    }
        llSetTimerEvent(10.0); // generate a timer event every 1 second
    }
    
    timer()
    {
               
            llSay(2,"bleh");
      }
    }

Link to comment
Share on other sites

I don't understand what you mean about the thing only talking to the owner. 

As it is, the the only talking it does that I can see is it says "bleh" every 10 seconds on channel 2.    It's not saying it to anyone in particular -- anyone in earshot wearing some device that listens on channel 2 and and repeats the message via llOwnerSay will hear it.

If you want it to talk to the person sitting on it (i.e. agentKey), simply put 

llRegionSayTo(agentKey,0, "You're sitting on me"); 

in the timer event, or whever you want it.   It will appear as green chat to agentKey but no one else will see it.

ETA -- I would use llRegionSayTo in preference to llInstantMessage when I know the avatar is going to be on the same sim as the object (which isn't an issue here) because llInstantMessage sleeps the script for 2 seconds each time its called and llRegionSayTo doesn't.

Link to comment
Share on other sites

Sorry if i am not clear.. I am making a hud and this script is going to speak to anyone wearing that hud that sits on the object. The hud is suppost to listen for that message then perform an action and no its not bleh ..its going to be something else when i complete the hud. The problom i am having is that when me and somone else that is helping me test this script sits down on the object it is only speaking to me and not his hud...it only speaks to his hud if he owns the object but i need it to speak to anyone that sits on this object that has this script inside of it. Sorry ..i hope this was more clear and thanks for helping. :3

Link to comment
Share on other sites

Here's a simple script for the seat....

stopAnim(){    list temp = llGetAnimationList(gAv);    integer i = (temp !=[]);    while(~(--i))    {        llStopAnimation(llList2String(temp,i));    }}key gAv;default{    state_entry()    {        llSitTarget(<0.0,0.0,0.5>,ZERO_ROTATION); //Change this sit target as necessary    }    changed (integer change)    {        if (change & CHANGED_LINK)        {            if(llAvatarOnSitTarget()) //When Av sits down....            {                gAv = llAvatarOnSitTarget();                llRequestPermissions(gAv,PERMISSION_TRIGGER_ANIMATION);            }            else  // When Av stands up ....            {                llRegionSayTo(gAv,-47102,"Good Bye!");  //Message to HUD script            }        }    }            run_time_permissions(integer perm)    {         if(perm & PERMISSION_TRIGGER_ANIMATION)        {            stopAnim();            llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));            llRegionSayTo(gAv,-47102,"Hello!"); //Message to HUD script        }    }}

 And here's an accompanying HUD script ....

default{    state_entry()    {        llListen(-47102,"","","");    }    listen(integer channel, string name, key id, string msg)    {        if(msg == "Hello!") // The sit down message        {            llSetColor(<0.0,1.0,0.0>,ALL_SIDES);        }        else if (msg == "Good Bye!") // The standup message        {            llSetColor(<1.0,0.0,0.0>,ALL_SIDES);        }    }}

 The trick here is that the llRegionSayTo function speaks to an attachment that the av is wearing (the HUD in this case) if the message is sent on a non-zero channel.  Because the message is aimed at the AvatarOnSitTarget, the only HUD that will hear it is the one being worn by that particular av.

Link to comment
Share on other sites

Thanks but thats not what i need :/...thanks for trying tho. I already have a hud script built that is going t recieve the message. That script i posted is what i need moded to just talk to the person sitting down on the object. It also needs to say that message over ...and over again for what i am making it for. Sorry for being difficult ..but that script wont work with what i am doing. So i need that repeating timer and there and it only needs to talk or llsay when the person sits on it not when it gets off :3.

Link to comment
Share on other sites

So, if you want it to talk to the person, do exactly what Innula and the others suggested.   Use llRegionSayTo on the public chat channel instead of on the non-zero channel I chose.  It will speak to the sitting av instead of her attached HUD.  No big deal.

And if you want to send the same annoying message over and over again, trigger a timer event with the message in it as soon as the av sits down.

ETA:  As I read your message again, it seems to imply that you and some other person are both planning to sit on the object at the same time.  You can only have one sit target in a prim, so the person identified by the script as llAvatarOnSitTarget will be the person who gets there first. An additional person on the same prim is not on the sit target, so will not be interacting with the script.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4706 days.

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
 Share

×
×
  • Create New...