Middlebury

Terra Tax Box

The following script will allow the owner to create a tax box to collect a varisble amount of Linden in taxes

//Tax Script for Terra Project v1.0
//Created by Brendan Smith 4/14/09
//This script is to be used to collect taxes from members of the Terra Project. Clicking on the tax box will bring up a payment dialogue with the option to pay the desired amount of tax money set as the variable "taxamount". The script keeps track of anyone who pays and will refund their money if they attempt to pay more than once. Warning!!!: Do not reset the script until all taxes are collected or the tax period is over as resetting the script will reset all the ongoing total amounts and the list of who's paid.

//Instructions to edit script:

//1. To change the amount taxes to charge simply change the 'taxamount' variable below to be the desired denomination
integer taxamount = 10;
//-----------


//variable to track total amount of taxes paid so far
integer totalamount = 0;
//variable to track total number of people who have paid taxes so far
integer totaltaxpayers = 0;
//variable to track the current user
key user;
//keeps track of the current list of people who have paid taxes by key
list g_TAXPAYERS;

//this function prints out a string including the number of taxpayers, their names, and the total amount of taxes collected
displayResults()
{
llInstantMessage(user, (string)totaltaxpayers + " people have payed L$" + (string)totalamount + " in taxes \n The following people have paid their taxes: " + taxpayers2String());
}
//This function converts all of the taxpayer's keys into names and then concatenates them into a single string and returns that string
string taxpayers2String()
{
string temp;
integer i= 0;
integer count = llGetListLength(g_TAXPAYERS);
for(i;i<count;i++)
{
temp += " " + (string)llList2String(g_TAXPAYERS,i) + ",";
}
return temp;
}

default
{
state_entry()
{
llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_DEBIT)
state cash;
}
}
//Script stays in this state for its whole execution.
state cash
{
state_entry()
{
llSetText("Click here to pay your L$10 tax", <1.0, 1.0, 1.0>, 1.0);
llSetPayPrice(PAY_HIDE, [taxamount ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}
touch_end(integer num_detected)
{
user = llDetectedKey(0);
if(user == llGetOwner())
{
displayResults();
}
}
//What to do when money is payed to this object. If the amount is incorrect then pay it back, if the person has already payed taxes then pay it back, and finally if the person has yet to pay taxes then record their key in the list of tax payers and increment the total number of payers and the total amount of taxes generated.
money(key id, integer amount)
{
user = id;
if(amount != taxamount)
{
llGiveMoney(user, amount);
llInstantMessage(user, "You paid "+(string)amount+", which is the wrong price, the price is: "+(string)taxamount);
}else if( llListFindList( g_TAXPAYERS, [llKey2Name(user)]) != -1 )
{
llGiveMoney(user, amount);
llInstantMessage(user, "You have already paid your taxes");
}
else
{
//insert your give code here.
llInstantMessage(id, "The Government of Terra thanks you for paying your taxes");
totalamount += 10;
totaltaxpayers++;
g_TAXPAYERS += llKey2Name(user);

}
}
}

Powered by MediaWiki