CDru Split Profit Script

Thread Started By steadymobbin

3088
0
  • 30 Vote(s) - 2.7 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rate Thread
#1
PHP Code:
//CDru
key owner;integer stp;key req;integer done=0;

//This is the list of partners that the object should split profits with.
//Please note that if the entry is a UUID, the script does not need to perform
//any outworld search to acquire the UUID based on name.

//If entry is a name, please make it exact, though it
//does not need to be case sensitive.

//The first example is provided. The profit holders are left in blank.
//If you wish to add profit holders, either enter their name, or their
//UUID. (If name, make sure it is full name - not case sensitive)
//
//Example:
//
//Each entry should be "Name or UUID", Percentage of profit,
//
//list partners=[
//    "Charliedru Lannock", 5,                              //Entries before the last need a comma after the quotation mark.
//    "Carina Luminos", 5,
//    "8f12ef0d-78e2-47da-af07-36392fdc816a", 5             //The last entry gets no comma after the quotation mark.
//];


//This should be limited to 20 partners maximum.
list partners=[
    
""10,
    
""20
];

list 
garbage=[];
list 
finaldata=[];

//Function Handlers

//Next step to check in partners list
next(){stp+=2;llSetTimerEvent(0.1);}

//Return the string for the current step
string l2s(){return llList2String(partners,stp);}

//Request debit permissions for split profit
reqq(){llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);}

//Return the amt to give to the partner
integer cut(integer percentinteger amt){return (integer)(((float)percent/100)*amt);}

//Add data to be removed to the garbage list.
discard(string tmp){llOwnerSay("Discarding "+tmp+" due to invalid name/key.");garbage+=tmp;}

//Verify the list to see it is a UUID. If not, then
//do an HTTP Request to acquire the person's UUID.
listcheck(){
    if(
stp>=(llGetListLength(partners)-1)){
        
dump();return;
    }
    
string tmp=l2s();
    if(
tmp==""){llOwnerSay("Error: There are blank entries in the script. Please enter data the data necessary.");return;}
    if((
key)tmp!=NULL_KEY && llStringLength(tmp)==36){
        
finaldata+=[tmp,llList2Integer(partners,stp+1)];
        
next();return;
    }
    else{
        if(
llGetListLength(llParseString2List(tmp,[" "],[]))!=2){
            
discard(tmp);next();return;
        }
        else{
            
req=llHTTPRequest("http://w-hat.com/name2key?terse=1&name="+llEscapeURL(tmp),[],"");
        }
        
    }
}

//Dump the invalid data
dump(){
    
partners=[];garbage=[];
    
done=1;llSetTimerEvent(0.25);
}


//Pay out to the partners based on each of their shares
payout(integer amt){integer a=0;integer b=llGetListLength(finaldata);
    for(;
a<b;a++){
        if(
a%2==0){
            if(
llList2Integer(finaldata,a+1)!=0llGiveMoney(llList2Key(finaldata,a),cut(llList2Integer(finaldata,a+1),amt));
        }
    }    
}

default{
    
on_rez(integer parm){llResetScript();}
    
state_entry(){owner=llGetOwner();llOwnerSay("/me requires Debit Permissions to split profits. Please accept.");
        
reqq();
    }
    
http_response(key ridinteger stat, list metadatastring body){
        if(
req==rid){
            
string tmp=l2s();
            if((
key)body==NULL_KEY){
                
discard(tmp);next();return;
            }
            else{
                
garbage+=tmp;finaldata+=body;finaldata+=llList2Integer(partners,stp+1);next();
            }
        }
    }
    
run_time_permissions(integer perm){
        if(
perm&PERMISSION_DEBIT){
            
llOwnerSay("Please provide a moment to verify the list of profit holders.");
            
stp=0;listcheck();
        }
    }
    
timer(){
        
llSetTimerEvent(0.0);
        if(!
done)listcheck();
        else
            
state ready2pay;
    }
}

state ready2pay{
    
on_rez(integer parm){llResetScript();}
    
state_entry(){llOwnerSay("List has been verified. Split profit is now enabled for all on the partner list.");}
    
money(key whointeger amt){
        if(
llGetListLength(finaldata)<=1) return;
        
payout(amt);
    }
}
//CDru 
[Image: guns-bullet-shirt_recreated.jpg]
Reply




Possibly Related Threads…
Thread Author Replies Views Last Post
  Vendor Split Revenues With Partner YoungMoney 1 3,400 07-03-2018, 06:48 PM
Last Post: ilkermete
  Profit Splitter TrueFreak 0 2,354 07-10-2013, 03:37 PM
Last Post: TrueFreak

Forum Jump:

1 Guest(s)
Share this:

About Second Life Copybot

Second Life CopyBot Forum is a place where you can get items for Second Life and other vitual worlds for free. With our CopyBot viewers you can export and import any content from these virtual worlds and modify them in 3D software such as Blender, 3D studio Macx etc...