Jump to content
Natalie Oe

Adding Notecard Query

Recommended Posts

Hi All,

I am using the following script which, the original post for it was from 2013 so I didn't want to bump it. But I'm trying to modify it so that the price of the item (integer gPrice) is set via a config notecard. I've been trying for a few hours but scripting is not my area of expertise.

Can anyone advise further (or recommend a scripter?)

Thank you,

// Give Inventory List with Split payout  --  Rolig Loon  -- November 2010

//  OWNER:   Specify each of the following parameters

integer gPrice = ; // Price of your item
key gSplitKey= NULL_KEY; // UUID of the person to whom you are giving a split
float gSplitPct = 0.4; // Percentage of the split (0.0 to 1.0)

default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
    }

    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_DEBIT)
        {
            state purchase;
        }
    }

    changed(integer change)
    {
        if(change & CHANGED_INVENTORY)
        {
            llResetScript();
        }
    }
}

state purchase
{
    state_entry()
    {
        llSetPayPrice(PAY_HIDE, [gPrice,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
        llSetClickAction(CLICK_ACTION_PAY);
    }

    changed(integer change)
    {
        if(change & CHANGED_INVENTORY)
        {
            llResetScript();
        }
    }

    money (key id, integer amount)
    {
        if (amount == gPrice)
        {
            list        inventory;
            integer     num = llGetInventoryNumber(INVENTORY_ALL);
            string      script = llGetScriptName();
            integer     i = 0;
            for (; i < num; ++i) {
                string name = llGetInventoryName(INVENTORY_ALL, i);
                if(name != script)
                {
                    if(llGetInventoryPermMask(name, MASK_OWNER) & PERM_COPY)
                    {
                        inventory += name;
                    }
                    else
                    {
                        llSay(0, "Don't have permissions to give you \""+name+"\".");
                    }
                }
            }
            if (llGetListLength(inventory) >= 1)
            {
                llGiveInventoryList(id, llGetObjectName(), inventory);
                llInstantMessage(id,"Thank you for your purchase. Your new items are now in your inventory in a folder named " +llGetObjectName());
            }
            if (gSplitKey != NULL_KEY)
            {
                integer Payout = (integer) (amount*gSplitPct);
                llGiveMoney(gSplitKey,Payout);
            }
        }
    }
}

 

Share this post


Link to post
Share on other sites

You can certainly add a notecard reading function without much trouble but frankly that's overkill.  It would be much simpler to just read the price from the object's description field. I would write a simple bit of code for you now but I am out of town and can't script on my cell phone. It's basically a one or two line change,  though,  so anyone else here can write it for you. 

Share this post


Link to post
Share on other sites

its a one line addition Natalie to do what Rolig suggests

state purchase
{
    state_entry()
    {
        // add line here to read gPrice from the object's description
        gPrice = (integer)llGetObjectDesc();

        llSetPayPrice(PAY_HIDE, [gPrice,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
        llSetClickAction(CLICK_ACTION_PAY);
    }

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Ok So I went in and added the line, in the exact position you did and now it is throwing me a syntax error at this field 

integer gPrice = ; // Price of your item

Do I just delete that line entirely?

Share this post


Link to post
Share on other sites

no. Don't delete. Tthe script needs the global gPrice variable.  Change that line to:  integer gPrice;     (remove the equals sign and keep the semi-colon)

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.


×
×
  • Create New...