Difference between revisions of "User:Kristy Fanshaw/Vendor System Script"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{LSL Header}}__TOC__
{{LSL Header}}__TOC__
*[[User:Kristy_Fanshaw|Click Here]]  To see my main page for more scripts, if i'll make any :))
*[[User:Kristy_Fanshaw/Shorter_Vendor_System_Script|Shorter Vendor System Script]] :: Same script, but without HTTP check
{{box|Copying Permission|
Copyright © 2008 by Kristy Fanshaw


This program is free software: you can redistribute it and/or modify<br>
it under the terms of the GNU General Public License as published by<br>
the Free Software Foundation, either version 3 of the License, or<br>
(at your option) any later version.<br>


*[[User:Kristy_Fanshaw|Click Here]]  To see my page and more of my scripts if i make any :))
This program is distributed in the hope that it will be useful,<br>
 
but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
==Pay Script for Reseller vendor==
GNU General Public License for more details.<br>
Place this script in a Vendor Root prim.
 
 
===== What it does: =====
 
# it asks the owner of the vendor to rezz the update box.
# 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)
# 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.  
# When debits are granted the vendor will be active
 
----


To get a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.}}
{{box|Pay Script for Reseller vendor|
Place this script in a Vendor Root prim you've created.<br><br>
What it does:
# it asks the owner of the vendor to rezz the update box.<br>
# 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 - index.html file should contain no code)<br>
# 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.<br>
# when debits are granted the vendor will be active.<br>
# if the owner of the vendor touches vendor in active mode, the vendor will tell how many items have been sold since activation.<br>
Purchase:
Purchase:
 
# buyer can pay only the amount of money that is set in "integer gCorrectAmount"  
# buyer can pay only the amount of money that is set in "integer gCorrectAmount = price;"
# when buyer pays money, the vendor goes to check the email address of the server from given URL. If there will be invalid response, money will be refunded to buyer and vendor shuts down till next update.
# when buyer pays money, the vendor goes to check the email address of the server from given URL. If there will be invalid response, money will be refunded to buyer and vendor shuts down till next update.
# vendor sends now email to server prim with buyers ID in subject line and its own email address in message content.
# vendor sends now email to server prim with buyers ID in subject line and its own email address in message content.
# server will give the item to buyer and sends "delivered" notification back to vendor. If the server is not working or there will be some other issues with delivery, then money will be refunded to buyer and vendor shuts down till next update.
# server will give the item to buyer and sends "delivered" notification back to vendor. If the server is not working or there will be some other issues with delivery, then money will be refunded to buyer and vendor shuts down till next update.
# when vendor receives email from server with "delivered" note, then creator of the vendor receives the money.
# when vendor receives email from server with "delivered" note, then creator of the vendor receives the money.  


<lsl>////////////////////////////////////////////////////////////////////////////////////////////////
//    Copyright (c) 2008 by Kristy Fanshaw                                                    //
//    This script is part of Vendor System.                                                  //
////////////////////////////////////////////////////////////////////////////////////////////////
//    Vendor System is free software: you can redistribute it and/or modify                  //
//    it under the terms of the GNU General Public License as published by                    //
//    the Free Software Foundation, either version 3 of the License, or                      //
//    (at your option) any later version.                                                    //
//                                                                                            //
//    Vendor System is distributed in the hope that it will be useful,                        //
//    but WITHOUT ANY WARRANTY; without even the implied warranty of                          //
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                          //
//    GNU General Public License for more details.                                            //
//                                                                                            //
//    To get a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.    //
////////////////////////////////////////////////////////////////////////////////////////////////


<lsl>integer gCorrectAmount = 10;                            // enter your price for fast pay
integer gCorrectAmount = 10;                            // enter the price for fast pay
integer my_profit = 50;                                // how many percent you would like to recieve form the sale
integer my_profit = 50;                                // how many percent you would like to recieve form the sale
string update_box = "update box name";                  // describe the name of the "update box" object that should be rezzed
string update_box = "update box name";                  // describe the name of the "update box" object that should be rezzed
 
string name = "my vendor name";                        // Set the vendor name here
integer totalsold = 0;
integer totalsold = 0;
integer Ch;
integer Ch;
Line 41: Line 63:
string url;
string url;
string mail;
string mail;
 
default
default
     {
     {
         changed(integer change)
         changed(integer change)
             {
             {
                 if(change && CHANGED_OWNER)
                 if(change & CHANGED_OWNER)
                     {
                     {
                        llSetObjectDesc("0");
                         llResetScript();
                         llResetScript();
                     }
                     }
Line 55: Line 78:
                 llResetScript();
                 llResetScript();
             }
             }
         state_entry()
         state_entry()
             {
             {
                 OWNER = llGetOwner();
                 OWNER = llGetOwner();
                 CREATOR = llGetCreator();
                 CREATOR = llGetCreator();
                 Ch =  ( -1 * (integer)("0x"+llGetSubString((string)llGetCreator(),-7,-1)) );
                 Ch =  ( -1 * (integer)("0x"+llGetSubString((string)CREATOR,-7,-1)) );
                totalsold = (integer)llGetObjectDesc();
                llSetObjectName(name);
                 llSetPayPrice(PAY_HIDE, [gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
                 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);
                 llSetText("To start vendor, rezz '" + update_box + "'.", <1.0, 1.0, 1.0>, 1.0);
Line 72: Line 96:
             {
             {
                 llResetScript();
                 llResetScript();
            }
    }
state sens1
    {
        state_entry()
            {
                state sens;
             }
             }
     }
     }
Line 90: Line 121:
             {
             {
                 url = message;
                 url = message;
                llListenRemove(listen_handle);
                 llOwnerSay("updated");
                 llOwnerSay("updated");
                 llShout(Ch,"updated");
                 llShout(Ch,"updated");
Line 98: Line 128:
             {
             {
                 llListenRemove(listen_handle);
                 llListenRemove(listen_handle);
                 state sens;
                 state sens1;
             }
             }
         no_sensor ()
         no_sensor ()
Line 124: Line 154:
             }   
             }   
     }  
     }  
state Ready1
    {
        state_entry()
            {
                state Ready;
            }
    }
state Ready
state Ready
     {
     {
Line 143: Line 180:
             {
             {
                 url = message;
                 url = message;
                llListenRemove(listen_handle);
                 llOwnerSay("updated");
                 llOwnerSay("updated");
                 llShout(Ch,"updated");
                 llShout(Ch,"updated");
Line 175: Line 211:
                                 llInstantMessage(llDetectedKey(0),"You didn't pay enough, " + llKey2Name(id) + ". Refunding your payment of L$" + (string)amount + ".");
                                 llInstantMessage(llDetectedKey(0),"You didn't pay enough, " + llKey2Name(id) + ". Refunding your payment of L$" + (string)amount + ".");
                                 llGiveMoney(id, amount);
                                 llGiveMoney(id, amount);
                                 state Ready;
                                 state Ready1;
                             }
                             }
                         else
                         else
Line 187: Line 223:
                             }
                             }
                     }
                     }
             }
             }
         http_response(key request_id, integer status, list metadata, string body)
         http_response(key request_id, integer status, list metadata, string body)
Line 219: Line 254:
                 if (subj == "delivered")
                 if (subj == "delivered")
                     {
                     {
                         float profit = my_profit / 100;
                         float profit = (my_profit + 0.0) / 100;
                         float calc = buyer_paid + 0.0;
                         float calc = buyer_paid + 0.0;
                         float a = calc * profit;
                         float a = calc * profit;
                         float b = buyer_paid - a;
                         float b = buyer_paid - a;
                         llGiveMoney( CREATOR, (integer)a );
                         llGiveMoney( CREATOR, llFloor((integer)a) );
                         llInstantMessage(ID,"Accept your purchased items");
                         llInstantMessage(ID,"Accept your purchased items");
                         totalsold = totalsold + 1;
                         totalsold = totalsold + 1;
                         llInstantMessage(OWNER, (string)llKey2Name(ID) + " has paid " + (string)buyer_paid + "L$ in "+ llGetRegionName() + " and you have recived " + (string)llRound(b) + "L$ from this sale");
                        llSetObjectDesc((string)totalsold);
                         llInstantMessage(CREATOR, (string)llKey2Name(ID) + " has paid " + (string)buyer_paid + "L$ in "+ llGetRegionName() + " and you have recived " + (string)llRound(a) + "L$ from this sale");
                         llInstantMessage(OWNER, (string)llKey2Name(ID) + " has paid " + (string)buyer_paid + "L$ in "+ llGetRegionName() + " and you have recived " + (string)llCeil(b) + "L$ from this sale");
                         llInstantMessage(CREATOR, (string)llKey2Name(ID) + " has paid " + (string)buyer_paid + "L$ in "+ llGetRegionName() + " and you have recived " + (string)llFloor(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 Ready1;
                     }   
                     }   
             }
             }
Line 244: Line 280:
                 state default;         
                 state default;         
             }                           
             }                           
}</lsl>}}
{{box|Updater Script for Reseller vendor|
Place this script in a box you've created.<br><br>
What it does:
# when rezzed next to the vendor, it will try to update the vendors URL string.
# when vendor gets the URL, the updater dies. It doesn't die until the vendor is updated.
<lsl>////////////////////////////////////////////////////////////////////////////////////////////////
//    Copyright (c) 2008 by Kristy Fanshaw                                                    //
//    This script is part of Vendor System.                                                  //
////////////////////////////////////////////////////////////////////////////////////////////////
//    Vendor System is free software: you can redistribute it and/or modify                  //
//    it under the terms of the GNU General Public License as published by                    //
//    the Free Software Foundation, either version 3 of the License, or                      //
//    (at your option) any later version.                                                    //
//                                                                                            //
//    Vendor System is distributed in the hope that it will be useful,                        //
//    but WITHOUT ANY WARRANTY; without even the implied warranty of                          //
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                          //
//    GNU General Public License for more details.                                            //
//                                                                                            //
//    To get a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.    //
////////////////////////////////////////////////////////////////////////////////////////////////
string URL = "http://www.my-web.com/my-secret-webpages/my-sl-stuff/my-vendor-name/";      // Write here the URL of the page where is defined the server email address
string update_box = "update box name";                                                    // Write here the name you like, but be sure the name here matches with a name in vendor script
integer Ch;
integer listen_handle;
default
    {
        state_entry ()
            {
                Ch =  ( -1 * (integer)("0x"+llGetSubString((string)llGetCreator(),-7,-1)) );
                listen_handle = llListen(Ch,"", NULL_KEY, "");
                llSetObjectName(update_box);
                llSetText("Updating your vendor\n\nPlease Wait ...", <1.0, 1.0, 1.0>, 1.0);
            }
        listen( integer channel, string name, key id, string message )
            {
                if(message == "update")
                    {
                        llShout(Ch, URL);
                    }       
                else if (message == "updated")
                    {
                        llDie();
                    }
            }
}</lsl>}}
{{box|Server Script and Mailer Script for "Server Object"|
Place these scripts into a box you've created as a server prim.<br>
Place the object you'd like to sell into this prim - only one object<br><br>
Server Script:
# when rezzed, it will tell you it's email address.
# when this scrpt gets an email from the vendor, it gives the inventory item to buyer and asks mailer script to send a note back to vendor that the delivery is done.
# when touched by the owner, it says totalsold.
<lsl>////////////////////////////////////////////////////////////////////////////////////////////////
//    Copyright (c) 2008 by Kristy Fanshaw                                                    //
//    This script is part of Vendor System.                                                  //
////////////////////////////////////////////////////////////////////////////////////////////////
//    Vendor System is free software: you can redistribute it and/or modify                  //
//    it under the terms of the GNU General Public License as published by                    //
//    the Free Software Foundation, either version 3 of the License, or                      //
//    (at your option) any later version.                                                    //
//                                                                                            //
//    Vendor System is distributed in the hope that it will be useful,                        //
//    but WITHOUT ANY WARRANTY; without even the implied warranty of                          //
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                          //
//    GNU General Public License for more details.                                            //
//                                                                                            //
//    To get a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.    //
////////////////////////////////////////////////////////////////////////////////////////////////
string my_address = "my.email@email.com";      // Write here the email, where you want to recieve the message with new server email address.
integer total_mailers = 5;                      // How many mailer scripts you have in server prim. 5 mailer scripts are Recomended min. because of llEmail function.
integer mailer = 1;                           
default
    {
        changed(integer change)
            {
                if(change && CHANGED_OWNER)
                    {
                        llSetObjectDesc("0");
                        llResetScript();
                    }     
            }
        on_rez(integer start_parameter)
            {
                llOwnerSay("new email is: " + (string)llGetKey() + "@lsl.secondlife.com");
                llEmail(my_address,llGetObjectName() , "my new email is: " + (string)llGetKey() + "@lsl.secondlife.com");
                llOwnerSay("message with new address is sent to your email");
            }
        state_entry()
            {             
                llSetObjectName(llGetInventoryName(INVENTORY_OBJECT,0));
                llSetText(llGetObjectName(),<1,1,1>,1);
                totalsold = (integer)llGetObjectDesc();
                llOwnerSay("new email is: " + (string)llGetKey() + "@lsl.secondlife.com");
                llEmail(my_address,llGetObjectName() , "my new email is: " + (string)llGetKey() + "@lsl.secondlife.com");
                llOwnerSay("message with new address is sent to your email");
                llSetTimerEvent(5.0);             
            }
        timer()
            {
                llGetNextEmail("", "");
            }
        email( string time, string address, string subj, string message, integer num_left )
            {
                llGiveInventory(subj,llGetInventoryName(INVENTORY_OBJECT,0) );
                message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") +1);
                llMessageLinked(LINK_THIS, mailer, message, "");
                if (mailer <= total_mailers)
                    {
                        mailer = mailer + 1;
                    }
                if (mailer >= total_mailers + 1)
                    {
                        mailer = 1; 
                    }
                totalsold = totalsold + 1;
                llSetObjectDesc((string)totalsold);
                llGetNextEmail("", "");
            }
        touch_start(integer total_number)
            {
                if (llDetectedOwner(0) == llGetOwner())
                    {
                        llOwnerSay((string)totalsold +" units have been sold since server update. ");
                    }
                else
                    {
                        llInstantMessage(llDetectedKey(0), "please don't touch");
                    }
            }
}</lsl>
}</lsl>
Mailer script.<br>
# Make as many numbers of mailer sciprts you need and place them into server object.<br>
# Name them with numbers starting from number "1".<br>
# Don't skip any numbers: if you have 5 mailer scripts in you server object then you their names should be 1, 2, 3, 4 and 5.


==Updater Script for Reseller vendor==
<lsl>////////////////////////////////////////////////////////////////////////////////////////////////
Place this script in a Vendor Root prim.
//    Copyright (c) 2008 by Kristy Fanshaw                                                    //
//    This script is part of Vendor System.                                                  //
////////////////////////////////////////////////////////////////////////////////////////////////
//    Vendor System is free software: you can redistribute it and/or modify                  //
//    it under the terms of the GNU General Public License as published by                    //
//    the Free Software Foundation, either version 3 of the License, or                      //
//    (at your option) any later version.                                                    //
//                                                                                            //
//    Vendor System is distributed in the hope that it will be useful,                        //
//    but WITHOUT ANY WARRANTY; without even the implied warranty of                          //
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                          //
//    GNU General Public License for more details.                                            //
//                                                                                            //
//    To get a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.   //
////////////////////////////////////////////////////////////////////////////////////////////////
                       
string mailer_num;


<lsl>
default
</lsl>
    {
        link_message(integer sender_num, integer num, string msg, key id)
            {
                mailer_num = llGetScriptName();
                if (num == (integer)mailer_num)
                    {
                        llEmail(msg,"delivered", (string)num);
                    }
            }
}</lsl>}}

Latest revision as of 02:52, 8 April 2009

Copying Permission

Copyright © 2008 by Kristy Fanshaw

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

To get a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.

Pay Script for Reseller vendor

Updater Script for Reseller vendor

Server Script and Mailer Script for "Server Object"