Onenrico

Easy AdminShop (Diamond ShoP)

Aug 16th, 2016
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.02 KB | None | 0 0
  1. options:
  2. dirdata: plugins/Skript/scripts/data/shop.yml
  3. line1buy: [&3&lBuy&0]
  4. line1sell: [&2&lSell&0]
  5. line2: &lKlik Kanan
  6. line3: &1Harga: &0[price]
  7. line4: &1ID: &c[id]
  8. invbuy: &3&lBuy &2%{_item}% &0&lShop
  9. invsell: &a&lSell &2%{_item}% &0&lShop
  10. steal: &a&c&d
  11. function citem(t: text) :: item:
  12. set {_a} to "%{_t}%" parsed as item
  13. return {_a}
  14. function cid(t: text) :: text:
  15. set {_a} to citem("%{_t}%")
  16. set {_b} to data of {_a}
  17. set {_id} to id of {_a}
  18. if {_b} is equal to 0:
  19. set {_c} to "%{_id}%"
  20. else:
  21. set {_c} to "%{_id}%:%{_b}%"
  22. return {_c}
  23. function cekload(e: entity) :: boolean:
  24. if {_e} is item_frame:
  25. if block below {_e} is not wall_sign:
  26. return true
  27. return false
  28. function cekfresh(e: entity) :: boolean:
  29. if {_e} is item_frame:
  30. if block below {_e} is wall_sign:
  31. set {_a} to block below {_e}
  32. if line 1 of {_a} is not "":
  33. if line 3 of {_a} is not "":
  34. if line 4 of {_a} is not "":
  35. return true
  36. return false
  37. function cek(e: entity) :: boolean:
  38. if {_e} is item_frame:
  39. if block below {_e} is wall_sign:
  40. set {_a} to block below {_e}
  41. if line 1 of {_a} is "":
  42. if line 3 of {_a} is not "":
  43. if line 4 of {_a} is not "":
  44. return true
  45. return false
  46. function ceksave(e: entity) :: boolean:
  47. if {_e} is item_frame:
  48. if block below {_e} is wall_sign:
  49. set {_a} to block below {_e}
  50. if line 1 of {_a} is "{@line1buy}":
  51. return true
  52. return false
  53. function setsign(e: entity):
  54. set {_signbuy} to block below {_e}
  55. set {_line3} to "{@line3}"
  56. set {_price} to "%line 3 of {_signbuy}%"
  57. replace all "[price]" with "%{_price}%" in {_line3}
  58. set {_line4} to "{@line4}"
  59. set {_id} to cid("%line 4 of {_signbuy}%")
  60. replace all "[id]" with "%{_id}%" in {_line4}
  61. set line 1 of {_signbuy} to "{@line1buy}"
  62. set line 2 of {_signbuy} to "{@line2}"
  63. set line 3 of {_signbuy} to "%{_line3}%$"
  64. set line 4 of {_signbuy} to "%{_line4}%"
  65. set {_item} to citem("%{_id}%")
  66. set name of {_item} to "&e☏ &f%{_item}% &8&l| &7Price: &e%{_price}%&a$"
  67. set the displayed item on {_e} to {_item}
  68. function seticon(e: entity):
  69. set {_signbuy} to block below {_e}
  70. set {_signsell} to block above {_e}
  71. set {_icon} to block behind {_signbuy}
  72. set {_icon2} to block behind {_signsell}
  73. set {_id} to id("%line 4 of {_signbuy}%")
  74. set {_item} to citem("%{_id}%")
  75. set block at {_icon}'s location to {_item}
  76. wait 1 tick
  77. set block at {_icon2}'s location to {_item}
  78. function setsell(e: entity):
  79. set block above {_e} to wall_Sign
  80. set {_signsell} to block above {_e}
  81. set {_signbuy} to block below {_e}
  82. set {_price} to price("%line 3 of {_signbuy}%")
  83. set {_price} to {_price} parsed as number
  84. set {_price} to {_price} / 4
  85. set {_line3} to "{@line3}"
  86. replace all "[price]" with "%{_price}%" in {_line3}
  87. set line 1 of {_signsell} to "{@line1sell}"
  88. set line 2 of {_signsell} to "{@line2}"
  89. set line 3 of {_signsell} to "%{_line3}%$"
  90. set line 4 of {_signsell} to "%line 4 of {_signbuy}%"
  91. command /ds [<text>] [<number>]:
  92. trigger:
  93. if arg 1 is not set:
  94. send "/ds t - Toggle Admin Mode"
  95. send "/ds set <radius> - Set Sign In Radius"
  96. if arg 1 is "save":
  97. if arg 2 is set:
  98. loop entities in radius arg 2 of player:
  99. set {_a} to ceksave(loop-entity)
  100. if {_a} is true:
  101. set {_sign} to block below loop-entity
  102. set {_id} to id("%line 4 of {_sign}%")
  103. set {_price} to price("%line 3 of {_sign}%")
  104. set "Saved.%{_id}%" to "%{_price}%" in yaml file "plugins/Skript/scripts/worth.yml"
  105. send "%{_id}% = %{_price}%"
  106. if arg 1 is "cek":
  107. if arg 2 is set:
  108. set {_s::*} to configuration section "Items" get of "plugins/Skript/scripts/worth.yml"
  109. set "Total" to "%size of {_s::*}%" in yaml file "plugins/Skript/scripts/worth.yml"
  110. set {_total} to single value "Total" get of "plugins/Skript/scripts/worth.yml"
  111. loop entities in radius arg 2 of player:
  112. set {_a} to cekload(loop-entity)
  113. if {_a} is true:
  114. add 1 to {_count}
  115. send "&8[&bShop&8] &eItemFrame Total: %{_count}%"
  116. send "&8[&bShop&8] &bItemWorth Total: %{_total}%"
  117. if arg 1 is "load":
  118. if arg 2 is set:
  119. set {_s::*} to configuration section "Items" get of "plugins/Skript/scripts/worth.yml"
  120. set "Total" to "%size of {_s::*}%" in yaml file "plugins/Skript/scripts/worth.yml"
  121. set {_total} to single value "Total" get of "plugins/Skript/scripts/worth.yml"
  122. loop entities in radius arg 2 of player:
  123. set {_a} to cekload(loop-entity)
  124. if {_a} is true:
  125. add 1 to {_count}
  126. send "&8[&bShop&8] &fProcess &a%{_count}%&7/&6%{_total}%"
  127. set {_id} to "%{_s::%{_count}%}%"
  128. set {_convert} to cid("%{_id}%")
  129. send "%{_id}% = %{_convert}%" to console
  130. set {_price} to single value "Items.%{_s::%{_count}%}%" get of "plugins/Skript/scripts/worth.yml"
  131. if {_price} contains "/":
  132. set {_pr::*} to {_price} split at "/"
  133. set {_p1} to {_pr::1} parsed as number
  134. set {_p2} to {_pr::2} parsed as number
  135. set {_price} to {_p1} / {_p2}
  136. set block below loop-entity to wall_sign
  137. set {_block} to block below loop-entity
  138. set line 3 of {_block} to "%{_price}%"
  139. set line 4 of {_block} to "%{_id}%"
  140. if "%{_total}%" is "%{_count}%":
  141. send "&8[&bShop&8] &eComplete &6%{_count}%&7/&6%{_total}%"
  142. player command "/ds set %arg 2%"
  143. stop
  144. wait 1 tick
  145. if arg 1 is "set":
  146. if arg 2 is set:
  147. loop entities in radius arg 2 of player:
  148. set {_a} to cek(loop-entity)
  149. if {_a} is true:
  150. setsign(loop-entity)
  151. wait 1 tick
  152. player command "/ds sell %arg 2%"
  153. if arg 1 is "icon":
  154. if arg 2 is set:
  155. loop entities in radius arg 2 of player:
  156. set {_a} to cekfresh(loop-entity)
  157. if {_a} is true:
  158. seticon(loop-entity)
  159. wait 1 tick
  160. if arg 1 is "reset":
  161. if arg 2 is set:
  162. loop entities in radius arg 2 of player:
  163. set {_a} to cekfresh(loop-entity)
  164. if {_a} is true:
  165. set displayed item on loop-entity to air
  166. set block below loop-entity to air
  167. if arg 1 is "sell":
  168. if arg 2 is set:
  169. loop entities in radius arg 2 of player:
  170. set {_a} to cekfresh(loop-entity)
  171. if {_a} is true:
  172. setsell(loop-entity)
  173. wait 1 tick
  174. if arg 1 is "t":
  175. if {mode::%player%} is true:
  176. delete {mode::%player%}
  177. send "&8[&bShop&8] &fAdmin Mode : OFF"
  178. stop
  179. if {mode::%player%} is not set:
  180. set {mode::%player%} to true
  181. send "&8[&bShop&8] &fAdmin Mode : ON"
  182. stop
  183. if arg 1 is "price":
  184. if arg 2 is set:
  185. set {_block} to player's targeted block
  186. loop entities in radius 1 around location of block above location of {_block}:
  187. set {_id} to cid("%displayed item on loop-entity%")
  188. set line 3 of {_block} to "%arg 2%"
  189. set line 4 of {_block} to "%{_id}%"
  190. setsign(loop-entity)
  191. on leftclick on sign:
  192. if {mode::%player%} is true:
  193. cancel event
  194. set {_price} to line 1 of event-block parsed as number
  195. if {_price} is set:
  196. if player's tool is air:
  197. send "&8[&bShop&8] &fTolong Pegang Item"
  198. stop
  199. set line 3 of event-block to "%line 1 of event-block%"
  200. set line 1 of event-block to ""
  201. set {_id} to cid("%player's tool%")
  202. set line 4 of event-block to "%{_id}%"
  203. loop entities in radius 1 around location of block above location of event-block:
  204. set {_a} to cek(loop-entity)
  205. if {_a} is true:
  206. setsign(loop-entity)
  207. else:
  208. if line 1 is not "":
  209. if line 3 of event-block is set:
  210. set {_price} to price("%line 3 of event-block%")
  211. set line 3 of event-block to "%{_price}%"
  212. if line 1 is "":
  213. set line 3 of event-block to "0"
  214. loop entities in radius 1 around location of block above location of event-block:
  215. if displayed item on loop-entity is air:
  216. set displayed item on loop-entity to player's tool
  217. set {_id} to cid("%displayed item on loop-entity%")
  218. set line 4 of event-block to "%{_id}%"
  219. setsign(loop-entity)
  220. function reloadmenu(p: player):
  221. {_p} command "/sk reload %script%"
  222. function buy(p: player, amount: number, price: number, item: item):
  223. set {_prices} to {_price} * {_amount}
  224. if {_p}'s balance is more than {_prices}:
  225. loop {_amount} times:
  226. set {_event} to event({_p}, {limit::multiplier::%{_p}%}, "transaction")
  227. if {_event} is false:
  228. if {_count} is set:
  229. set {_harga} to {_price} * {_count}
  230. log("%{_p}%", "Sadap/trade/%{_p}%-Trade.txt", "[Buy] %{_count}% %{_item}% | Harga > %{_harga}% !Terkena Limit!)")
  231. send "&8[&bShop&8] &eKamu Berhasil Membeli Sebanyak &6%{_count}% &2%{_item}%" to {_p}
  232. send "&8[&bShop&8] &eDengan Total Harga: &f%{_price} * {_count}%$" to {_p}
  233. stop
  234. add {_item} to {_p}'s inventory
  235. subtract {_price} from {_p}'s balance
  236. add 1 to {_count}
  237. set {_harga} to {_price} * {_count}
  238. log("%{_p}%", "Sadap/trade/%{_p}%-Trade.txt", "[Buy] %{_count}% %{_item}% | Harga > %{_harga}%")
  239. send "&8[&bShop&8] &eKamu Berhasil Membeli Sebanyak &6%{_count}% &2%{_item}%" to {_p}
  240. send "&8[&bShop&8] &eDengan Total Harga: &f%{_price} * {_count}%$" to {_p}
  241. play "ENTITY_VILLAGER_YES" to {_p} at volume 2
  242. stop
  243. else:
  244. send "&8[&bShop&8] &cUangmu tidak cukup untuk membeli &6%{_amount}% &2%{_item}%" to {_p}
  245. play "ENTITY_VILLAGER_NO" to {_p} at volume 2
  246. stop
  247. function sell(p: player, amount: number, price: number, item: item):
  248. set {_prices} to {_price} * {_amount}
  249. if {_amount} is more than number of {_item} in {_p}'s inventory:
  250. send "&8[&bShop&8] &eKamu Tidak Mempunyai &2%{_item}% Sebanyak &6%{_amount}%" to {_p}
  251. play "ENTITY_VILLAGER_NO" to {_p} at volume 2
  252. stop
  253. loop {_amount} times:
  254. set {_event} to event({_p}, {limit::multiplier::%{_p}%}, "transaction")
  255. if {_event} is false:
  256. if {_count} is set:
  257. set {_harga} to {_price} * {_count}
  258. log("%{_p}%", "Sadap/trade/%{_p}%-Trade.txt", "[Sell] %{_count}% %{_item}% | Harga > %{_harga}% [Terkena Limit]")
  259. send "&8[&bShop&8] &eKamu Berhasil Menjual Sebanyak &6%{_count}% &2%{_item}%" to {_p}
  260. send "&8[&bShop&8] &eDengan Total Harga: &f%{_price} * {_count}%$" to {_p}
  261. stop
  262. remove {_item} from {_p}
  263. add {_price} to {_p}'s balance
  264. add 1 to {_count}
  265. set {_harga} to {_price} * {_count}
  266. log("%{_p}%", "Sadap/trade/%{_p}%-Trade.txt", "[Sell] %{_count}% %{_item}% | Harga > %{_harga}%")
  267. send "&8[&bShop&8] &eKamu Berhasil Menjual Sebanyak &6%{_count}% &2%{_item}%" to {_p}
  268. send "&8[&bShop&8] &eDengan Total Harga: &f%{_price} * {_count}%$" to {_p}
  269. play "ENTITY_VILLAGER_YES" to {_p} at volume 2
  270. stop
  271. on rightclick on sign:
  272. if line 1 of event-block is "{@line1sell}":
  273. wait 1 tick
  274. set {_b} to event-block
  275. set {_price} to price("%line 3 of {_b}%")
  276. set {_id} to id("%line 4 of {_b}%")
  277. set {_item} to citem("%{_id}%")
  278. set {_miaw} to cid("%{_item}%")
  279. set {_2item} to "2 %{_miaw}%" parsed as item
  280. if {_2item} is not set:
  281. set {_2item} to {_item}
  282. set {_4item} to "4 %{_miaw}%" parsed as item
  283. if {_4item} is not set:
  284. set {_4item} to {_item}
  285. set {_8item} to "8 %{_miaw}%" parsed as item
  286. if {_8item} is not set:
  287. set {_8item} to {_item}
  288. set {_16item} to "16 %{_miaw}%" parsed as item
  289. if {_16item} is not set:
  290. set {_16item} to {_item}
  291. set {_32item} to "32 %{_miaw}%" parsed as item
  292. if {_32item} is not set:
  293. set {_32item} to {_item}
  294. set {_64item} to "64 %{_miaw}%" parsed as item
  295. if {_64item} is not set:
  296. set {_64item} to {_item}
  297. if inventory name of player's current inventory is "{@invsell}":
  298. stop
  299. play "UI_BUTTON_CLICK" to player at volume 2
  300. open chest with 1 row named "{@invsell}" to player
  301. while inventory name of player's current inventory is "{@invsell}":
  302. set {_have} to number of {_item} in player's inventory
  303. format slot 0 of player with chest named "{@steal}&a&lINFO>" with lore "&bName&f&l: &e%player%||&bMoney&f&l: &e%player's balance%" to run [reloadmenu(player)]
  304. format slot 8 of player with chest named "{@steal}&a&lINFO>" with lore "&bName&f&l: &e%player%||&bMoney&f&l: &e%player's balance%" to run [reloadmenu(player)]
  305. format slot 1 of player with {_item} named "{@steal}&b&lSell> &7Klik Untuk menjual" with lore "&fHarga&f&l: &e%{_price}%$||&fJumlah&f&l: &e1x||&aPunyamu&f&l: %{_have}%x" to run [sell(player, 1, {_price}, {_item})]
  306. format slot 2 of player with {_2item} named "{@steal}&b&lSell> &7Klik Untuk menjual" with lore "&fHarga&f&l: &e%{_price}*2%$||&fJumlah&f&l: &e2x||&aPunyamu&f&l: %{_have}%x" to run [sell(player, 2, {_price}, {_item})]
  307. format slot 3 of player with {_4item} named "{@steal}&b&lSell> &7Klik Untuk menjual" with lore "&fHarga&f&l: &e%{_price}*4%$||&fJumlah&f&l: &e4x||&aPunyamu&f&l: %{_have}%x" to run [sell(player, 4, {_price}, {_item})]
  308. format slot 4 of player with {_8item} named "{@steal}&b&lSell> &7Klik Untuk menjual" with lore "&fHarga&f&l: &e%{_price}*8%$||&fJumlah&f&l: &e8x||&aPunyamu&f&l: %{_have}%x" to run [sell(player, 8, {_price}, {_item})]
  309. format slot 5 of player with {_16item} named "{@steal}&b&lSell> &7Klik Untuk menjual" with lore "&fHarga&f&l: &e%{_price}*16%$||&fJumlah&f&l: &e16x||&aPunyamu&f&l: %{_have}%x" to run [sell(player, 16, {_price}, {_item})]
  310. format slot 6 of player with {_32item} named "{@steal}&b&lSell> &7Klik Untuk menjual" with lore "&fHarga&f&l: &e%{_price}*32%$||&fJumlah&f&l: &e32x||&aPunyamu&f&l: %{_have}%x" to run [sell(player, 32, {_price}, {_item})]
  311. format slot 7 of player with {_64item} named "{@steal}&b&lSell> &7Klik Untuk menjual" with lore "&fHarga&f&l: &e%{_price}*64%$||&fJumlah&f&l: &e64x||&aPunyamu&f&l: %{_have}%x" to run [sell(player, 64, {_price}, {_item})]
  312. wait 2 tick
  313. on rightclick on sign:
  314. if line 1 of event-block is "{@line1buy}":
  315. wait 1 tick
  316. set {_b} to event-block
  317. set {_price} to price("%line 3 of {_b}%")
  318. set {_id} to id("%line 4 of {_b}%")
  319. set {_item} to citem("%{_id}%")
  320. set {_miaw} to cid("%{_item}%")
  321. set {_2item} to "2 %{_miaw}%" parsed as item
  322. if {_2item} is not set:
  323. set {_2item} to {_item}
  324. set {_4item} to "4 %{_miaw}%" parsed as item
  325. if {_4item} is not set:
  326. set {_4item} to {_item}
  327. set {_8item} to "8 %{_miaw}%" parsed as item
  328. if {_8item} is not set:
  329. set {_8item} to {_item}
  330. set {_16item} to "16 %{_miaw}%" parsed as item
  331. if {_16item} is not set:
  332. set {_16item} to {_item}
  333. set {_32item} to "32 %{_miaw}%" parsed as item
  334. if {_32item} is not set:
  335. set {_32item} to {_item}
  336. set {_64item} to "64 %{_miaw}%" parsed as item
  337. if {_64item} is not set:
  338. set {_64item} to {_item}
  339. if inventory name of player's current inventory is "{@invbuy}":
  340. stop
  341. play "UI_BUTTON_CLICK" to player at volume 2
  342. open chest with 1 row named "{@invbuy}" to player
  343. while inventory name of player's current inventory is "{@invbuy}":
  344. format slot 0 of player with chest named "{@steal}&a&lINFO>" with lore "&bName&f&l: &e%player%||&bMoney&f&l: &e%player's balance%" to run [reloadmenu(player)]
  345. format slot 8 of player with chest named "{@steal}&a&lINFO>" with lore "&bName&f&l: &e%player%||&bMoney&f&l: &e%player's balance%" to run [reloadmenu(player)]
  346. format slot 1 of player with {_item} named "{@steal}&b&lBuy> &7Klik Untuk Membeli" with lore "&fHarga&f&l: &e%{_price}%$||&fJumlah&f&l: &e1x" to run [buy(player, 1, {_price}, {_item})]
  347. format slot 2 of player with {_2item} named "{@steal}&b&lBuy> &7Klik Untuk Membeli" with lore "&fHarga&f&l: &e%{_price}*2%$||&fJumlah&f&l: &e2x" to run [buy(player, 2, {_price}, {_item})]
  348. format slot 3 of player with {_4item} named "{@steal}&b&lBuy> &7Klik Untuk Membeli" with lore "&fHarga&f&l: &e%{_price}*4%$||&fJumlah&f&l: &e4x" to run [buy(player, 4, {_price}, {_item})]
  349. format slot 4 of player with {_8item} named "{@steal}&b&lBuy> &7Klik Untuk Membeli" with lore "&fHarga&f&l: &e%{_price}*8%$||&fJumlah&f&l: &e8x" to run [buy(player, 8, {_price}, {_item})]
  350. format slot 5 of player with {_16item} named "{@steal}&b&lBuy> &7Klik Untuk Membeli" with lore "&fHarga&f&l: &e%{_price}*16%$||&fJumlah&f&l: &e16x" to run [buy(player, 16, {_price}, {_item})]
  351. format slot 6 of player with {_32item} named "{@steal}&b&lBuy> &7Klik Untuk Membeli" with lore "&fHarga&f&l: &e%{_price}*32%$||&fJumlah&f&l: &e32x" to run [buy(player, 32, {_price}, {_item})]
  352. format slot 7 of player with {_64item} named "{@steal}&b&lBuy> &7Klik Untuk Membeli" with lore "&fHarga&f&l: &e%{_price}*64%$||&fJumlah&f&l: &e64x" to run [buy(player, 64, {_price}, {_item})]
  353. wait 2 tick
  354. on drop:
  355. if name of player's current inventory is "{@invbuy}":
  356. cancel event
  357. on break:
  358. if line 1 of event-block is "{@line1sell}":
  359. if player's tool is not golden axe:
  360. send "&8[&bShop&8] &7Use golden axe to destroy" to player
  361. cancel event
  362. if line 1 of event-block is "{@line1buy}":
  363. if player's tool is not golden axe:
  364. send "&8[&bShop&8] &7Use golden axe to destroy" to player
  365. cancel event
  366. on damage:
  367. if victim is item_Frame:
  368. set {_a} to location of block at victim's location
  369. if block below {_a}'s location is wall_sign:
  370. set {_block} to block below {_a}
  371. if line 1 of {_block} is "{@line1buy}":
  372. send "&8[&bShop&8] &cDon't Touch!" to attacker
  373. cancel event
  374. if line 1 of {_block} is "{@line1sell}":
  375. send "&8[&bShop&8] &cDon't Touch!" to attacker
  376. cancel event
Advertisement
Add Comment
Please, Sign In to add comment