Jump to content
Sign in to follow this  
conrad Evanier

getting this script to configure from a note card please help

Recommended Posts

Hi iv got a great split income script that works well, the trouble im having is getting it to configure from a note card iv tried many time with no luck.  Im posting on here in the hope some one can help me out feel free to copy and use script your self as its only part of a creation and not the main script.  It needs to get avi key from a note card named settings so you dont have to eddit script as not many customers like doing this lol thanks for looking its the list partners i need it to get from note card!

key owner;integer stp;key req;integer done=0;
//list of partners add avi key in the commas the number is persentage of split this can be changed//
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 percent, integer 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)!=0) llGiveMoney(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 rid, integer stat, list metadata, string 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 who, integer amt){
        if(llGetListLength(finaldata)<=1) return;
        payout(amt);
    }
}

Share this post


Link to post
Share on other sites

This is a tough script to read. Style is a very personal matter and we each use whatever works best for us.  Still, if it were my own script I wouldn't pack multiple functions on a single line.  I'd find it hard to debug.  Just sayin' ..........

You'll need to include a dataserver event in your default state to read the notecard and a llGetNotecardLine function to trigger it.  See the short example HERE

Share this post


Link to post
Share on other sites

Rolig is right - your script is a pain to read - next time you should format it more readable.

Since, however, it could be changed without having to read most of it (at least I hope I managed to do just that) and mostly by adding some lines, here is a version that should look for an NC named Config which should contain lines formatted like:

 

UUID, percentageUUID, percentage

 

string gsCardName = "Config";key gkQuery;integer giLine;key owner;integer stp;key req;integer done=0;//list of partners add avi key in the commas the number is persentage of split this can be changed//list partners;list garbage=[];list finaldata=[];//Function Handlers//Next step to check in partners listnext(){stp+=2;llSetTimerEvent(0.1);}//Return the string for the current stepstring l2s(){return llList2String(partners,stp);}//Request debit permissions for split profitreqq(){llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);}//Return the amt to give to the partnerinteger cut(integer percent, integer 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 datadump(){    partners=[];garbage=[];    done=1;llSetTimerEvent(0.25);}//Pay out to the partners based on each of their sharespayout(integer amt){    integer a=0;    integer b=llGetListLength(finaldata);    for(;a<b;a++){        if(a%2==0){            if(llList2Integer(finaldata,a+1)!=0) llGiveMoney(llList2Key(finaldata,a),cut(llList2Integer(finaldata,a+1),amt));        }    }   }default{    on_rez(integer parm){llResetScript();}    state_entry(){        owner=llGetOwner();        llOwnerSay("Reading configuration.");        giLine = 0;        gkQuery = llGetNotecardLine(gsCardName, 0);        //llOwnerSay("/me requires Debit Permissions to split profits. Please accept.");        //reqq();    }        dataserver(key queryid, string data) {        if (gkQuery == queryid) {            if (data == EOF) {                llOwnerSay("/me requires Debit Permissions to split profits. Please accept.");                reqq();                } else {                list lidata = llParseStringKeepNulls(data, [","], []);                if (llGetListLength(lidata) == 2) {                    partners += llStringTrim(llList2String(lidata, 0), STRING_TRIM);                    partners += (integer)llStringTrim(llList2String(lidata, 1), STRING_TRIM);                    }                gkQuery = llGetNotecardLine(gsCardName, ++giLine);            }        }    }        http_response(key rid, integer stat, list metadata, string 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 who, integer amt){        if(llGetListLength(finaldata)<=1) return;        payout(amt);    }}

 

 

Share this post


Link to post
Share on other sites

what for getting the UUIDs???  Hardly all encompassing or thorough enough for deployment use.

 

Just create a prim for those you are going to give money to touch and spit out their UUIDs.  Then you can copy paste the UUIDs into the notecard. 

 

touch_start(integer ignore)

{

key toucher = llDetectedKey(0);

llOwnerSay("the uuid of the person is "+(string)toucher);  // ownersay so the whole world doesn't hear it.

}

Share this post


Link to post
Share on other sites

thanks Shockwave but its not the key finder i was after i have that already i needed the script to read from a note card and thanks to Darkie Minotar it dose that now,  Thanks again for all the help

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.

Sign in to follow this  

×
×
  • Create New...