Jump to content

Box script (Notecard Giver + float text + unpacker + autodelete)


EsePibe Borkotron
 Share

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

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

Recommended Posts

      If the owner of the box is also its creator, the script works as a notecard giver and show in float text the name of object and the description I use the description to put the price but you can put other content.

    The notecard for delive have the name  "__" + objectName. For example, if the box have the name "Pink panty boxed" the notecard must have the name "__Pink panty boxed".

     If the owner of the box is not the creator, that is, a customer. The script is a unpacker and will autodelete in 120 seconds.

     Edited: This script is not to be used with no copy objects, or the client may lose its purchasing.

 

integer TIME_TO_DIE = 120;
integer g_iTimeToDie;

default {
    
    state_entry() {
        
        llSetMemoryLimit(4096 * 3);
        
        llSetText(
            llGetObjectName() + "\n" + 
            llGetObjectDesc() + 
            "\nTouch here for info", <1, 1, 1>, 1);
            
        if (llGetOwner() != llGetCreator()) {
            state NewOwner;
        } // if
            
    } // state_entry
    
    on_rez(integer start_param) {
        
        llResetScript();
        
    } // on_rez

    touch_start(integer total_number) {
        
        llGiveInventory(llDetectedKey(0), "__" + llGetObjectName());
        
    } // touch_start
    
    changed(integer change) {
     
        if (change & CHANGED_OWNER) {
            state NewOwner;
        } // if
        
    } // changed
    
} // default

state NewOwner {
    
    state_entry() {
        
        g_iTimeToDie = TIME_TO_DIE;
        llSetTimerEvent(1.0);
        
    } // state_entry
    
    on_rez(integer start_param) {
        
        g_iTimeToDie = TIME_TO_DIE;
        llSetTimerEvent(1.0);
        
    } // on_rez
    
    touch_start(integer total_number) {
        
        if (llDetectedKey(0) != llGetOwner()) {
            return;
        } // if
        
        llSetTimerEvent(0.0);
        llSetText("unpacking.....", <1.0, 1.0, 1.0>, 1.0);
        
        list lInventory;
        integer iCounter;
        integer iNumItems = llGetInventoryNumber(INVENTORY_ALL);
        string sName;
        
        for (iCounter = 0; iCounter < iNumItems; iCounter++) {
            
            sName = llGetInventoryName(INVENTORY_ALL, iCounter);
            if (sName != llGetScriptName()) {
                lInventory += [sName];
            } // if
            
        } // if
        
        if (llGetListLength(lInventory) > 0) {
            llOwnerSay("Search in your inventory one folder with name " +  llGetObjectName());
            llGiveInventoryList(llGetOwner(), llGetObjectName(), lInventory);
        } else {
            llOwnerSay("Sorry, box is empty!");
        } // if
        llSetTimerEvent(1.0);
        
    } // touch_start
    
    timer() {
        
        g_iTimeToDie -= 1;
        llSetText(
            "Touch me to unpack.\nThis box will be autodeleted in " + (string) g_iTimeToDie + " seconds.", 
            <1.0, 1.0, 1.0>, 
            1.0);
        
        if (g_iTimeToDie <= 0) {
            llDie();
        } // if
        
    } // timer
    
} // NewOwner

 

Link to comment
Share on other sites

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