Jump to content

Needing script help sit/item give


Sumomo Cheri
 Share

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

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

Recommended Posts

OK so basically this is what I'm trying for , i got an item that already has a wicked animation in it  when you sit on it , I'm trying to added a simple side script to give any one who sits down an item , great for quest , hunts of the such  like saying sit on the sword and stone watch as it draws it sword ... then side script  that I'm working to get to work if at all possible have it detect avatar sitting and give them an object  by name

 

default
{
    state_entry()
    {
    }
 changed(integer change) {
        if (change & CHANGED_LINK)
        {
            key agent = llAvatarOnSitTarget();
                llGiveInventory(llDetectedKey(0),"Object");
            }
        }
    }

 this saves with no Errors and as a novice scripter i though i nailed it at first .... but it fails to not only recognize you have sit down but fails to give anything. so i anyone will point me in the right direction i will greatly appreciate it

Link to comment
Share on other sites

Almost!

llDetectedkey() only works in certain event handlers, like touch(), sensor, collision events.

However, you already assigned the key of the sitting avatar to the key agent variable, with llAvatarOnSitTarget(). That's the function which returns the avatars key who is sitting on the prims llSitTarget().

To make llAvatarOnSitTarget() return the key and not just NULL_KEY, the prim must have a valid llSitTarget() set. Which will be a sit target with a non zero vector as the offset, like llSitTarget(<0.0,0.0,0.1>, ZERO_ROTATION);

Sit target is a prim property, so if you have set one from another script already, llAvatarOnSitTarget() will work correctly.

I have added a few more lines which will check if the avatar is actually sitting, and not just stood up, and to limit the object giver to give the object only once to the avatar, and not again if another avatar sits down on the same object, with the first avatar still sitting.

 

integer giSitting = FALSE;default{    state_entry()    {        //llSitTarget(<0.0,0.0,0.1>, ZERO_ROTATION);    }        changed(integer change) {                if (change & CHANGED_LINK)        {            key agent = llAvatarOnSitTarget();            if (agent != NULL_KEY) // Check if the avatar is sitting, and not just stood up.            {                if (giSitting == FALSE)                {                    llGiveInventory(agent, "Object");                    giSitting = TRUE;                }            }            else             {                giSitting = FALSE;            }        }    }}

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3468 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...