knugi

Untitled

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