MLPV2 Give Items in Folder to a Specific Person

* Back to MLPV2_Addons
<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##0##Wear these four cuffs.
//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 ##.
//##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.)
//##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.
//Caution: There is a linden script limit of 255 bytes of info that can be read from a notecard line. Practically speaking, that means you are limited to say maybe 225, 230 characters in total that you can have in this LINKMSG line. So if you are giving several items to wear in one folder, keep the items names short and sweet, or your whole line will get truncated randomly, just cut right off.
 
//parameters 
string ObjectToGive;
string message;
integer x;
list Avnames = ["", "", "", "", "", ""];
key GiveToID;
string FolderName;
addAv(string id, integer ballIx) {
 Avnames = llListReplaceList(Avnames, (list)id, ballIx, ballIx);
}
removeAv(integer ballIx) {
 addAv("", ballIx);
}
myMsg() {
 string name = llGetObjectName();
 llSetObjectName("Blue Balls");
 //change the text "Blue Balls" to anything you like, such as your own Brand Name
 llInstantMessage(GiveToID,message + " " + FolderName);
 if (name != "") llSetObjectName(name);
}
//_________________________
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) {
 //llSay(0, "test:" + str);
 string idtogiveto = "";
 list TempList = llParseStringKeepNulls(str,["##"],[]);
 string Objects = llStringTrim(llList2String(TempList, 0),STRING_TRIM);
 list ObjectsToGive = llParseStringKeepNulls(Objects,["#"],[]);
 integer GiveLength = llGetListLength(ObjectsToGive);
 FolderName = llStringTrim(llList2String(TempList, 1),STRING_TRIM);
 string ball = llStringTrim(llList2String(TempList, 2),STRING_TRIM);
 message = 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 != "") {
 myMsg();
 }
 llGiveInventoryList(GiveToID, FolderName, ObjectsToGive);
 }//end of checking GiveLength
 } //end of if check for the right channel
 } //end link_message event
} //end default state
 
</lsl>
Category:MLPV2