Jump to content
Sign in to follow this  
EsePibe Borkotron

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

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

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...