Difference between revisions of "MLPV2 Give Item Add-on"

From Second Life Wiki
Jump to navigation Jump to search
(added ability to give multiple items at once)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
* Back to [[MLPV2]]
* Back to [[MLPV2_Addons]]


Add on tool for MLPV2 that puts a button on the MLPV2 menu that, when clicked, gives a user an object (or multiple objects) that you wish them to use with an animation.
Add on tool for MLPV2 that puts a button on the MLPV2 menu that, when clicked, gives a user an object (or multiple objects) that you wish them to use with an animation. If you are giving multiple items, they are giving in succession one after the other -- that is, each is given separately, rather than all being given at once in a folder.


By Chaz Longstaff, June 2008.
By Chaz Longstaff, June 2008.




Example: LINKMSG TieMeUp | 1,-4,987789,Cuff1#Cuff2#Cuff3#Cuff4##Wear these four cuffs.<br />
Example:
LINKMSG TieMeUp | 1,-4,987789,Cuff1#Cuff2#Cuff3#Cuff4##Wear these four cuffs.<br />


Steps to use:<br />
Steps to use:<br />
Line 14: Line 15:
#Add to the menu in an MLPV2 menu notecard the following line:<br />
#Add to the menu in an MLPV2 menu notecard the following line:<br />


LINKMSG MyButtonName | 1,-4,987789,NamesOfObjectToOffer##MsgToPerson<br />
LINKMSG MyButtonName | 1,-4,987789,NamesOfObjectToOffer##MsgToPerson<br />


 
In the above line, there are three elements for you to customize:
In the above line, there are three elements for you to customize as appropriate:
*MyButtonName -- the wording that you want to appear for the button on the blue menu
*MyButtonName -- the wording that you want to appear for the button on the blue menu
*NamesOfObjectToOffer -- the name(s) (case and spacing sensitive) of the object(s) you are offering. If you are offering more than one, separate them with a hache (aka number, aka pound) sign # . Example: Item01#Item02#Item03
*NamesOfObjectToOffer -- the name(s) (case and spacing sensitive) of the object(s) you are offering. If you are offering more than one, separate them with a hash mark (aka number sign, pound sign) # . Example: Item01#Item02#Item03 . If you are not offering more than one, don't use a # separator here.
*MsgToPerson -- A message to be instant messaged to the person being offered the item, so they know what it is for, and don't think it's a random spammer or griefer passing by, etc.
*MsgToPerson -- A message to be instant messaged to the person being offered the item, so they know what it is for, and don't think it's a random spammer or griefer passing by, etc.


Note that NamesOfObjectToOffer and MsgToPerson are separated by a ## separator (two hache symbols.)
Note that NamesOfObjectToOffer and MsgToPerson are separated by a ## separator (two hash marks.)




What you don't need to change in the above sample line:
What you don't need to change in the above sample line:
* 1 -- makes it so the MLPV2 menu doesn't reappear, so the user can see the accept-object menu
* 1 -- makes it so the MLPV2 menu doesn't reappear, so the user can see the accept-object menu
* -4 -- the value of LINK_THIS, meaning, send this message to this prim only.  (Use -4 if the ~give script is in a different prim.)
* -4 -- the value of LINK_THIS, meaning, send this message to this prim only.  (Use -2 if the ~give script is in a different prim.)
* 987789 -- This is the number the ~give script looks for to detect a message to it.
* 987789 -- This is the number the ~give script looks for to detect a message to it.




_______________________________________________________<br />
<lsl>
_______________________________________________________<br />
// Add-on by Chaz Longstff for MLPV2 by Lear Cale. June 2008.
// Function: gives object to someone on an MLPV2 ball
// MLP button: LINKMSG MyButtonName | 1,-4,987789,NamesOfObjectToOffer##MsgToPerson
 
// In a menu card, format a menu button like this, for example:
// LINKMSG TieMeUp | 1,-4,987789,Cuff1#Cuff2#Cuff3#Cuff4##Wear these four cuffs.
// In this example, TieMeUp is the button name
//    1 means whether to make the MLPV2 menu go away or not.
//      Generally set it to 1 as per the example, as otherwise the user
//      might not see the accept prompt for the inventory being given.
//    -4 is the value of LINK_THIS, meaning, send this message to this prim only.
//      (Use -1 if the ~give script is in a different prim.)
//    987789 -- don't change this, this is the link message number
//    Cuff1#Cuff2#Cuff3#Cuff4##Wear these four cuffs.
//      The items separated by # are the items to give,
//      followed by a message to be instant messaged to the recipient
//      of the object. It's good to include a msg, so that they don't think
//      it's a griefer trying to hand them something. Notice that the list
//      of objects to give and the accompanying msg, are separated by ##
 
default{
  link_message(integer from, integer num, string str, key id) {
      if (num == 987789) {
          list    TempList = llParseStringKeepNulls(str,["##"],[]);
          string  message = llStringTrim(llList2String(TempList, 1),STRING_TRIM);
          string  Objects = llStringTrim(llList2String(TempList, 0),STRING_TRIM);
          list    ObjectsToGive = llParseStringKeepNulls(Objects,["#"],[]);
          integer GiveLength = llGetListLength(ObjectsToGive);
          if (GiveLength != 0) {
              if (message != "") {
                  llInstantMessage(id,message + " " + llList2CSV(ObjectsToGive));
              }
              integer x;
              for (x = 0; x < GiveLength; x++) {
                    string ObjectToGive = llStringTrim(llList2String(ObjectsToGive, x),STRING_TRIM);
                    if ( ( llGetInventoryType(ObjectToGive) != INVENTORY_NONE)
                    &&  ( llGetInventoryPermMask(ObjectToGive, MASK_NEXT) & PERM_COPY) ) {
                        llGiveInventory(id,ObjectToGive);
                    }
                }//end of for
            }//end of checking GiveLength
      } //end of if check for the right channel
  } //end link_message event
} //end default state
</lsl>


//add-on by Chaz Longstff for MLPV2 by Lear Cale. June 2008.<br />
[[Category:MLPV2]]
//Function: gives object to someone on an MLPV2 ball<br />
//in a menu card, format a menu button like this, for example:<br />
//LINKMSG Give Book | 1,-4,987789,little book(wear)##Wear This<br />
//In this example, Give Book is the button name<br />
//1 means whether to make the MLPV2 menu go away or not.<br />
//Generally set it to 1 as per the example, as otherwise the user<br />
//might not see the accept prompt for the inventory being given<br />
//-4 -- the value of LINK_THIS, meaning, send this message to this prim only.  (Use -1 if the ~give script is in a different prim.)
//987789 -- don't change this, this is the communication channel<br />
//little book(wear)##Wear This -- this is the item to give,<br />
//followed by a message to be instant messaged to the recipient<br />
//of the object. It's good to include a msg, so that they don't just think<br />
//it's a griefer trying to hand them something. Notice that the object to give,<br />
//and the accompanying msg, are separated by ##<br />
//parameters
string ObjectToGive;
string message;
//_________________________
default{
    link_message(integer from, integer num, string str, key id) {
        if (num == 987789) {
            list TempList = llParseStringKeepNulls(str,["##"],[]);
            ObjectToGive = llStringTrim(llList2String(TempList, 0),STRING_TRIM);
            message = llStringTrim(llList2String(TempList, 1),STRING_TRIM);
            if (  ( llGetInventoryType(ObjectToGive) != INVENTORY_NONE)
            && ( llGetInventoryPermMask(ObjectToGive, MASK_NEXT) & PERM_COPY)
            && ( llGetInventoryPermMask(ObjectToGive, MASK_NEXT) & PERM_COPY) ) {
                if (message != "") {
                    llInstantMessage(id,message + " " + ObjectToGive);
                }
                llGiveInventory(id,ObjectToGive);
            }
        } //end of if check for the right channel
    } //end link_message event
} //end default state

Latest revision as of 16:58, 7 January 2014

Add on tool for MLPV2 that puts a button on the MLPV2 menu that, when clicked, gives a user an object (or multiple objects) that you wish them to use with an animation. If you are giving multiple items, they are giving in succession one after the other -- that is, each is given separately, rather than all being given at once in a folder.

By Chaz Longstaff, June 2008.


Example:

LINKMSG TieMeUp | 1,-4,987789,Cuff1#Cuff2#Cuff3#Cuff4##Wear these four cuffs.

Steps to use:

  1. Copy and paste everything below the double-line on this page into a script called, for the sake of argument, "~give" (the script name is actually irrelevant; you may call it kumquat if you wish;)
  2. Drop the script into the prim where you have the rest of the MLPV2 scripts;
  3. Add the object that you wish to give out. Usually, it is either a prim object, or clothing. Note that this object to be given out needs to have both copy and transfer permissions set on it;
  4. Add to the menu in an MLPV2 menu notecard the following line:
LINKMSG MyButtonName | 1,-4,987789,NamesOfObjectToOffer##MsgToPerson

In the above line, there are three elements for you to customize:

  • MyButtonName -- the wording that you want to appear for the button on the blue menu
  • NamesOfObjectToOffer -- the name(s) (case and spacing sensitive) of the object(s) you are offering. If you are offering more than one, separate them with a hash mark (aka number sign, pound sign) # . Example: Item01#Item02#Item03 . If you are not offering more than one, don't use a # separator here.
  • MsgToPerson -- A message to be instant messaged to the person being offered the item, so they know what it is for, and don't think it's a random spammer or griefer passing by, etc.

Note that NamesOfObjectToOffer and MsgToPerson are separated by a ## separator (two hash marks.)


What you don't need to change in the above sample line:

  • 1 -- makes it so the MLPV2 menu doesn't reappear, so the user can see the accept-object menu
  • -4 -- the value of LINK_THIS, meaning, send this message to this prim only. (Use -2 if the ~give script is in a different prim.)
  • 987789 -- This is the number the ~give script looks for to detect a message to it.


<lsl> // Add-on by Chaz Longstff for MLPV2 by Lear Cale. June 2008. // Function: gives object to someone on an MLPV2 ball // MLP button: LINKMSG MyButtonName | 1,-4,987789,NamesOfObjectToOffer##MsgToPerson

// In a menu card, format a menu button like this, for example: // LINKMSG TieMeUp | 1,-4,987789,Cuff1#Cuff2#Cuff3#Cuff4##Wear these four cuffs. // In this example, TieMeUp is the button name // 1 means whether to make the MLPV2 menu go away or not. // Generally set it to 1 as per the example, as otherwise the user // might not see the accept prompt for the inventory being given. // -4 is the value of LINK_THIS, meaning, send this message to this prim only. // (Use -1 if the ~give script is in a different prim.) // 987789 -- don't change this, this is the link message number // Cuff1#Cuff2#Cuff3#Cuff4##Wear these four cuffs. // The items separated by # are the items to give, // followed by a message to be instant messaged to the recipient // of the object. It's good to include a msg, so that they don't think // it's a griefer trying to hand them something. Notice that the list // of objects to give and the accompanying msg, are separated by ##

default{

  link_message(integer from, integer num, string str, key id) {
      if (num == 987789) {
          list    TempList = llParseStringKeepNulls(str,["##"],[]);
          string  message = llStringTrim(llList2String(TempList, 1),STRING_TRIM);
          string  Objects = llStringTrim(llList2String(TempList, 0),STRING_TRIM);
          list    ObjectsToGive = llParseStringKeepNulls(Objects,["#"],[]);
          integer GiveLength = llGetListLength(ObjectsToGive);
          if (GiveLength != 0) {
              if (message != "") {
                  llInstantMessage(id,message + " " + llList2CSV(ObjectsToGive));
              }
              integer x;
              for (x = 0; x < GiveLength; x++) {
                    string ObjectToGive = llStringTrim(llList2String(ObjectsToGive, x),STRING_TRIM);
                    if ( ( llGetInventoryType(ObjectToGive) != INVENTORY_NONE)
                    &&   ( llGetInventoryPermMask(ObjectToGive, MASK_NEXT) & PERM_COPY) ) {
                        llGiveInventory(id,ObjectToGive);
                    }
               }//end of for
           }//end of checking GiveLength
      } //end of if check for the right channel
  } //end link_message event

} //end default state </lsl>