Jump to content

Split Payment Vendor


Rolig Loon
 Share

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

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

Recommended Posts

If you want to divide the income from a sale or from tips between two people, you need a Split Pay Vendor. Here's one way to do it. This one will give everything in its inventory (except this script) to the buyer and will then direct half of the purchase price to the avatar that you identify in the gSplitKey variable at the top of the script.  If there are no inventory items, it acts as a donation/tip jar.

 

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

//  OWNER:   Specify each of the following parameters

integer gPrice = 1000; // Price of your item
key gSplitKey= NULL_KEY; // UUID of the person to whom you are giving a split
float gSplitPct = 0.0; // 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);
			}
		}
	}
}

Updated to correct minor coding error.

 

  • Like 3
Link to comment
Share on other sites

  • 3 months later...
  • 1 year later...

I moddes Rolig's script into a multi-split vendor. You can now specify as many splits as you want using the two lists at the top of the script. I also added a refund, if the wrong amount is payed.

It's untested.

// Give Inventory List with Split payout  --  Rolig Loon  -- November 2010//Tweaked into multi split by Dakie Minotaur, July 2012//  OWNER:   Specify each of the following parametersinteger gPrice = 1000; // Price of your itemlist gSplitKeys= []; // list of UUIDs of the persons to whom you are giving a splitlist gSplitPct = []; // list of percentages of the splits (0.0 to 1.0); each percentsge corresponds to a person at the same position in the list//global variables not to be touchedinteger giSplitOn;default{	state_entry()	{				//added by DM check the persentages and the list of keys		if (llGetListLength(gSplitKeys)) {			giSplitOn = 1;			if (llGetListLength(gSplitKeys) != llGetListLength(gSplitPct)) {				llOwnerSay("The number of receivers of a split and the number of percentages " +				            "do not correspond. Splitting will be turned of.");				giSplitOn = 0;			} else {				integer i;				float splitsSum;				for (i = 0; i < llGetListLength(gSplitPct); i++) {					splitsSum += llList2Float(gSplitPct, i);				}				if (splitsSum > 1.0) {					llOwnerSay("The total of the splits is greater than 1. Splitting will be turned of.");					giSplitOn = 0;				}			}		}		if (giSplitOn) {			llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);		} else {			state purchase;		}	}	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 (giSplitOn)			{				for (i = 0; i < llGetListLength(gSplitKeys); i++) {					integer Payout = (integer) (amount*llList2Float(gSplitPct, i));					llGiveMoney(llList2Key(gSplitKeys, i),Payout);				}			}		} else {			llGiveMoney(id,amount);			llInstantMessage(id,"The amount payed does not equal the price of the merchandise (" + (string)gPrice + " L$)");			}	}}

 

  • Like 1
Link to comment
Share on other sites

thank you for that, I did figure it out, I do have trouble logging into the site hence the delay, I found the script works for two so far, I have changed the amount and I still get the previous amount showing, I have reset scripts, checked the General Tab was not set, not sure why it does not update to the new price

Link to comment
Share on other sites

That's odd.  I tested it myself just now and Darkie's version works fine.  I changed the price three times just to be sure.

When you change the price, be sure that you simply change that one number in the line that says

integer gPrice = 1000; // Price of your item

Don't change anything else, including the punctuation.You don't have to Reset the script.  When you click Save, it does that automatically.  BTW, it shouldn't make any difference how the click action is set on the General page of your Edit tool.  The script resets it to CLICK_ACTION_PAY anyway.

  • Like 1
Link to comment
Share on other sites

ok I just tried it in one prim and the price changes, I was hoping to be able to use it in furniture but it seems it has to be in the root prim for the price to change, I wanted ease of use for visitor to sit /use menus but to pay the back of the chair which is not the root prim

Link to comment
Share on other sites

That's true.  If you look in the LSL wiki, you'll find the advice that "This function [llSetPayPrice] only works when called from the root prim of an object. Its effect applies to all the prims in the object. Calling it from a child prim has no effect." 

You really have only that one choice: put the script in the root prim.  There are several ways to modify the script to make it accept payment only if you click on the back of the chair.  Unfortunately, though, they will each involve forcing the user to touch the chair twice... once to activate the section of the script labeled state running, and a second time to open the PAY window and request payment.  Otherwise, because the script is normally in state running when a user finds it, a touch anywhere opens that PAY window. 

 

Link to comment
Share on other sites

Here my modest improvement.

 

// Give Inventory List with Split payout  --  Rolig Loon  -- November 2010//Tweaked into multi split by Dakie Minotaur, July 2012// Added a sales report to owner via IM  with the store, product, amount and buyer's identification. (Put in the object's Desc the store's name or its identificator). by Gabonux Resident - August 2012//  OWNER:   Specify each of the following parametersinteger gPrice = 1; // Price of your itemlist gSplitKeys= []; // list of UUIDs of the persons to whom you are giving a splitlist gSplitPct = []; // list of percentages of the splits (0.0 to 1.0); each percentsge corresponds to a person at the same position in the list//global variables not to be touchedinteger giSplitOn;string mStore;key owner;default{    state_entry()    {        // added by Gabonux        owner=llGetOwner();        mStore = llGetObjectDesc();         //added by DM check the persentages and the list of keys        if (llGetListLength(gSplitKeys)) {            giSplitOn = 1;            if (llGetListLength(gSplitKeys) != llGetListLength(gSplitPct)) {                llOwnerSay("The number of receivers of a split and the number of percentages " +                            "do not correspond. Splitting will be turned of.");                giSplitOn = 0;            } else {                integer i;                float splitsSum;                for (i = 0; i < llGetListLength(gSplitPct); i++) {                    splitsSum += llList2Float(gSplitPct, i);                }                if (splitsSum > 1.0) {                    llOwnerSay("The total of the splits is greater than 1. Splitting will be turned of.");                    giSplitOn = 0;                }            }        }        if (giSplitOn) {            llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);        } else {            state purchase;        }    }    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, llKey2Name(id) +" Thank you for your purchase. Your new items are now in your inventory in a folder named " +llGetObjectName());                                // added by Gabonux                llInstantMessage(owner,llKey2Name(id) + " has purchased a " + llGetInventoryName(INVENTORY_OBJECT,0) + " for L$"  + (string)gPrice + " in " + mStore);            }            if (giSplitOn)            {                for (i = 0; i < llGetListLength(gSplitKeys); i++) {                    integer Payout = (integer) (amount*llList2Float(gSplitPct, i));                    llGiveMoney(llList2Key(gSplitKeys, i),Payout);                }            }        } else {            llGiveMoney(id,amount);            llInstantMessage(id,"The amount payed does not equal the price of the merchandise (" + (string)gPrice + " L$)");            }    }}

 

Link to comment
Share on other sites

  • 5 years later...

Hello,

This is a great script - how would you configure it so that anyone who pays into an object pays the owner say 10% (tax) of the amount they are paying?

Again, thank you for this excellent script and any advice.

Regards.

John

Edited by jbc71
Needed to turn on notify me of replies
Link to comment
Share on other sites

6 hours ago, jbc71 said:

how would you configure it so that anyone who pays into an object pays the owner say 10% (tax) of the amount they are paying?

I don't understand the question.  After all, when anyone pays L$ to a vendor, the entire amount goes automatically to the vendor's owner.  A split payment vendor simply takes part of that amount and then sends it to someone else. 

Link to comment
Share on other sites

Okay, let me try and clarify the question -  I am looking for a script that would allow me to collect the tax and not split it with anyone else.  Example, object is placed on land, land owner pays into object L$200 I keep 10% - what commands do I use in the script for this please?  Thanks again for you time and also reply.

Link to comment
Share on other sites

OK, then, let me try to clarify the answer.  Whoever owns a vendor always gets the entire amount of L$ that anyone deposits in it.  The only way that a second person gets any L$ from it is if there is a script in the vendor (a split vendor script) that turns around and sends a part of the L$ from the vendor's owner to that second person.  You could have a vendor that splits the L$ among more than two people, too.  It's the same principle: whoever owns the vendor receives 100% of whatever is paid into it, and the script redistributes a portion of that total to the other people.

In your case, you have not explained who owns the vendor.  The landowner pays L$200 into it, the vendor pays you L$10 of that, and who gets the rest?  Presumably whoever owns the vendor, but who is that?  Obviously not the landowner.  He's just dropping L$ into it.  Also obviously not you.  You want the vendor to pay you 10%.  So... who owns the vendor and gets to keep the other 90%?

No matter what your answer is, the solution is still the same: you create a simple split vendor -- or use this one.  Give it to whoever is supposed to keep the 90% and ask that person to designate you as the recipient of the 10% split.

 

Edited by Rolig Loon
Link to comment
Share on other sites

Let me see if I have this right. Please correct any mistakes in understanding:

  1. Land Owner pays Object some amount of money (example: L$200)
  2. Object sends you 10% of the amount paid by Land Owner (example: L$20)
  3. Object records that 90% of the amount paid is now available for Payouts and Rewards (example: L$180)

At some time in the future the Land Owner can command the Object to send some amount of L$ to a 3rd party recipient. For example as an award or some sort of incentive payout. The purpose isn't important, only that the Land Owner can command the Object to send money to someone else .. but only if that amount is in the "Payouts and Rewards" account.

That "Payouts and Rewards" account is nothing more than a balance sheet that remembers how much was "deposited" .. and thus will only allow paying out from the current balance of the "Payouts and Rewards" account. In truth the money is going to come from the Land Owner's L$ balance .. because Objects don't have L$ balances or accounts.

When the Land Owner "pays" the Object, the money is withdrawn from their account .. and immediately put right back in. The script in the Object though will immediately send you 10% of that amount and then credit the "Payouts and Rewards" account balance with 90% of the amount paid.

It would really be a LOT easier to just have the Land Owner enter an amount via Prompt Box and not actually "Pay" anything. The script could then just send you 10% of whatever amount the Land Owner entered and record 90% of that amount as a credit to the "Payouts and Rewards" account.

Link to comment
Share on other sites

9 minutes ago, Darrius Gothly said:

It would really be a LOT easier to just have the Land Owner enter an amount via Prompt Box and not actually "Pay" anything. The script could then just send you 10% of whatever amount the Land Owner entered and record 90% of that amount as a credit to the "Payouts and Rewards" account.

Exactly.  You don't need any kind of split payment vendor if that's the case.  Just a simple vendor that owned by the "Payouts and Rewards" group. The landlord drops L$200 into it and the vendor sends you L$20.  Since a group can't have an account, the remaining L$180 is distributed among group members who have the "ability" to share group assets.

Link to comment
Share on other sites

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