Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.73 KB | None | 0 0
  1. integer sell_type = INVENTORY_OBJECT;
  2. vector text_color = <1,1,1>;
  3. float text_alpha = 1;
  4. list items;
  5. list descriptions;
  6. list prices;
  7. integer notecardline;
  8. integer current_item;
  9.  
  10. Next_Item()
  11. {
  12. current_item++;
  13. if(current_item >= llGetListLength(items))
  14. {
  15. current_item = 0;
  16. }
  17. llSetText(llList2String(descriptions,current_item) + "\n$L" + llList2String(prices,current_item),text_color,text_alpha);
  18. llSetTexture(llList2String(items,current_item) + "PIC",2);
  19. }
  20.  
  21. default
  22. {
  23. state_entry()
  24. {
  25. llSetTexture("d2665d83-d5f5-d0a8-7fb7-89656f2d3f7a",ALL_SIDES);
  26. llSetText("Offline Mode, Nows the time to add/remove items, then click to start.",text_color,text_alpha);
  27. }
  28. touch(integer number)
  29. {
  30. if(llDetectedKey(0) == llGetOwner())
  31. {
  32. state check_items;
  33. }
  34. }
  35. }
  36.  
  37. state check_items
  38. {
  39. state_entry()
  40. {
  41. llSetText("Checking inventory",text_color,text_alpha);
  42. if(llGetInventoryNumber(sell_type) == 0)
  43. {
  44. llOwnerSay("Nothing found in inventory. Reseting.");
  45. llResetScript();
  46. }
  47. if(llGetInventoryKey("_LIST") == NULL_KEY)
  48. {
  49. llOwnerSay("Could not find the _LIST notecard. Remeber the name of the notecard is important and CaSe sensitive.");
  50. llResetScript();
  51. }
  52. else
  53. {
  54. llGetNumberOfNotecardLines("_LIST");
  55. }
  56. }
  57. dataserver(key queryid, string data)
  58. {
  59. state setup_items;
  60. }
  61. on_rez(integer start_param)
  62. {
  63. llResetScript();
  64. }
  65. }
  66. state setup_items
  67. {
  68. state_entry()
  69. {
  70. llSetText("Please Wait, Loading Items List.",text_color,text_alpha);
  71. current_item = 0;
  72. notecardline = 0;
  73. llGetNotecardLine("_LIST",notecardline);
  74. }
  75. dataserver(key query_id, string data)
  76. {
  77. if (data != EOF)
  78. {
  79. integer item_mode = (notecardline - 0) % 2;
  80. if(item_mode == 0)
  81. {
  82. if(llGetInventoryKey(data) == NULL_KEY)
  83. {
  84. llOwnerSay("Item: " + data + " couldn't be found in inventory. Reseting");
  85. llResetScript();
  86. }
  87. else
  88. {
  89. if(llGetInventoryKey(data + "PIC") == NULL_KEY)
  90. {
  91. llOwnerSay("Couldn't find the picture for " + data + " named " + data + "PIC. Reseting.");
  92. llResetScript();
  93. }
  94. descriptions += [data];
  95. items += [data];
  96. }
  97. }
  98. else if(item_mode == 1)
  99. {
  100. prices += [data];
  101. }
  102. notecardline++;
  103. llGetNotecardLine("_LIST",notecardline);
  104. }
  105. else
  106. {
  107. state run_store;
  108. }
  109. }
  110. on_rez(integer start_param)
  111. {
  112. llResetScript();
  113. }
  114. }
  115.  
  116. state run_store
  117. {
  118. state_entry()
  119. {
  120. llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
  121. current_item = 0;
  122. llSetText(llList2String(descriptions,0) + "\n$L" + llList2String(prices,0),text_color,text_alpha);
  123. llSetTexture(llList2String(items,0) + "PIC",ALL_SIDES);
  124. }
  125. on_rez(integer start_param)
  126. {
  127. llResetScript();
  128. }
  129. changed(integer type)
  130. {
  131. if(type & CHANGED_INVENTORY)
  132. {
  133. llResetScript();
  134. }
  135. }
  136. run_time_permissions(integer type)
  137. {
  138. if(type & PERMISSION_DEBIT)
  139. {
  140. }
  141. else
  142. {
  143. llOwnerSay("Permissions must be granted for refund setup incomplete. Reseting");
  144. llResetScript();
  145. }
  146. }
  147. touch(integer number)
  148. {
  149. Next_Item();
  150. }
  151. money(key giver, integer amount)
  152. {
  153. integer cost = (integer)llList2String(prices,current_item);
  154. if (amount == cost)
  155. {
  156. llInstantMessage(giver,"Thank you for your purchase!");
  157. llGiveInventory(giver,llList2String(items,current_item));
  158. }
  159. if (amount > cost)
  160. {
  161. integer change =0;
  162. llInstantMessage(giver,"Here is your change. Thank you for your purchase!");
  163. llGiveInventory(giver,llList2String(items,current_item));
  164. change = amount - cost;
  165. llGiveMoney(giver,change);
  166. }
  167. if (amount < cost)
  168. {
  169. llInstantMessage(giver, "Sorry, That's not enough to buy this item. It costs L$" + llList2String(prices,current_item));
  170. llGiveMoney(giver, amount);
  171. }
  172. }
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement