Difference between revisions of "User:Kristy Fanshaw"

From Second Life Wiki
Jump to navigation Jump to search
Line 17: Line 17:


<lsl>
<lsl>
integer gCorrectAmount = 10; //enter your price for fast pay
integer gCorrectAmount = 600;                       //enter your price for fast pay
integer my_profit = 60;                            // how many percent you would like to recieve form the sale
string update_box = "Lady Minimal update box";      // describe the name of the "update box" object that should be rezzed
integer totalsold = 0;
integer totalsold = 0;
integer totalamount = 0;
integer totalamount = 0;
key OWNER;
key OWNER;
key CREATOR;
key ID;
key ID;
string url;
string url;
key http_request_id;
key http_request_id;
integer listen_handle;
integer listen_handle;
integer back;
integer buyer_paid;
string mail;
string mail;
integer Ch;




default
default
     {
     {
Line 37: Line 42:
                         llResetScript();
                         llResetScript();
                     }
                     }
               
             }
             }
         on_rez(integer start_param)
         on_rez(integer start_param)
Line 43: Line 48:
                 llResetScript();
                 llResetScript();
             }
             }
           
         state_entry()
         state_entry()
             {
             {
                 OWNER = llGetOwner();
                 OWNER = llGetOwner();
                CREATOR = llGetCreator();
                Ch =  ( -1 * (integer)("0x"+llGetSubString((string)llGetCreator(),-7,-1)) );
                 llSetPayPrice(PAY_HIDE, [gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                 llSetPayPrice(PAY_HIDE, [gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                // in llSetText describe the name of the "update box" object that should be rezzed
                 llSetText("To start vendor, rezz '" + update_box + "'.", <1.0, 1.0, 1.0>, 1.0);
                 llSetText("To start vendor, rezz 'update box name'.", <1.0, 1.0, 1.0>, 1.0);
                 llSensorRepeat(update_box, NULL_KEY , SCRIPTED, 10 , PI, 10);
                 llSensorRepeat("update box name", NULL_KEY , SCRIPTED, 10 , PI, 10);
             }
             }
         sensor (integer numberDetected)
         sensor (integer numberDetected)
Line 62: Line 68:
     }
     }
state sens
state sens
{
    {
         on_rez(integer start_param)
         on_rez(integer start_param)
             {
             {
Line 69: Line 75:
         state_entry()
         state_entry()
             {
             {
                 llSetText("Updating", <1.0, 1.0, 1.0>, 1.0);
                 llSetText("Updating", <1.0, 1.0, 1.0>, 1.0);   
                // set llShout channel to whatever negative channel you like, but remeber to define the same channel in update box llListen function  
                 llShout(Ch,"update");
                 llShout(-1234567,"update");
                 listen_handle = llListen(Ch,update_box, NULL_KEY, "");
                // set llListen channel to whatever negative channel you like, but remeber to define the same channel in update box llShout function
                 llSensorRepeat(update_box, NULL_KEY , SCRIPTED, 10 , PI, 5);
                 listen_handle = llListen(-7654321,"update box name", NULL_KEY, "");
                 llSensorRepeat("update box name", NULL_KEY , SCRIPTED, 10 , PI, 5);
             }
             }
         listen( integer channel, string name, key id, string message )
         listen( integer channel, string name, key id, string message )
Line 81: Line 85:
                 llListenRemove(listen_handle);
                 llListenRemove(listen_handle);
                 llOwnerSay("updated");
                 llOwnerSay("updated");
                 llShout(-1234567,"updated");
                 llShout(Ch,"updated");
                 llListenRemove(listen_handle);     
                 llListenRemove(listen_handle);     
             }
             }
Line 95: Line 99:
         touch_start(integer total_number)
         touch_start(integer total_number)
             {
             {
                 llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
                 llRequestPermissions(OWNER, PERMISSION_DEBIT);
             }
             }
         run_time_permissions(integer Permission)
         run_time_permissions(integer Permission)
Line 112: Line 116:
                     }
                     }
             }   
             }   
     }
     }  
 
state Ready
state Ready
    {
    {
         on_rez(integer start_param)
         on_rez(integer start_param)
             {
             {
Line 122: Line 125:
         state_entry()
         state_entry()
             {
             {
                 llSensorRepeat("update box name", NULL_KEY , SCRIPTED, 10 , PI,30);
                 llSensorRepeat(update_box, NULL_KEY , SCRIPTED, 10 , PI,30);
             }
             }
         sensor (integer numberDetected)
         sensor (integer numberDetected)
             {
             {
                 llSetText("Updating", <1.0, 1.0, 1.0>, 1.0);
                 llSetText("Updating", <1.0, 1.0, 1.0>, 1.0);
                 llShout(-1234567,"update");
                 llShout(Ch,"update");
                 listen_handle = llListen(-7654321,"update box name", NULL_KEY, "");
                 listen_handle = llListen(Ch,update_box, NULL_KEY, "");
             }
             }
         listen( integer channel, string name, key id, string message )
         listen( integer channel, string name, key id, string message )
Line 135: Line 138:
                 llListenRemove(listen_handle);
                 llListenRemove(listen_handle);
                 llOwnerSay("updated");
                 llOwnerSay("updated");
                 llShout(-1234567,"updated");
                 llShout(Ch,"updated");
                 llSetText("", <1.0, 1.0, 1.0>, 1.0);
                 llSetText("", <1.0, 1.0, 1.0>, 1.0);
                 llListenRemove(listen_handle);
                 llListenRemove(listen_handle);
Line 141: Line 144:
         touch_start(integer total_number)
         touch_start(integer total_number)
             {
             {
                 if (llDetectedOwner(0) == llGetOwner())
                 if (llDetectedOwner(0) == OWNER)
                     {
                     {
                         llOwnerSay((string)totalsold +" units have been sold since object rez. ");
                         llOwnerSay((string)totalsold +" units have been sold since object rez. ");
Line 150: Line 153:
                     }
                     }
             }
             }
 
         money(key id, integer amount)
         money(key id, integer amount)
        {
            ID =id;
            back = amount;
             {
             {
                 if (amount == gCorrectAmount)
                 ID =id;
                    {// correct amount paid
                buyer_paid = amount;
                        llInstantMessage(id, "Thank you " + llKey2Name(id) + " for your purchase.");
                        llInstantMessage(id,"Server initialises your request .....");
                        http_request_id = llHTTPRequest(url, [], "");
                    }
                else if (amount < gCorrectAmount)
                    {
                        llInstantMessage(llDetectedKey(0),"You didn't pay enough, " + llKey2Name(id) + ". Refunding your payment of L$" + (string)amount + ".");
                        llGiveMoney(id, amount);
                        state Ready;
                    }
                else
                     {
                     {
                         integer refund = amount - gCorrectAmount;
                         if (amount == gCorrectAmount)
                        llInstantMessage(llDetectedKey(0),"You paid too much, " + llKey2Name(id) + ". Your change is L$" + (string)refund + ".");
                            {
                        llGiveMoney(id, refund);
                                llInstantMessage(id, "Thank you " + llKey2Name(id) + " for your purchase.");
                        llInstantMessage(id, "Thank you " + llKey2Name(id) + " for your purchase.");
                                llInstantMessage(id,"Server initialises your request .....");
                        llInstantMessage(id,"Server initialises your request .....");
                                http_request_id = llHTTPRequest(url, [], "");
                        http_request_id = llHTTPRequest(url, [], "");
                            }
                        else if (amount < gCorrectAmount)
                            {
                                llInstantMessage(llDetectedKey(0),"You didn't pay enough, " + llKey2Name(id) + ". Refunding your payment of L$" + (string)amount + ".");
                                llGiveMoney(id, amount);
                                state Ready;
                            }
                        else
                            {
                                integer refund = amount - gCorrectAmount;
                                llInstantMessage(llDetectedKey(0),"You paid too much, " + llKey2Name(id) + ". Your change is L$" + (string)refund + ".");
                                llGiveMoney(id, refund);
                                llInstantMessage(id, "Thank you " + llKey2Name(id) + " for your purchase.");
                                llInstantMessage(id,"Server initialises your request .....");
                                http_request_id = llHTTPRequest(url, [], "");
                            }
                     }
                     }
             }
             }
                 
        }
         http_response(key request_id, integer status, list metadata, string body)
         http_response(key request_id, integer status, list metadata, string body)
        {
             {
             {
                 mail =body;
                 mail =body;
                if (request_id == http_request_id)
                     {
                     {
                    if(llGetSubString(body, -19, -1) == "@lsl.secondlife.com")
                        if (request_id == http_request_id)
                        {
                            {
                            llInstantMessage(ID,"Request initialised.");
                                if(llGetSubString(body, -19, -1) == "@lsl.secondlife.com")
                            llInstantMessage(ID,"Sending your requested items .....");
                                    {
                            llSetText("Purchase in progress...\n\nPlease Wait...", <1.0, 1.0, 1.0>, 1.0);
                                        llInstantMessage(ID,"Request initialised.");
                            llSetPayPrice(PAY_HIDE,[ PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                                        llInstantMessage(ID,"Sending your requested items .....");
                            llEmail( body, ID, (string)llGetKey()+"@lsl.secondlife.com" );
                                        llSetText("Purchase in progress...\n\nPlease Wait...", <1.0, 1.0, 1.0>, 1.0);
                           
                                        llSetPayPrice(PAY_HIDE,[ PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                            llSetTimerEvent(5);
                                        llEmail( body, ID, (string)llGetKey()+"@lsl.secondlife.com" );
                            llGetNextEmail("", "");
                                        llSetTimerEvent(5);
                            llGiveMoney(ID, back);
                                        llGetNextEmail("", "");     
                            llInstantMessage(ID, "Vendor is outdated");
                                    }
                            llInstantMessage(llGetOwner(), "Your Vendor in " + llGetRegionName() + " sim can't deliver items. Please update your Vendor.");
                                else
                            llResetScript();     
                                    {
                        }
                                        llGiveMoney(ID, buyer_paid);
                    else
                                        llInstantMessage(ID, "Vendor is outdated");
                        {
                                        llInstantMessage(OWNER, "Your Vendor in " + llGetRegionName() + " sim can't deliver items. Please update your Vendor.");
                            llGiveMoney(ID, back);
                                        llResetScript();   
                            llInstantMessage(ID, "Vendor is outdated");
                                    }
                            llInstantMessage(llGetOwner(), "Your Vendor in " + llGetRegionName() + " sim can't deliver items. Please update your Vendor.");
                            }
                            llResetScript();   
                        }
                     }
                     }
             }
             }
        }
       
         email( string time, string address, string subj, string message, integer num_left )
         email( string time, string address, string subj, string message, integer num_left )
             {     
             {     
                 if (subj == "delivered")
                 if (subj == "delivered")
                     {
                     {
                         key creator = llGetCreator();
                         float profit = my_profit / 100;
                            float calc = back + 0.0;
                        float calc = buyer_paid + 0.0;
                            float a = calc * 0.6;     // Define here how much you'll recieve from the sale: 1 = 100 % (in this case here you'll get 60% from the sale and vendor owner gets 40%)
                        float a = calc * profit;
                            float b = back - a;
                        float b = buyer_paid - a;
                            llGiveMoney( creator, (integer)a );
                        llGiveMoney( CREATOR, (integer)a );
                            llInstantMessage(ID,"Accept your purchased items");
                        llInstantMessage(ID,"Accept your purchased items");
                            totalsold = totalsold + 1;
                        totalsold = totalsold + 1;
                            totalamount = back * totalsold;
                        totalamount = buyer_paid * totalsold;
                            llInstantMessage(llGetOwner(), (string)llKey2Name(ID) + " has paid " + (string)back + "L$ in "+ llGetRegionName() + " and you have recived " + (string)llRound(b) + "L$ from this sale");
                        llInstantMessage(OWNER, (string)llKey2Name(ID) + " has paid " + (string)buyer_paid + "L$ in "+ llGetRegionName() + " and you have recived " + (string)llRound(b) + "L$ from this sale");
                            llInstantMessage(creator, (string)llKey2Name(ID) + " has paid " + (string)back + "L$ in "+ llGetRegionName() + " and you have recived " + (string)llRound(a) + "L$ from this sale");
                        llInstantMessage(CREATOR, (string)llKey2Name(ID) + " has paid " + (string)buyer_paid + "L$ in "+ llGetRegionName() + " and you have recived " + (string)llRound(a) + "L$ from this sale");
                            llSetPayPrice(PAY_HIDE,[gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                        llSetPayPrice(PAY_HIDE,[gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                            llSetText("", <1.0, 1.0, 1.0>, 1.0);
                        llSetText("", <1.0, 1.0, 1.0>, 1.0);
                            llSetTimerEvent(0);
                        llSetTimerEvent(0);
                            state Ready;
                        state Ready;
                     }   
                     }   
             }
             }
         timer()  
         timer()  
             {       
             {       
                        llGiveMoney(ID, back);
                llGiveMoney(ID, buyer_paid);
                        llInstantMessage(ID, "Vendor couldn't deliver items ... your money is refunded");
                llInstantMessage(ID, "Vendor couldn't deliver items ... your money is refunded");
                        llInstantMessage(llGetOwner(), "Your Vendor in " + llGetRegionName() + " sim can't deliver items. Please update your Vendor.");
                llInstantMessage(OWNER, "Your Vendor in " + llGetRegionName() + " sim can't deliver items. Please update your Vendor.");
                        llSetPayPrice(PAY_HIDE,[gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                llSetPayPrice(PAY_HIDE,[gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                        llSetText("", <1.0, 1.0, 1.0>, 1.0);
                llSetText("", <1.0, 1.0, 1.0>, 1.0);
                        llSetTimerEvent(0);
                llSetTimerEvent(0);
                        state default;         
                state default;         
             }                           
             }                           
}
}

Revision as of 07:57, 9 January 2009

Pay Script for Reseller vendor

Place this script in a Vendor Root prim.

What it does:

1) it asks the owner of the vendor to rezz the update box. 2) update box will define the URL from where it can aquire the email address of the vendor. (the webpage body should contain only pure address - no html code) 3) when the URL is set, it asks the owner of the vendor to grant debits. If the owner won't do so, the script resets. 4) When debits are granted the vendor will be active

Purchase:

1) buyer can pay only the amount of money that is set in "integer gCorrectAmount = price;"



<lsl> integer gCorrectAmount = 600; //enter your price for fast pay integer my_profit = 60; // how many percent you would like to recieve form the sale string update_box = "Lady Minimal update box"; // describe the name of the "update box" object that should be rezzed integer totalsold = 0; integer totalamount = 0; key OWNER; key CREATOR; key ID; string url; key http_request_id; integer listen_handle; integer buyer_paid; string mail; integer Ch;


default

   {
       changed(integer change)
           {
               if(change && CHANGED_OWNER)
                   {
                       llResetScript();
                   }

           }
       on_rez(integer start_param)
           {
               llResetScript();
           }

       state_entry()
           {
               OWNER = llGetOwner();
               CREATOR = llGetCreator();
               Ch =  ( -1 * (integer)("0x"+llGetSubString((string)llGetCreator(),-7,-1)) );
               llSetPayPrice(PAY_HIDE, [gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
               llSetText("To start vendor, rezz '" + update_box + "'.", <1.0, 1.0, 1.0>, 1.0);
               llSensorRepeat(update_box, NULL_KEY , SCRIPTED, 10 , PI, 10);
           }
       sensor (integer numberDetected)
           {
               state sens;
           }
       no_sensor ()
           {
               llResetScript();
           }
   }

state sens

   {
       on_rez(integer start_param)
           {
               llResetScript();
           }
       state_entry()
           {
               llSetText("Updating", <1.0, 1.0, 1.0>, 1.0);  
               llShout(Ch,"update");
               listen_handle = llListen(Ch,update_box, NULL_KEY, "");
               llSensorRepeat(update_box, NULL_KEY , SCRIPTED, 10 , PI, 5);
           }
       listen( integer channel, string name, key id, string message )
           {
                url = message;
                llListenRemove(listen_handle);
                llOwnerSay("updated");
                llShout(Ch,"updated");
                llListenRemove(listen_handle);     
           }
       sensor (integer numberDetected)
           {
               llListenRemove(listen_handle);
               state sens;
           }
       no_sensor ()
           {
               llSetText("Touch to grant debit permission.", <1.0, 1.0, 1.0>, 1.0);
           }
       touch_start(integer total_number)
           {
               llRequestPermissions(OWNER, PERMISSION_DEBIT);
           }
       run_time_permissions(integer Permission)
           {
               if(Permission == PERMISSION_DEBIT)
                   {
                       llOwnerSay("Starting vendor.");
                       llSetText("", <1.0, 1.0, 1.0>, 1.0);
                       state Ready;
                   }
               else
                   {
                       llOwnerSay ( "To share proceeds I must have give money(DEBIT) permissions");
                       llOwnerSay ( "Try again");
                       llResetScript();
                   }
           }  
   } 

state Ready

   {
       on_rez(integer start_param)
           {
               llResetScript();
           }
       state_entry()
           {
               llSensorRepeat(update_box, NULL_KEY , SCRIPTED, 10 , PI,30);
           }
       sensor (integer numberDetected)
           {
               llSetText("Updating", <1.0, 1.0, 1.0>, 1.0);
               llShout(Ch,"update");
               listen_handle = llListen(Ch,update_box, NULL_KEY, "");
           }
       listen( integer channel, string name, key id, string message )
           {
               url = message;
               llListenRemove(listen_handle);
               llOwnerSay("updated");
               llShout(Ch,"updated");
               llSetText("", <1.0, 1.0, 1.0>, 1.0);
               llListenRemove(listen_handle);
           }
       touch_start(integer total_number)
           {
               if (llDetectedOwner(0) == OWNER)
                   {
                       llOwnerSay((string)totalsold +" units have been sold since object rez. ");
                   }
               else
                   {
                       llInstantMessage(llDetectedKey(0), "Right-click and pay to purchase."); 
                   }
           }
       money(key id, integer amount)
           {
               ID =id;
               buyer_paid = amount;
                   {
                       if (amount == gCorrectAmount)
                           {
                               llInstantMessage(id, "Thank you " + llKey2Name(id) + " for your purchase.");
                               llInstantMessage(id,"Server initialises your request .....");
                               http_request_id = llHTTPRequest(url, [], "");
                           }
                       else if (amount < gCorrectAmount)
                           {
                               llInstantMessage(llDetectedKey(0),"You didn't pay enough, " + llKey2Name(id) + ". Refunding your payment of L$" + (string)amount + ".");
                               llGiveMoney(id, amount);
                               state Ready;
                           }
                       else
                           {
                               integer refund = amount - gCorrectAmount;
                               llInstantMessage(llDetectedKey(0),"You paid too much, " + llKey2Name(id) + ". Your change is L$" + (string)refund + ".");
                               llGiveMoney(id, refund);
                               llInstantMessage(id, "Thank you " + llKey2Name(id) + " for your purchase.");
                               llInstantMessage(id,"Server initialises your request .....");
                               http_request_id = llHTTPRequest(url, [], "");
                           }
                   }

           }
       http_response(key request_id, integer status, list metadata, string body)
           {
               mail =body;
                   {
                       if (request_id == http_request_id)
                           {
                               if(llGetSubString(body, -19, -1) == "@lsl.secondlife.com")
                                   {
                                       llInstantMessage(ID,"Request initialised.");
                                       llInstantMessage(ID,"Sending your requested items .....");
                                       llSetText("Purchase in progress...\n\nPlease Wait...", <1.0, 1.0, 1.0>, 1.0);
                                       llSetPayPrice(PAY_HIDE,[ PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                                       llEmail( body, ID, (string)llGetKey()+"@lsl.secondlife.com" );
                                       llSetTimerEvent(5);
                                       llGetNextEmail("", "");     
                                   }
                               else
                                   {
                                       llGiveMoney(ID, buyer_paid);
                                       llInstantMessage(ID, "Vendor is outdated");
                                       llInstantMessage(OWNER, "Your Vendor in " + llGetRegionName() + " sim can't deliver items. Please update your Vendor.");
                                       llResetScript();  
                                   }
                           }
                   }
           }
       email( string time, string address, string subj, string message, integer num_left )
           {    
               if (subj == "delivered")
                   {
                       float profit = my_profit / 100;
                       float calc = buyer_paid + 0.0;
                       float a = calc * profit;
                       float b = buyer_paid - a;
                       llGiveMoney( CREATOR, (integer)a );
                       llInstantMessage(ID,"Accept your purchased items");
                       totalsold = totalsold + 1;
                       totalamount = buyer_paid * totalsold;
                       llInstantMessage(OWNER, (string)llKey2Name(ID) + " has paid " + (string)buyer_paid + "L$ in "+ llGetRegionName() + " and you have recived " + (string)llRound(b) + "L$ from this sale");
                       llInstantMessage(CREATOR, (string)llKey2Name(ID) + " has paid " + (string)buyer_paid + "L$ in "+ llGetRegionName() + " and you have recived " + (string)llRound(a) + "L$ from this sale");
                       llSetPayPrice(PAY_HIDE,[gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                       llSetText("", <1.0, 1.0, 1.0>, 1.0);
                       llSetTimerEvent(0);
                       state Ready;
                   }  
           }
       timer() 
           {       
               llGiveMoney(ID, buyer_paid);
               llInstantMessage(ID, "Vendor couldn't deliver items ... your money is refunded");
               llInstantMessage(OWNER, "Your Vendor in " + llGetRegionName() + " sim can't deliver items. Please update your Vendor.");
               llSetPayPrice(PAY_HIDE,[gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
               llSetText("", <1.0, 1.0, 1.0>, 1.0);
               llSetTimerEvent(0);
               state default;         
           }                           

}