knugi

Untitled

Oct 7th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.06 KB | None | 0 0
  1. function isAroundChest(loc: location) :: location:
  2. if block north {_loc} is chest:
  3. return location of block north {_loc}
  4. if block west {_loc} is chest:
  5. return location of block west {_loc}
  6. if block east {_loc} is chest:
  7. return location of block east {_loc}
  8. if block north {_loc} is chest:
  9. return location of block north {_loc}
  10. else:
  11. return null
  12. options:
  13. nameFolder: "plugins/TreasureSkript"
  14. nameConfig: "plugins/TreasureSkript/config.yml"
  15. on script load:
  16. if folder {@nameFolder} is not exists:
  17. create folder {@nameFolder}
  18. create file {@nameConfig}
  19. set "small-refresh" to "12" in {@nameConfig}
  20. set "large-refresh" to "24" in {@nameConfig}
  21. set "small-amount-items-min" to "1" in {@nameConfig}
  22. set "small-amount-items-max" to "3" in {@nameConfig}
  23. set "large-amount-items-min" to "4" in {@nameConfig}
  24. set "large-amount-items-max" to "5" in {@nameConfig}
  25. set "items.1" to "3 apple" in {@nameConfig}
  26. set "items.2" to "5 stone" in {@nameConfig}
  27. set "items.3" to "2 stick" in {@nameConfig}
  28. set "items.4" to "3 322:1" in {@nameConfig}
  29. set "items.5" to "1 diamond" in {@nameConfig}
  30. stop
  31. command /tchest [<text>]:
  32. trigger:
  33. if player has permission "treasureskript.admin":
  34. if arg 1 is "aktywuj":
  35. set {tchest.%player%} to true
  36. send "&7Kliknij PPM na skrzynki, by dodac je do tchest'ow"
  37. stop
  38. if arg 1 is "anuluj":
  39. clear {tchest.%player%}
  40. send "&7Juz nie dodajesz tchest'ow"
  41. stop
  42. send "&aKomendy dodawania skrzynek."
  43. send "&a/tchest aktywuj &7- &8aktywuje dodawanie skrzynek."
  44. send "&a/tchest anuluj &7- &8anuluje dodawania skrzynek."
  45. stop
  46. send "Unknown command. Type ""/help"" for help. xD"
  47. stop
  48. on rightclick on chest:
  49. if {tchest.%player%} is true:
  50. cancel event
  51. loop {tchest::*}:
  52. if location of event-block is loop-value:
  53. send "&cTa skrzynka jest juz dodana."
  54. stop
  55. if isAroundChest(location of event-block) is set:
  56. add location of event-block to {tchest::*}
  57. add isAroundChest(location of event-block) to {tchest::*}
  58. else:
  59. add location of event-block to {tchest::*}
  60. send "&cDodales skrzynke do tchest'a"
  61. stop
  62. loop {tchest::*}:
  63. if location of event-block is loop-value:
  64. cancel event
  65. if isAroundChest(location of event-block) is set:
  66. set {_rows} to 6
  67. open chest with 6 rows to player
  68. else:
  69. set {_rows} to 3
  70. open chest with 3 rows to player
  71. set {tchest.%player%.opened} to location of event-block
  72. set {tchest.%player%.rows} to {_rows}
  73. wait 2 tick
  74. if {tchest.%player%::%location of event-block%} is set:
  75. if now is smaller than {tchest.%player%::%location of event-block%}:
  76. loop {tchest.%player%::%location of event-block%::*}:
  77. set {_int} to loop-index-2 parsed as integer
  78. set player's current inventory's slot {_int} to loop-value-2
  79. stop
  80. if {_rows} is 3:
  81. set {_amount} to random integer between single value "small-amount-items-min" get of {@nameConfig} parsed as integer and single value "small-amount-items-max" get of {@nameConfig} parsed as integer
  82. else:
  83. set {_amount} to random integer between single value "large-amount-items-min" get of {@nameConfig} parsed as integer and single value "large-items-max" get of {@nameConfig} parsed as integer
  84. set {_it::*} to configuration section "items" get of {@nameConfig}
  85. loop size of {_it::*} times:
  86. add single value "items.%loop-number%" get of {@nameConfig} to {_itemsConf::*}
  87. if {_amount} is larger than size of {_it::*}:
  88. set {_amount} to size of {_it::*}
  89. if {_amount} is smaller than or equal to 0:
  90. stop
  91. if {_amount} is not set:
  92. stop
  93. loop 10000 times:
  94. if size of {_slots::*} is smaller than {_amount}:
  95. set {_a} to random integer between 0 and 26
  96. loop {_slots::*}:
  97. if loop-value-2 is {_a}:
  98. set {_error} to true
  99. exit loop
  100. if {_error} is not set:
  101. add {_a} to {_slots::*}
  102. clear {_error}
  103. else:
  104. exit loop
  105. loop {_slots::*}:
  106. set {_item} to random text out of {_itemsConf::*}
  107. remove {_item} from {_itemsConf::*}
  108. set {_ilosc} to first character of {_item} parsed as integer
  109. set {_item} to subtext of {_item} between index 3 and length of {_item}
  110. set {_item} to "%random integer between 1 and {_ilosc}% %{_item}%" parsed as item type
  111. set {_slot} to "%loop-value-2%" parsed as integer
  112. set player's current inventory's slot {_slot} to {_item}
  113. set {_i} to 0
  114. if isAroundChest(location of event-block) is set:
  115. set {_newTime} to now
  116. set {_lR} to single value "large-refresh" get of {@nameConfig}
  117. add "%{_lR}% hour" parsed as timespan to {_newTime}
  118. set {tchest.%player%::%location of event-block%} to {_newTime}
  119. set {tchest.%player%::%isAroundChest(location of event-block)%} to {_newTime}
  120. loop {_rows}*9 times:
  121. set {tchest.%player%::%location of event-block%::%{_i}%} to player's current inventory's slot {_i}
  122. set {tchest.%player%::%isAroundChest(location of event-block)%::%{_i}%} to player's current inventory's slot {_i}
  123. add 1 to {_i}
  124. else:
  125. set {_newTime} to now
  126. set {_sR} to single value "small-refresh" get of {@nameConfig}
  127. add "%{_sR}% hour" parsed as timespan to {_newTime}
  128. set {tchest.%player%::%location of event-block%} to {_newTime}
  129. loop {_rows}*9 times:
  130. set {tchest.%player%::%location of event-block%::%{_i}%} to player's current inventory's slot {_i}
  131. add 1 to {_i}
  132. on inventory close:
  133. if {tchest.%player%.opened} is set:
  134. set {_i} to 0
  135. loop {tchest.%player%.rows} * 9 times:
  136. if isAroundChest({tchest.%player%.opened}) is set:
  137. set {_loc2} to isAroundChest({tchest.%player%.opened})
  138. set {tchest.%player%::%{_loc2}%::%{_i}%} to player's current inventory's slot {_i}
  139. set {tchest.%player%::%{tchest.%player%.opened}%::%{_i}%} to player's current inventory's slot {_i}
  140. add 1 to {_i}
  141. clear {tchest.%player%.opened}
  142. clear {tchest.%player%.rows}
  143. #{tchest::*} - dodane skrzynki
  144. #{tchest.%player::%lokacja%} - czas otworzenia + czas z configu
  145. #{tchest.%player%::%lokacja::*} - index - slot, value - item
Advertisement
Add Comment
Please, Sign In to add comment