Sunday, 17 October 2010

COMISSION SCRIPT - Second Life®

// enter here the Price of the Object
integer price=79;
// enter here the Product wich a People will get after Paying Object
string product="Male Skin TGA Files";
// enter here the persons Key wich will get the Money
key partner ="5bf4a61e-347e-49b8-b4f8-c2949d6f484f";
// enter here the Hovering Text wich will be Displayed
string DISPLAYTEXT="Pay me to get the object";
// enter here the Percent wich your Partner will get
integer cpercent = 50;


integer commission;
integer payment;
/////////////////////
//    CONSTANTS    //
/////////////////////
integer PERMST=FALSE;

default
{
    state_entry()
    {
        llSetText("", <255.0,255.0,64.0>, 1);
        llGetOwner();
        llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
        if(PERMST==TRUE){
        state run;}
        llSetTimerEvent(5.0);
    }
   
    touch_start(integer total_number)
    {
        llInstantMessage(llGetOwner(),llDetectedKey(0));
        if(llGetOwner() == llDetectedKey(0)){
        if(PERMST==FALSE){ 
        state perms;
        } else {state run;}}
    }
   
    timer()
    {
     if(PERMST==FALSE){ 
        state perms;
        } else {state run;}  
    }
}

state run
{
    state_entry()
    {
    llSetText(DISPLAYTEXT, <255.0,255.0,64.0>, 1);
    llSetPayPrice(PAY_HIDE, [price, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}
   
    money(key payer, integer amount)
    {
        if (amount == price)
        {  
        commission = (amount * cpercent) / 100;
        payment = amount - commission;
        llGiveMoney(partner, payment);
        llInstantMessage(payer,"Thanks for your Purchase! you should receive your Item in a few seconds");
        llGiveInventory(payer,product);
        }        
       
       
        if (amount < price)
        {
            llInstantMessage(payer, "I'm sorry, but that is not enough for the item.");
            llGiveMoney(payer, amount);
        }
       
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_DEBIT)
        { 
        }
        else
        {
            llOwnerSay("Sorry, you must click [Yes] in order for this to work. Reset Display now.");
            state black_hole;
        }
    }
}

state perms {
    state_entry() {
        llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); 
        PERMST=TRUE;
        state default;
    }  
   
}
state black_hole
{
    state_entry()
    {
        llResetScript();
    }
}




do not forget yout donation

No comments:

Post a Comment