User:Fred Gandt/Scripts/Continued 4

From Second Life Wiki
Jump to navigation Jump to search
FG jpg.jpg

My Contributions

I have implemented a V# system to make it more obvious if a script is updated. The V# forms part of the title of each script.

If you have any comments about the content of this page please post them HERE

More Pages

Free Scripts (content constantly updating)

More Free Scripts (content constantly updating)

Even More Free Scripts (content constantly updating)

Even More More Free Scripts (content constantly updating)

Legal Stuff

The legal stuff about contributing to this wiki (worth reading).

Tuition

Tuition scripts, notes, videos and screenshots etc. (hardly any content yet)

Free Scripts

Campsite ( V1 )

Use of these scripts may or may not cause you to breach the Terms of Service of SL. See HERE. If you can work out what is allowed and what isn't you are far smarter than me!

It is my opinion that the object these scripts create would constitute a game that does not in its self constitute gambling and thus can be used to encourage residents to remain within range of the object in order that they can continue to play the game. Seems like fair traffic to me. That however is just my opinion.

THIS IS A FIRST DRAFT....!!EXPECT BUGS!!

TELL ME ABOUT THEM (If they crop up) AND I CAN FIX THEM

  • Camping!! A great idea for boosting your traffic scores when just starting out in SL business. Traffic scores are added to by avatars being present on your land for periods of time measured in 5 minute chunks. These scripts will act fairly toward the user and the owner since, every 5 minutes someone is logged on as a camper they will earn the amount the owner specifies for that 5 minute chunk.
  • Registered BOTS (Scripted agents) do not count toward traffic. Unregistered bots will (as far as I know). These scripts issue a test to all logged in campers every 5 minutes that a bot almost certainly could not pass by its self (although it could ask for help from its user). I have included this function because people have come to expect it (not because I think it is a good idea). Genuine bot protection is practically impossible. I enjoyed writing the scripts though so all is well!
  • The test is issued as a request to interact with the object to highlight a word found in a "Wordsearch" texture. If the camper doesn't respond or gets the answer wrong (2 chances are given per test) they are automatically logged out.
  • The camper is paid automatically whenever they are logged out. They will be logged out if they leave the campsite (the whole parcel the scripts are set on) or log out (including crashes) of SL. They will only be paid per FULL 5 minutes as staying an extra 4 minutes wouldn't be counted toward the traffic. Campers are paid from the owner's account balance.

Campsite Builder

To create the starter object, create a fresh prim and drop this script on it. The script will self delete.

<lsl>// V1 //

default {

   state_entry()
   {
       llSetPrimitiveParams([7,<4.0, 0.01, 2.0>,
                             9,0,0,<0.375, 0.875, 0.0>,0.0,<0.0, 0.0, 0.0>,<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,
                             17,0,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                             17,1,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                             17,2,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                             17,3,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                             17,4,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                             17,5,"f0863bb8-141a-e705-7fe1-3ac3212b503e",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                             17,6,"e81341cc-5673-10ff-cc11-0e34d6674fcb",<1.0, 1.0, 0.0>,<0.0, 0.0, 0.0>,0.0,
                             18,0,<0.0, 0.0, 0.0>,1.0,
                             18,1,<0.0, 0.0, 0.0>,1.0,
                             18,2,<0.0, 0.0, 0.0>,1.0,
                             18,3,<0.0, 0.0, 0.0>,1.0,
                             18,4,<0.0, 0.0, 0.0>,1.0,
                             18,5,<0.04, 0.16, 1.0>,1.0,
                             18,6,<1.0, 1.0, 1.0>,1.0,
                             20,0,0,
                             20,1,0,
                             20,2,0,
                             20,3,0,
                             20,4,0,
                             20,5,1,
                             20,6,1]);
       llRemoveInventory(llGetScriptName());
   }

}</lsl>

Messaging

This script deals with ALL the instant messaging for the other two scripts (below this). It is short and simple but, absolutely necessary.

<lsl>// V1 //

default {

   link_message(integer sender, integer num, string str, key id)
   {
       if(num == 2468)
       llInstantMessage(id, str);
   }

}</lsl>

Campsite

This script deals with logged campers, owner permissions (to debit your account), owner's instructions etc. It also deals with remote ON/OFF switching via email. So if you need to shut it down but cannot log on for whatever reason you can switch it ON/OFF by emailing it. The script needs to know what email address to respond to so, you need to fill those details out. The email instructions are simple...

The campsite will tell you its email address as the script is set running. Make a note of it.

Instructions are sent to the campsite as the subject line of the email you send (no actual message is required). A confirmation email will be sent back. Refresh your inbox after sending the instruction to confirm it was received. Be reasonably patient.

  • "shutdown" - Will shut the campsite down.
  • "startup" - Will open the campsite for use.

If the owner touches the login side (that will make more sense when you see the object) of the campsite they will not be logged in but, will be given a dialog menu with the option to shut or open the campsite depending on its current state.

<lsl>// V1 //

integer max_campers = 5; // Maximum number of slots for campers (e.g. 5 = 5 avatars).

integer lindens_per_5_mins = 5; // The number of L$ to pay an avatar for 5 minutes camping.

string e_master = "my_email_address@my_email_service.com"; // The email address you will/might send email instructions from.

key WS_UUID = "f0863bb8-141a-e705-7fe1-3ac3212b503e"; // The UUID of the texture used for the wordsearch.

/////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////DON'T DO ANYTHING TO THE REST OF THIS SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////

string vacancy = "/me ** A vacancy has opened up! **";

integer tracking;

integer perms;

integer open;

integer lis;

integer RTC;

string parcel;

vector where;

key owner;

list logged;

integer InRange(key id) {

   if(llGetAgentSize(id) != ZERO_VECTOR)
   {
       if(llList2String(llGetParcelDetails(llList2Vector(llGetObjectDetails(id, [OBJECT_POS]), 0), [PARCEL_DETAILS_NAME]), 0) == parcel)
       {
           if(llOverMyLand(id))
           return TRUE;
       }
   }
   return FALSE;

}

LogOut(key id, integer i) {

   integer time = llList2Integer(logged, (i + 1));
   integer earned = (llFloor(((float)(time / 5))) * lindens_per_5_mins);
   if(earned)
   {
       if(perms)
       llGiveMoney(id, earned);
       else
       {
           llMessageLinked(-1, 2468, "\nLOSS OF PERMISSIONS *shrugs*\nYou owe secondlife:///app/agent/" +
           ((string)id) + "/about - L$" + ((string)earned), owner);
           ShutDown(FALSE);
           return;
       }
   }
   logged = llDeleteSubList(logged, i, (i + 2));
   if(!llGetListLength(logged))
   {
       tracking = FALSE;
       llSetTimerEvent(30.0);
   }
   llMessageLinked(-1, 36912, "", id);
   llMessageLinked(-1, 2468, "\nYou have stopped camping!" +
   "\nAs agreed you are being paid " + ((string)earned) + "L$ for " + ((string)time) + " minutes camping." +
   "\nPlease come again soon!", id);
   --RTC;
   llSay(0, vacancy);

}

ShutDown(integer e) {

   open = FALSE;
   RTC = max_campers;
   tracking = FALSE;
   llSetTimerEvent(0.0);
   llResetOtherScript("Wordsearch");
   while(llGetListLength(logged))
   {
       key id = llList2Key(logged, 0);
       if(id)
       {
           integer time = llList2Integer(logged, 1);
           integer earned = (llFloor(((float)(time / 5))) * lindens_per_5_mins);
           if(earned)
           {
               if(perms)
               llGiveMoney(id, earned);
               else
               llMessageLinked(-1, 2468, "\nLOSS OF PERMISSIONS *shrugs*\nYou owe secondlife:///app/agent/" +
               ((string)id) + "/about - L$" + ((string)earned), owner);
           }
           logged = llDeleteSubList(logged, 0, 2);
           llMessageLinked(-1, 2468, "\nThe owner has shut the campsite." +
           "\nAs agreed you are being paid " + ((string)earned) + "L$ for " + ((string)time) + " minutes camping." +
           "\nPlease come again soon!", id);
       }
   }
   if(e)
   llEmail(e_master, "ShutDown Complete!", "");
   else
   llMessageLinked(-1, 2468, "\nShutDown Complete!", owner);
   llSetTimerEvent(30.0);

}

StartUp(integer e) {

   open = TRUE;
   RTC = 0;
   if(e)
   llEmail(e_master, "StartUp Complete!", "");
   else
   llMessageLinked(-1, 2468, "\nStartUp Complete!", owner);
   llSay(0, vacancy);

}

Track() {

   integer count;
   integer to_track = llGetListLength(logged);
   do
   {
       key agent = llList2Key(logged, count);
       integer index = llListFindList(logged, [agent]);
       if(!InRange(agent))
       LogOut(agent, index);
       else
       {
           integer min = llAbs((integer)llGetSubString(llGetTimestamp(), 14, 15));
           integer last = llList2Integer(logged, (index + 2));
           integer extra = (min - last);
           if(extra == -59)
           extra = 1;
           integer total = llList2Integer(logged, (index + 1));
           logged = llListReplaceList(logged, [(total + extra), min], (index + 1), (index + 2));
           if((extra) && (!(total % 5)) && (total != 0))
           llMessageLinked(-1, 0, "foo", agent);
       }
       count = (count + 3);
   }
   while(count < to_track);

}

default {

   on_rez(integer param)
   {
       llResetScript();
   }
   state_entry()
   {
       owner = llGetOwner();
       where = llGetPos();
       parcel = llList2String(llGetParcelDetails(where, [PARCEL_DETAILS_NAME]), 0);
       llRequestPermissions(owner, PERMISSION_DEBIT);
   }
   run_time_permissions(integer p)
   {
       if(p & PERMISSION_DEBIT)
       {
           perms = TRUE;
           open = TRUE;
           llMessageLinked(-1, 2468, "\nMy email address is - " + ((string)llGetKey()) + "@lsl.secondlife.com", owner);
           llSetTimerEvent(30.0);
       }
       else
       {
           llMessageLinked(-1, 2468, "\nPermissions to debit your account MUST be granted for this script to function.", owner);
           llRequestPermissions(owner, PERMISSION_DEBIT);
       }
   }
   touch_start(integer nd)
   {
       if(llDetectedTouchFace(0) != 5)
       {
           integer count;
           do
           {
               key id = llDetectedKey(count);
               if(id != owner)
               {
                   if(InRange(id))
                   {
                       integer index = llListFindList(logged, [id]);
                       if(index != -1)
                       {
                           integer time = llList2Integer(logged, (index + 1));
                           integer earned = (llFloor(((float)(time / 5))) * lindens_per_5_mins);
                           llMessageLinked(-1, 2468, "\nYou have clocked " + ((string)time) + " minutes." + 
                           "\nYou would be paid " + ((string)earned) + "L$ if you left now.", id);
                       }
                       else
                       {
                           if(((++RTC) <= max_campers) && perms)
                           llMessageLinked(-1, 0, "foo", id);
                           else
                           {
                               --RTC;
                               llMessageLinked(-1, 2468, "\nThere are no camping slots available at this time.", id);
                           }
                       }
                   }
                   else
                   llMessageLinked(-1, 2468, "\nYou must be within \"" + parcel + "\" to log in.", id);
               }
               else
               {
                   list buttons = ["Nothing"];
                   lis = llListen(-8365583, llKey2Name(owner), owner, "");
                   if(open)
                   buttons += ["ShutDown"];
                   else
                   buttons += ["StartUp"];
                   llDialog(owner, "\n\nWhat is your bidding?", buttons, -8365583);
               }
           }
           while((++count) < nd);
       }
   }
   listen(integer chan, string name, key id, string msg)
   {
       llListenRemove(lis);
       if(msg != "Nothing")
       {
           if(msg == "ShutDown")
           ShutDown(FALSE);
           else if(msg == "StartUp")
           StartUp(FALSE);
       }
   }
   email(string t, string a, string s, string m, integer n)
   {
       if(a == e_master)
       {
           if(llToLower(s) == "shutdown")
           {
               if(open)
               ShutDown(TRUE);
               else
               llEmail(e_master, "Already ShutDown. Other option is \"StartUp\"", "");
           }
           else if(llToLower(s) == "startup")
           {
               if(!open)
               StartUp(TRUE);
               else
               llEmail(e_master, "Already StartedUp. Other option is \"ShutDown\"", "");
           }
       }
   }
   link_message(integer sender, integer num, string str, key id)
   {
       if((str != "foo") && (num != 2468) && (num != 36912) && (str != "oof"))
       {
           if(!num)
           {
               integer index = llListFindList(logged, [id]);
               if(index != -1)
               LogOut(id, index);
               else
               {
                   --RTC;
                   llMessageLinked(-1, 2468, "\nYou have failed to pass the test." +
                   "\nYou are not logged in to camp.\nTry again?", id);
                   llSay(0, vacancy);
               }
           }
           else
           {
               integer index = llListFindList(logged, [id]);
               if(index == -1)
               {
                   logged += [id, -1, llAbs((integer)llGetSubString(llGetTimestamp(), 14, 15))];
                   llMessageLinked(-1, 2468, "\nYou have begun camping!" + 
                   "\nYou must remain within the parcel - \"" + parcel + "\".\nYou will be paid " +
                   ((string)lindens_per_5_mins) + "L$ for every full " +
                   "5 minutes you are on-site.\nThere will be intermittent re-tests.", id);
               }
               else
               llMessageLinked(-1, 2468, "\nYou have passed this test!", id);
               if(!tracking)
               {
                   tracking = TRUE;
                   llSetTimerEvent(10.0);
               }
           }
       }
   }
   changed(integer change)
   {
       if(change & CHANGED_OWNER)
       llResetScript();
       if(change & CHANGED_TEXTURE)
       {
           if(llList2Key(llGetPrimitiveParams([17, 5]), 0) != WS_UUID)
           {
               if(open)
               ShutDown(FALSE);
               llSleep(0.2);
               llMessageLinked(-1, 0, "oof", owner);
           }
       }
   }
   timer()
   {
       if(tracking)
       Track();
       llGetNextEmail(e_master, "");
   }

}</lsl>

Wordsearcher

This script takes care of the wordsearch tests. You can change the wordsearch texture and configuration to suit your own business or style. There is a basic and simple wordsearch supplied with this script so, it is ready to roll. If you create your own wordsearch, just apply the texture to the correct panel of the object and the scripts will issue instructions to you. Read them ALL and follow them.

I found a site that can automatically and for free create a wordsearch to your specifications very simply. Visit THIS SITE to see how simple it really is. I found copy/pasting the result to a text layer in GIMP and stretching it to fit within a guide grid (10 x 10) on another layer very simple and easy.

  • THE WORDSEARCH MUST BE A 10 x 10 GRID. 10 LETTERS BY 10 LETTERS

Of course you may wish to create a wordsearch from scratch yourself. Good luck with that!

<lsl>// V1 //

// The list below should only be changed if/when the texture is changed to make another wordsearch.

list words = [ "ANIMATION", "59,58,57,56,55,54,53,52,51,", "TELEPORT", "2,12,22,32,42,52,62,72,", "LANDMARK", "71,61,51,41,31,21,11,1,", "MEGAPRIM", "10,20,30,40,50,60,70,80,", "CAMPING", "34,45,56,67,78,89,100,", "TEXTURE", "87,86,85,84,83,82,81,", "AVATAR", "92,93,94,95,96,97,", "REGION", "4,5,6,7,8,9,", "OBJECT", "24,25,26,27,28,29,", "SCRIPT", "14,15,16,17,18,19,", "LINDEN", "79,78,77,76,75,74,", "PARCEL", "44,45,46,47,48,49,", "FURRY", "43,33,23,13,3,", "GROUP", "39,38,37,36,35," ];

/////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////DON'T DO ANYTHING TO THE REST OF THIS SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////

list agents;

list plot_list;

key owner;

string owner_name;

integer lis;

integer coord_count = 0;

string new_coords;

integer lis_by_2;

integer channel = 888;

integer string_length;

TimerControl(float tn) {

   if(!llGetListLength(agents))
   llSetTimerEvent(0.0);
   else
   {
       float nt = llList2Float(agents, 4);
       if(tn < nt)
       llSetTimerEvent((60.0 - ((60.0 - nt) + tn)));
       else
       llSetTimerEvent((60.0 - (tn - nt)));
   }

}

default {

   on_rez(integer param)
   {
       llResetScript();
   }
   changed(integer change)
   {
       if(change & CHANGED_OWNER)
       llResetScript();
   }
   state_entry()
   {
       owner = llGetOwner();
       owner_name = llKey2Name(owner);
   }
   link_message(integer sender, integer num, string str, key id)
   {
       if(str == "foo")
       {
           if(llListFindList(agents, [id]) == -1)
           {
               agents += [id];
               list strided = llList2ListStrided(words, 0, -1, 2);
               integer index = (llRound(llFrand(((float)(llGetListLength(strided) - 1)))));
               string word = llList2String(strided, index);
               index = (llListFindList(words, [word]) + 1);
               string coords = llList2String(words, index);
               agents += [coords, "", 0];
               llMessageLinked(-1, 2468, "\nPlease click on each letter (in correct spelling order) of the word \"" +
               word + "\" within the next 60 seconds.", id);
               agents += [((float)llGetSubString(llGetTimestamp(), -10, -2))];
               if(llGetListLength(agents) == 5)
               llSetTimerEvent(60.0);
           }
       }
       else if(num == 36912)
       {
           integer index = llListFindList(agents, [id]);
           if(index != -1)
           {
               agents = llDeleteSubList(agents, index, (index + 4));
               TimerControl(((float)llGetSubString(llGetTimestamp(), -10, -2)));
           }
       }
       else if(str == "oof")
       {
           lis = llListen(channel, owner_name, owner, "");
           lis_by_2 = llListen((channel * 2), owner_name, owner, "DONE");
           llMessageLinked(-1, 2468, ("\nPlease say the first word you want to plot on channel " + ((string)channel)), owner);
       }
   }
   listen(integer chan, string name, key id, string msg)
   {
       if(chan == channel)
       {
           if(!llGetListLength(plot_list))
           {
               plot_list = ["list words = ["];
               llDialog(owner, "\nClick \"DONE\" when you have FINISHED plotting ALL OF the new Wordsearch", ["DONE"], (channel * 2));
           }
           plot_list += [("\"" + llStringTrim(msg, STRING_TRIM) + "\"")];
           string_length = llStringLength(llStringTrim(msg, STRING_TRIM));
           llMessageLinked(-1, 2468, ("\nNow click each letter (in correct spelling order) of \"" +
           llStringTrim(msg, STRING_TRIM)) + "\".", owner);
       }
       else if((chan == (channel * 2)) && (msg == "DONE"))
       {
           llListenRemove(lis);
           llListenRemove(lis_by_2);
           plot_list += ["];"];
           llMessageLinked(-1, 2468, ("\nPlease paste this list into this script to replace the \"words\" list and click \"Save\".\n\n" +
           llList2String(plot_list, 0) + "\n" + llDumpList2String(llList2List(plot_list, 1, -1), ",\n") + "\n"), owner);
           plot_list = [];
           llMessageLinked(-1, 2468, ("\nPlease paste this to replace the WS_UUID in the \"Campsite\" script and click \"Save\".\n\n" +
           "key WS_UUID = \"" + ((string)llList2Key(llGetPrimitiveParams([17, 5]), 0)) + "\";\n"), owner);
       }
   }
   touch_start(integer nd)
   {
       integer count;
       do
       {
           if(llDetectedTouchFace(count) == 5)
           {
               if(!llGetListLength(plot_list))
               {
                   integer index = llListFindList(agents, [llDetectedKey(count)]);
                   if(index != -1)
                   {
                       vector v = llDetectedTouchUV(0);
                       integer coord = ((llFloor(v.x * 10.0) * 10) + llFloor(v.y * 10.0) + 1);
                       string coord_so_far = (llList2String(agents, (index + 2)) + (((string)coord) + ","));
                       agents = llListReplaceList(agents, [coord_so_far], (index + 2), (index + 2));
                       if(coord_so_far == llList2String(agents, (index + 1)))
                       {
                           llMessageLinked(-1, 1, "", llList2Key(agents, index));
                           agents = llDeleteSubList(agents, index, (index + 4));
                           TimerControl(((float)llGetSubString(llGetTimestamp(), -10, -2)));
                       }
                   }
               }
               else
               {
                   if(llDetectedKey(count) == owner)
                   {
                       vector v = llDetectedTouchUV(0);
                       integer coord = ((llFloor(v.x * 10.0) * 10) + llFloor(v.y * 10.0) + 1);
                       new_coords += (((string)coord) + ",");
                       if((++coord_count) == string_length)
                       {
                           coord_count = 0;
                           plot_list += ["\"" + new_coords + "\""];
                           new_coords = "";
                           llMessageLinked(-1, 2468, "\nSay the next word on 888 OR click \"DONE\" if finished.", owner);
                       }
                   }
               }
           }
       }
       while((++count) < nd);
   }
   timer()
   {
       key agent = llList2Key(agents, 0);
       integer index = llListFindList(agents, [agent]);
       if(!llList2Integer(agents, (index + 3)))
       {
           list entry = llListReplaceList(llList2List(agents, index, (index + 4)), ["", 1], 2, 3);
           agents = llDeleteSubList(agents, index, (index + 4));
           agents += entry;
           llMessageLinked(-1, 2468, "\nYou have not entered the correct word." +
           "\nYou have 1 more chance." + 
           "\nYou have 60 more seconds.", agent);
       }
       else
       {
           llMessageLinked(-1, 0, "", agent);
           agents = llDeleteSubList(agents, index, (index + 4));
       }
       TimerControl(((float)llGetSubString(llGetTimestamp(), -10, -2)));
   }

}</lsl>

More Scripts...

Free Scripts

More Free Scripts

Even More Free Scripts

Even More More Free Scripts

If you have any comments about the content of this page please post them HERE