Advertisement
Gayngel

Group Only Vendor

May 3rd, 2015
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. // Group vendor by Gayngel. Full perm and no terms or strings, edit and give away how you like.
  2.  
  3. // This vendor script will receive money and give items to activated group members only. Non-group members will be refunded.
  4.  
  5. // Place the products to be sold in the vendor's contents and grant debit permissions to refund non-group members.
  6.  
  7. //N.B: You must grant debit permissions each time you change or remove the vendor's contents!
  8.  
  9. //----------------------------------------------------------\\
  10. integer Price = 150; //Set price of product here.
  11. string Group ="secondlife:///app/group/04f595b0-cdc8-97f0-e710-9564824c03b2/about"; // Copy and paste your group url here.
  12. integer DebitPerms;
  13.  
  14.  
  15. list inventoryItems;
  16.  
  17. integer index;
  18.  
  19. default
  20. {
  21. state_entry()
  22. {
  23. llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); //Gets permission to refund customers who are not in the group.
  24.  
  25. }
  26.  
  27. run_time_permissions (integer perm)
  28. {
  29. if (perm & PERMISSION_DEBIT)
  30. { DebitPerms = TRUE;
  31. llSetClickAction(CLICK_ACTION_PAY); // Debit permissions were granted then allow the vendor to be paid.
  32.  
  33.  
  34. llSetPayPrice(PAY_HIDE, [Price, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
  35. }
  36. }
  37.  
  38. touch_start(integer num)
  39. {
  40. key id = llDetectedKey(0);
  41.  
  42. if(id == llGetOwner());
  43. {
  44. llResetScript(); //In case the owner didn't allow debit permissions they can touch the script to reset.
  45. }
  46. }
  47.  
  48. money(key id, integer amount)
  49. {
  50. integer sameGroup = llSameGroup(id);
  51. if(!sameGroup) // If not in the same group as the vendor's, refund the customer.
  52. {
  53. llTransferLindenDollars(id, Price);
  54. llInstantMessage(id, "Sorry you are not a group member. Please join and activate the " + Group + " group to purchase this item.");
  55. }
  56.  
  57. else // If in the same group, accept their money and give the customer their purchase.
  58. {
  59.  
  60.  
  61.  
  62. string thisScript = llGetScriptName();
  63. integer inventoryNumber = llGetInventoryNumber(INVENTORY_ALL);
  64. for ( ; index < inventoryNumber; ++index )
  65. {
  66. string itemName = llGetInventoryName(INVENTORY_ALL, index);
  67.  
  68. if (itemName != thisScript)
  69. {
  70. if (llGetInventoryPermMask(itemName, MASK_OWNER) & PERM_COPY) // Checks if objects to be given are copyable. If they aren't they won't be sold.
  71. {
  72. inventoryItems += itemName;
  73. }
  74. else
  75. {
  76. llInstantMessage(llGetOwner(),"Unable to copy the item named '" + itemName + "'. Please add copyable items in this vendor.");
  77. }
  78. }
  79. }
  80.  
  81. if (inventoryItems == [] )
  82. {
  83. llInstantMessage(llGetOwner(), "No copiable items found. Please add copyable items in this vendor.");
  84. llInstantMessage(id, "No copiable items in this vendor, sorry. Refunding you.");
  85. llTransferLindenDollars(id, Price);
  86.  
  87.  
  88. }
  89. else
  90. {
  91. llInstantMessage(id, "Thank you " + llKey2Name(id) + "!");
  92. llGiveInventoryList(id,"Folder Name", inventoryItems);
  93. // Gives all objects in prim's inventory in a folder. Replace "Folder Name" with a name of your product, keeping quotations.
  94. }
  95. }
  96. }
  97.  
  98. changed(integer change)
  99. {
  100. if(change & CHANGED_INVENTORY) //If inventory is added or deleted reset the script.
  101. {
  102. llResetScript();
  103. }
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement