Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Script Needed: Delayed Give on sit.

Ziggy Quirk
Registered User
Join date: 5 Sep 2004
Posts: 57
10-13-2007 01:28
Sorted, thanks.
Finkel Flossberg
Registered User
Join date: 25 Nov 2006
Posts: 23
10-13-2007 03:03
From: Ziggy Quirk
I'm looking for a script that will wait 60 seconds after someone sits on the object, and then give them one of the objects in inventory at random.

So for example, I have 5 objects in the inventory of the prim, someone wanders along and sits on it. 60 seconds later, they get one of the objects from the prim, but not the same one every time.

Does that make sense? I'd need the script with at the very least copy/trans perms and it would be sold on as trans only inside an object.
Can you help? Please?? I have monies! Please IM me in world if you can rustle me up something like this :D



I have sent you an IM in-world.
Anthalia Nemeth
Registered User
Join date: 8 Mar 2007
Posts: 17
10-13-2007 06:35
This should do what you want

CODE

// Give an item to the sitter after X seconds
// Created by GarrMe Dagger 10.13.07

float fTime = 60.0; // Time to wait before giving a random item in seconds


key avatar = NULL_KEY;
integer SITTING = FALSE;
default
{
state_entry()
{
llSitTarget(<0, 0, 0.1>, ZERO_ROTATION);
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
if (SITTING == FALSE)
{
avatar = llAvatarOnSitTarget();
llSetTimerEvent(fTime);
SITTING = TRUE;
}
else if (SITTING)
{
avatar = NULL_KEY;
SITTING = FALSE;
llSetTimerEvent(0.0);
}
}
}
timer()
{
if (avatar != NULL_KEY)
{
integer items = llGetInventoryNumber(INVENTORY_OBJECT);
llGiveInventory(avatar, llGetInventoryName(INVENTORY_OBJECT, (integer)llFrand(items) - 1));
llUnSit(avatar);
SITTING = FALSE;
llSetTimerEvent(0.0);
}
else llSetTimerEvent(0.0);
}
}