MLPV2 Give Items in Folder to a Specific Person

From Second Life Wiki
Revision as of 13:42, 3 September 2011 by Chaz Longstaff (talk | contribs) (Created page with "<lsl> //add-on by Chaz Longstff for MLPV2 by Lear Cale. August 2011. Give 2 v.001 //Function: gives object to a specific person on an MLPV2 ball // //in a menu card, format a men…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<lsl> //add-on by Chaz Longstff for MLPV2 by Lear Cale. August 2011. Give 2 v.001 //Function: gives object to a specific person on an MLPV2 ball // //in a menu card, format a menu button like this, for example: //LINKMSG MyButtonName | 0,-4,987789,Cuff1#Cuff2#Cuff3#Cuff4##FolderName##Wear these four cuffs.##0 //In this example, MyButtonName is the button name //0 means whether to make the MLPV2 menu go away or not. Generally set it to 0 as per the example, so the menu comes back (taking advantage of new 2.x and higher viewers). To make the MLPV2 menu go away, use 1 instead. //-4 -- the value of LINK_THIS, meaning, send this message to this prim only. (Use -1 if the ~give2 script is in a different prim.) //987789 -- don't change this, this is the communication channel //Cuff1#Cuff2#Cuff3#Cuff4 -- (The items to give are separated by a single # //##FolderName: the name of the folder to put the stuff in. Note that it needs to be preceded by a double ##. //##Wear these four cuffs -- Msg to receiver. (Note that it needs to be preceded by a double ##. It's good to include a msg, so that they don't think it's a griefer trying to hand them something. However, you can leave this param blank if you wish. //##0 -- (offer to person on which ball? 0, 1, 2, 3, 4, 5 . You can leave blank if the person to receive is the person who is operating the menu, this is default behaviour.)

//parameters string ObjectToGive; string message; integer x; list Avnames = ["", "", "", "", "", ""]; key GiveToID;


addAv(string id, integer ballIx) {

   Avnames = llListReplaceList(Avnames, (list)id, ballIx, ballIx);

}

removeAv(integer ballIx) {

   addAv("", ballIx);

} //_________________________ default{

  link_message(integer from, integer num, string str, key id) { 
  
   if (num == -11000) {
           // av hopped on
           list parms = llParseStringKeepNulls(str, ["|"], []);
           integer ballnum = (integer)llList2String(parms, 0);
           // string anim = llList2String(parms, 1);     // anim name parameter, if desired
           //debug(4, llKey2Name(dkey) + ": on ball " + (string)ballnum);
           addAv((string)id, ballnum);
           return;
       } else if (num == -11001) {
           // av hopped off
           //debug(4, llKey2Name(dkey) + ": off ball " + str);
           removeAv((integer)str);
           return;
       }
      else if (num == 987789) {
           string idtogiveto = "";
           list TempList = llParseStringKeepNulls(str,["##"],[]);
           string Objects = llStringTrim(llList2String(TempList, 0),STRING_TRIM);
           list ObjectsToGive = llParseStringKeepNulls(Objects,["#"],[]);
           integer GiveLength = llGetListLength(ObjectsToGive);
           string FolderName = llStringTrim(llList2String(TempList, 1),STRING_TRIM);
           message = llStringTrim(llList2String(TempList, 2),STRING_TRIM);
           string ball = llStringTrim(llList2String(TempList, 3),STRING_TRIM);
           if (ball != "") {
               idtogiveto = llStringTrim(llList2String(Avnames,(integer)ball),STRING_TRIM);
           }
           //llSay(0, idtogiveto);
           if (idtogiveto == "") {
               GiveToID = id;
               //llSay(0, (string)GiveToID);
           }
           
           else GiveToID = (key)idtogiveto;
           if (GiveLength != 0) {
               if (message != "") {
                  llInstantMessage(GiveToID,message + " " + llList2CSV(ObjectsToGive));
               }
           llGiveInventoryList(GiveToID, FolderName, ObjectsToGive);
           }//end of checking GiveLength
      } //end of if check for the right channel
  } //end link_message event

} //end default state


</lsl>