//Gives a random object from inventory when the scripted-object is touched. Does not charge money, items MUST be "objects" i.e. clothing needs to be boxed.
default
{
state_entry()
{
llAllowInventoryDrop(TRUE);
llSetSitText("Grab!"
;llSitTarget(<0,0,1>, <0,0,0,0>
;}
changed(integer change)
{
if(change & CHANGED_LINK)
{
key avataronsittarget = llAvatarOnSitTarget();
if(avataronsittarget!=NULL_KEY)
{
if((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget){
llStopAnimation("sit"
;llStartAnimation("dumpster"
;llSay(0, "You start exploring the contents of the dumpster..."
;state diving;
}
else
{
llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);
}
}
}
}
run_time_permissions(integer perm)
{
if(perm)
{
llStopAnimation("sit"
;llStartAnimation("stand"
;}}
}
state diving
{
state_entry()
{
llSetTimerEvent(10.0);
}
timer()
{
llSay(0, "You find unexpected treasure!"
;integer content = llGetInventoryNumber(INVENTORY_OBJECT);
float rand = llFrand(content);
llGiveInventory(llAvatarOnSitTarget(), llGetInventoryName(INVENTORY_OBJECT, (integer)rand));
llStopAnimation("dumpster"
; llSetTimerEvent(0);
llUnSit(llAvatarOnSitTarget());
llResetScript();
}
}
anybody have advice? I'd love to make it work, since the dumpsters sold on SLX are no-mod.
