Cleanup Script 2

Written by: Headmaster

This version will let you know when it is done cleaning up.

 

// Delete all scripts in an object

integer lhook;
list scripts;

alInit(integer argi)
{
    if (lhook)
    {
        llListenRemove(lhook);
    }
    llOwnerSay("Deleting scripts....");
    integer num = llGetInventoryNumber(INVENTORY_SCRIPT);
    integer i;
    for (i = 0; i < num; i = i + 1)
    {
        string tmps = llGetInventoryName(INVENTORY_SCRIPT,i);
        if (tmps != llGetScriptName())
        {
            scripts = scripts + [ tmps ];
        }
    }
    for (i = 0; i < llGetListLength(scripts); i = i + 1)
    {
        llRemoveInventory(llList2String(scripts,i));
    }
    llOwnerSay("Done!");
    llRemoveInventory(llGetScriptName());
}

default 
{
    on_rez(integer p) 
    {
        // Reset, to get rid of stale listen handler.
        llResetScript();
    }
    state_entry()
    {
        alInit(0);
    }
}

 

Category: