Advertisement
laivytkill

DanielSK-Feiras.sk

May 17th, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.02 KB | None | 0 0
  1. # Código desenvolvido por DanielZinh#7616
  2. # LoS Skripters - EliteSK
  3.  
  4. # Permissões:
  5. # danielsk.feira.admin - Permissão para usar os comandos de admin
  6. # danielsk.feira.comprar - Permissão que comprar feiras
  7. # danielsk.feira.delay.bypass - Permissão que comprar feiras
  8.  
  9. # É necessário possuir o plugin HolographicDisplays caso venha usar feiras de hologramas.
  10.  
  11. options:
  12. # Anunciar sempre que uma feira nova for criada, deletada, comprada ou expirada?
  13. Anunciar: true
  14.  
  15. # ------------------------------ #
  16.  
  17. # Precisa estar perto para comprar feira
  18. # Isso evita que pessoas comprem feiras de distâncias longas
  19. # Não influencia em nada, é apenas um gosto pessoal, haha!
  20. BlockComprasLonges: false
  21.  
  22. # Distância (em blocos) mínima para compra, caso "BlockComprasLonges" esteja como true
  23. ComprasLongesDistancia: 20
  24.  
  25. # ------------------------------ #
  26.  
  27. # Poder renovar feiras, isso permitirá com que um jogador
  28. # fique com a mesma feira enquanto for renovando, fazendo
  29. # com que players fiquem com feiras por longos e longos tempos.
  30. BlockRenovações: false
  31.  
  32. # Segundos que vai aguardar para poder ir para uma feira, pessoas que possuem
  33. # a permissão "danielsk.feira.delay.bypass" estão imunes.
  34. # Deixe "0" caso não queira.
  35. DelayGoFeira: 5 # Segundos
  36.  
  37. on load:
  38. send "[DanielSK] Código %script% iniciado." to console
  39. send "[DanielSK] Discord: DanielZinh##7616" to console
  40.  
  41. load yaml "plugins/DanielSK/feiras.yml" as "DanielSK.feiras"
  42. save yaml "DanielSK.feiras"
  43. on unload:
  44. save yaml "DanielSK.feiras"
  45.  
  46.  
  47. command /feira [<text>] [<integer>] [<number>] [<integer>] [<text>]:
  48. trigger:
  49. if arg 1 is set:
  50. if arg 1 is "ir", "comprar", "excluir", "renovar", "criar", "deletar" or "expirar":
  51.  
  52. if arg 1 is not "ir", "comprar", "excluir" or "renovar":
  53. player doesn't have permission "danielsk.feira.admin"
  54. send "&cVocê não possui permissão para fazer isso!"
  55. stop
  56.  
  57. if arg 1 is "ir", "comprar", "excluir", "deletar", "renovar" or "expirar":
  58. if arg 2 is not set:
  59. send "&cUse /feira %arg-1% &c(ID)"
  60. stop
  61. if yaml value "feiras.%arg-2%" from "DanielSK.feiras" is not set:
  62. send "&cEssa feira não existe!"
  63. stop
  64.  
  65. if arg 1 is "criar":
  66. if yaml value "feiras.%arg-2%" from "DanielSK.feiras" is set:
  67. send "&cEssa feira já existe!"
  68. else if arg 2, arg 3, arg 4 or arg 5 is not set:
  69. send "&cUse /feira criar (ID) (Preço) (Expiração (Em dias)) (placa/holograma)"
  70. else if arg 5 is not "placa" or "holograma":
  71. send "&cUse /feira criar (ID) (Preço) (Expiração (Em dias)) (placa/holograma)"
  72. else:
  73.  
  74. if arg 5 is "placa":
  75. if player's target block is a sign:
  76. loop yaml nodes with keys "feiras" from "DanielSK.feiras":
  77. yaml value "feiras.%loop-value%.sign-location" from "DanielSK.feiras" is location of target block
  78. send "&cEssa placa já possui uma feira registrada!"
  79. stop
  80. set {_a} to target block's location
  81. else:
  82. send "&cVocê precisa estar olhando para a placa!"
  83. stop
  84. else:
  85. set {_b} to true
  86.  
  87. set {_id} to abs(arg-2)
  88. set yaml value "feiras.%arg-2%" from "DanielSK.feiras" to abs(arg-2)
  89. set {_p::*} to split "owner;0=price;%arg-3%=expiration-days;%abs(arg-4)%=expiration-date;0=type;%arg-5%=local;loc" at "="
  90. loop {_p::*}:
  91. set {_p2::*} to split loop-value at ";"
  92. if {_p2::2} is "loc":
  93. set {_p2::2} to player's location
  94. set yaml value "feiras.%{_id}%.%{_p2::1}%" from "DanielSK.feiras" to {_p2::2}
  95. if {_a} is set:
  96. set yaml value "feiras.%{_id}%.sign-location" from "DanielSK.feiras" to {_a}
  97. set line 1 of block at {_a} to "[Feira]"
  98. set line 2 of block at {_a} to "Dono: Ninguém"
  99. set line 3 of block at {_a} to "Valor: R$%arg-3%"
  100.  
  101. make player execute command "rg define feira-%{_id}%"
  102. wait 5 tick
  103. make player execute command "rg setpriority feira-%{_id}% 1"
  104. make player execute command "rg flag feira-%{_id}% build allow"
  105.  
  106. if {@Anunciar} is true:
  107. wait 1 tick
  108. broadcast "&6[&fFeiras&6] &7Uma nova feira com o ID &f%{_id}% &7foi criada!"
  109. if {_b} is set:
  110. teleport player to block 3.5 above player
  111. make player execute command "hd create feira-%{_id}% &6[FEIRA]"
  112. wait 1 tick
  113. make player execute command "hd addline feira-%{_id}% &eDono: &6Ninguém"
  114. make player execute command "hd addline feira-%{_id}% &eValor: &6R$%arg-3%"
  115. make player execute command "hd addline feira-%{_id}% &eExpira: &6Nunca"
  116. make player execute command "hd addline feira-%{_id}% &5"
  117. make player execute command "hd addline feira-%{_id}% &6/feira comprar %{_id}%"
  118.  
  119. else if arg 1 is "deletar":
  120. delete yaml value "feiras.%arg-2%" from "DanielSK.feiras"
  121. make player execute command "rg delete feira-%arg-2%"
  122. if yaml value "feiras.%arg-2%.type" from "DanielSK.feiras" is not "placa":
  123. make console execute command "hd delete feira-%arg-2%"
  124.  
  125. if {@Anunciar} is true:
  126. broadcast "&6[&fFeiras&6] &7A feira de ID &f%arg-2% &7foi deletada."
  127.  
  128. else if arg 1 is "expirar":
  129. set {_n} to now
  130. set yaml value "feiras.%arg-2%.expiration-date" from "DanielSK.feiras" to {_n}
  131. send "&7Essa feira será expirada em alguns instantes..."
  132. else if arg 1 is "ir":
  133. if {@DelayGoFeira} is not 0:
  134. player doesn't have permission "danielsk.feira.delay.bypass"
  135. wait "%abs({@DelayGoFeira})% seconds" parsed as timespan
  136. teleport player to yaml value "feiras.%arg-2%.local" from "DanielSK.feiras"
  137. send "&7Você foi teleportado para a feira ID &f%arg-2%&7."
  138. else if arg 1 is "comprar":
  139. if yaml value "feiras.%arg-2%.owner" from "DanielSK.feiras" is not 0:
  140. send "&cEssa feira já tem dono."
  141. else:
  142.  
  143. if {@BlockComprasLonges} is true:
  144. set {_l} to yaml value "feiras.%arg-2%.local" from "DanielSK.feiras"
  145. distance between player and {_l} > {@ComprasLongesDistancia}
  146. send "&cVocê precisa estar próximo da feira para compra-la."
  147. stop
  148.  
  149. open chest with 3 rows named "&eComprar Feira" to player
  150. wait 1 tick
  151. if name of player's current inventory is "&eComprar Feira":
  152. set {_price} to yaml value "feiras.%arg-2%.price" from "DanielSK.feiras"
  153. set slot 12 of player's current inventory to light green wool block named "&aConfirmar" with lore "||&7ID: &6%arg-2%||&7Preço: &6R$%{_price}%||&aClique para comprar...||&5||"
  154. set slot 14 of player's current inventory to red wool block named "&cCancelar"
  155. else if arg 1 is "renovar":
  156. if yaml value "feiras.%arg-2%.owner" from "DanielSK.feiras" is not player:
  157. send "&cEssa feira não é sua!"
  158. else if player's balance < yaml value "feiras.%arg-2%.price" from "DanielSK.feiras":
  159. send "&cVocê não possui dinheiro o suficiente para fazer isso."
  160. else:
  161. remove yaml value "feiras.%arg-2%.price" from "DanielSK.feiras" from player's balance
  162. send "&7Você renovou sua feira com sucesso."
  163. set {_n} to now
  164. set {_t} to yaml value "feiras.%arg-2%.expiration-days" from "DanielSK.feiras"
  165. add "%{_t}% days" parsed as timespan to {_n}
  166. set yaml value "feiras.%arg-2%.expiration-date" from "DanielSK.feiras" to {_n}
  167. if yaml value "feiras.%arg-2%.sign-location" from "DanielSK.feiras" is not set:
  168. make console execute command "hd setline feira-%arg-2% 4 &eExpira: &6%{_n}%"
  169. else if arg 1 is "excluir":
  170. if yaml value "feiras.%arg-2%.owner" from "DanielSK.feiras" is not player:
  171. send "&cEssa feira não é sua!"
  172. else:
  173. make console execute command "feira expirar %arg-2%"
  174.  
  175. else:
  176. make player execute command "feira"
  177. else:
  178. send "&7Comandos para uso das &fFeiras&7:"
  179. send "&f/feira ir (ID) &6- &7ir para uma feira"
  180. send "&f/feira comprar (ID) &6- &7comprar uma feira"
  181. send "&f/feira excluir (ID) &6- &7exclui sua feira"
  182. if {@BlockRenovações} is not true:
  183. send "&f/feira renovar (ID) &6- &7renova sua feira"
  184. player has permission "danielsk.feira.admin"
  185. send "&c/feira criar (ID) &6- &4cria uma feira"
  186. send "&c/feira deletar (ID) &6- &4deleta uma feira"
  187. send "&c/feira expirar (ID) &6- &4expira uma feira"
  188.  
  189. on rightclick on sign:
  190. loop yaml nodes with keys "feiras" from "DanielSK.feiras":
  191. if yaml value "feiras.%loop-value%.owner" from "DanielSK.feiras" is 0:
  192. yaml value "feiras.%loop-value%.sign-location" from "DanielSK.feiras" is location of block
  193. make player execute command "feira comprar %loop-value%"
  194. else:
  195. send "&cEssa feira já possui dono."
  196.  
  197. on inventory click:
  198. if name of player's current inventory is "&eComprar Feira":
  199. cancel event
  200.  
  201. if "%name of item%" is "&cCancelar":
  202. close player's inventory
  203. else if "%name of item%" is "&aConfirmar":
  204. set {_id} to uncolored line 2 of lore of item
  205. set {_preço} to uncolored line 3 of lore of item
  206. replace all "Preço: R$" and "ID: " with "" in {_id} and {_preço}
  207. set {_preço} to {_preço} parsed as number
  208. if player's balance >= {_preço}:
  209.  
  210. close player's inventory
  211. remove {_preço} from player's balance
  212. set {_n} to now
  213. set {_t} to yaml value "feiras.%{_id}%.expiration-days" from "DanielSK.feiras"
  214. add "%{_t}% days" parsed as timespan to {_n}
  215. set yaml value "feiras.%{_id}%.expiration-date" from "DanielSK.feiras" to {_n}
  216. set yaml value "feiras.%{_id}%.owner" from "DanielSK.feiras" to player
  217. if yaml value "feiras.%{_id}%.sign-location" from "DanielSK.feiras" is set:
  218. set {_a} to yaml value "feiras.%{_id}%.sign-location" from "DanielSK.feiras"
  219. set line 1 of block at {_a} to "[Feira]"
  220. set line 2 of block at {_a} to "Dono: %player%"
  221. set line 3 of block at {_a} to "Expira:"
  222. else:
  223. make console execute command "hd setline feira-%{_id}% 2 &eDono: &6%player%"
  224. make console execute command "hd setline feira-%{_id}% 4 &eExpira: &6%{_n}%"
  225. make console execute command "hd setline feira-%{_id}% 6 &6/feira ir %{_id}%"
  226. if {@Anunciar} is true:
  227. broadcast "&6[&fFeiras&6] &f%player% &7comprou a feira de ID &f%{_id}%&7."
  228. else:
  229. send "&cVocê não possui dinheiro o suficiente."
  230.  
  231. on place:
  232. "%region at block%" contains "feira"
  233. loop yaml nodes with keys "feiras" from "DanielSK.feiras":
  234. "%region at block%" contains "feira-%loop-value%"
  235. if yaml value "feiras.%loop-value%.owner" from "DanielSK.feiras" is not player:
  236. player is not op
  237. cancel event
  238. else:
  239. add block's location to {feiras::%loop-value%::*}
  240. on break:
  241. "%region at block%" contains "feira"
  242. loop yaml nodes with keys "feiras" from "DanielSK.feiras":
  243. "%region at block%" contains "feira-%loop-value%"
  244. if yaml value "feiras.%loop-value%.owner" from "DanielSK.feiras" is not player:
  245. player is not op
  246. cancel event
  247. else:
  248. add block's location to {feiras::%loop-value%::*}
  249.  
  250. every 1 second:
  251. loop yaml nodes with keys "feiras" from "DanielSK.feiras":
  252. yaml value "feiras.%loop-value%.owner" from "DanielSK.feiras" is not 0
  253. set {_re} to yaml value "feiras.%loop-value%.expiration-date" from "DanielSK.feiras"
  254.  
  255. if now >= {_re}:
  256.  
  257. set yaml value "feiras.%loop-value%.expiration-date" from "DanielSK.feiras" to 0
  258. set yaml value "feiras.%loop-value%.owner" from "DanielSK.feiras" to 0
  259.  
  260. loop {feiras::%loop-value%::*}:
  261. set block at loop-value-2 to air
  262. delete {feiras::%loop-value%::*}
  263.  
  264. if yaml value "feiras.%loop-value%.sign-location" from "DanielSK.feiras" is set:
  265. set {_a} to yaml value "feiras.%loop-value%.sign-location" from "DanielSK.feiras"
  266. set {_price} to yaml value "feiras.%loop-value%.price" from "DanielSK.feiras"
  267. set line 1 of block at {_a} to "[Feira]"
  268. set line 2 of block at {_a} to "Dono: Ninguém"
  269. set line 3 of block at {_a} to "Valor: R$%{_price}%"
  270. else:
  271. make console execute command "hd setline feira-%loop-value% 2 &eDono: &6Ninguém"
  272. make console execute command "hd setline feira-%loop-value% 4 &eExpira: &6Nunca"
  273. make console execute command "hd setline feira-%loop-value% 6 &6/feira comprar %loop-value%"
  274. if {@Anunciar} is true:
  275. broadcast "&6[&fFeiras&6] &7A feira de ID &f%loop-value% &7expirou."
  276.  
  277. else:
  278. set {_e} to yaml value "feiras.%loop-value%.expiration-date" from "DanielSK.feiras"
  279. set {_x} to "%difference between now and {_e}%"
  280. loop 99 times:
  281. replace all ".%(99 - loop-number)%" with "" in {_x}
  282. replace all " " and "and" with "" in {_x}
  283. replace all "seconds" and "second" with "s" in {_x}
  284. replace all "minutes" and "minute" with "m" in {_x}
  285. replace all "hours" and "hour" with "h" in {_x}
  286. replace all "days" and "day" with "d" in {_x}
  287. if yaml value "feiras.%loop-value%.sign-location" from "DanielSK.feiras" is set:
  288. set {_a} to yaml value "feiras.%loop-value%.sign-location" from "DanielSK.feiras"
  289. set {_price} to yaml value "feiras.%loop-value%.price" from "DanielSK.feiras"
  290. set line 3 of block at {_a} to "Expira: %{_x}%"
  291.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement