laivytkill

DanielSK-Trade.sk (Versão 1.16.5)

May 21st, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.27 KB | None | 0 0
  1. # Código desenvolvido por DanielZinh#7616
  2. # LoS Skripters - EliteSK
  3.  
  4. options:
  5.  
  6. # Apertar com o direito + shift em um player para oferecer troca
  7. ShiftTroca: true
  8.  
  9. # Estar perto para realizar trocas
  10. NecessarioEstarPerto: true
  11. DistanciaMinima: 20 # Blocos
  12.  
  13. on unload:
  14. delete {troca::*}
  15.  
  16. command /trade [<player>] [<text>]:
  17. aliases: trocar
  18. trigger:
  19. if arg 1 is not set:
  20. send "&cUse /trade (player)"
  21. else if {troca::%player%::*} contains player:
  22. send "&cEsse jogador já possui um pedido de troca seu"
  23. else:
  24. if arg 2 is not "accept":
  25. if {@NecessarioEstarPerto} is true:
  26. distance between arg-1 and player > {@DistanciaMinima}
  27. send "&cVocê está muito longe do jogador." to player
  28. stop
  29. send formatted "&f%player% &7enviou um pedido de troca para você <run command:/trade %player% accept>&f&nCLIQUE AQUI &7para aceitar" to arg-1
  30. send "&7Você enviou um pedido de troca para &f%arg-1%&7." to player
  31. add player to {troca::%arg-1%::*}
  32. else:
  33. if {troca::%player%::*} doesn't contain arg-1:
  34. send "&cEsse jogador não enviou um pedido de troca para você."
  35. else if arg-1 is not online:
  36. send "&cEsse jogador não está mais on-line."
  37. else if {var::%arg-1%::troca} is set:
  38. send "&cEsse jogador já está em uma troca."
  39. else:
  40. loop all players:
  41. loop-player is arg-1 or player
  42. open chest with 6 rows named "&eTroca %arg-1%" to loop-player
  43. remove loop-player from {troca::%player%::*}
  44. set {var::%loop-player%::troca} to arg-1
  45. set {var::%arg-1%::troca} to loop-player
  46. set {var::%arg-1%::trocad} to arg-1
  47. set {var::%loop-player%::trocad} to arg-1
  48. wait 1 tick
  49. if name of loop-player's current inventory contains "&eTroca":
  50. set {_e::*} to split "4,13,22,31,30,29,28,27,40,49,50,51" at ","
  51. loop {_e::*}:
  52. set slot (loop-value-2 parsed as number) of loop-player's current inventory to black stained glass pane
  53. set slot 36 of loop-player's current inventory to red stained glass pane named "&6-R$100" with lore "", "&cClique para subtrair", "&cesse valor da troca", ""
  54. set slot 45 of loop-player's current inventory to red stained glass pane named "&6-R$5,000" with lore "", "&cClique para subtrair", "&cesse valor da troca", ""
  55.  
  56. set slot 37 of loop-player's current inventory to gold nugget named "&eSaldo: &6R$0" with lore "", "&7Esse valor será enviado", "&7ao usuário na conclusão", "&7da troca.", ""
  57. set slot 46 of loop-player's current inventory to gray dye named "&aConfirmar troca" with lore "", "&7Clique para confirmar", "&7essa troca.", "", "&7Lembrando que o usuário", "&7também precisa confirmar", "&7para que a troca seja", "&7bem-sucedida.", ""
  58.  
  59. set slot 38 of loop-player's current inventory to lime stained glass pane named "&2+R$100" with lore "", "&aClique para adicionar", "&aesse valor à troca", ""
  60. set slot 47 of loop-player's current inventory to lime stained glass pane named "&2+R$1,000" with lore "", "&aClique para adicionar", "&aesse valor à troca", ""
  61. set slot 39 of loop-player's current inventory to lime stained glass pane named "&2+R$10,000" with lore "", "&aClique para adicionar", "&aesse valor à troca", ""
  62. set slot 48 of loop-player's current inventory to lime stained glass pane named "&2+R$50,000" with lore "", "&aClique para adicionar", "&aesse valor à troca", ""
  63.  
  64. set slot 53 of loop-player's current inventory to gold block named "&eSaldo: &6R$0" with lore "", "&7Esse é o saldo que o", "&7usuário te dará caso a", "&7troca seja bem-sucedida.", ""
  65. set slot 52 of loop-player's current inventory to red wool named "&cNão-confirmado" with lore "", "&7Indica se o usuário", "&7confirmou ou não a troca.", ""
  66.  
  67. on inventory close:
  68. if name of player's current inventory contains "&eTroca":
  69. {var::%player%::trocad} is set
  70. set {_numbers::*} to split "0,1,2,3,9,10,11,12,18,19,20,21" at ","
  71. loop all players:
  72. {var::%loop-player%::trocad} is {var::%player%::trocad}
  73. add loop-player to {_p::*}
  74. loop {_numbers::*}:
  75. slot loop-value-2 parsed as number of loop-value-1's current inventory is not air
  76. give slot loop-value-2 parsed as number of loop-value-1's current inventory to loop-value-1
  77. loop {_p::*}:
  78. delete {var::%loop-value%::troca}
  79. delete {troca::%loop-value%::*}
  80. delete {var::%loop-value%::trocad}
  81. if loop-value is not player:
  82. close loop-value's inventory
  83. clear {troca::%{var::%loop-value%::trocad}%::*}
  84. delete {var::%loop-value%::trocad}
  85. send "&cA troca foi cancelada por %player%&c." to loop-value
  86. on inventory click:
  87. if name of player's current inventory contains "&eTroca":
  88. cancel event
  89. set {_numbers::*} to split "0,1,2,3,9,10,11,12,18,19,20,21" at ","
  90. if "%clicked inventory%" is "inventory of %player%":
  91. if slot 46 of player's current inventory is lime dye:
  92. send "&cVocê não pode fazer alterações enquanto estiver com a troca confirmada."
  93. stop
  94. loop {_numbers::*}:
  95. slot loop-value parsed as number of player's current inventory is air
  96. add clicked item to {troca::%{var::%player%::trocad}%::*}
  97. set slot loop-value parsed as number of player's current inventory to clicked item
  98. loop all players:
  99. loop-player is not player
  100. {var::%player%::trocad} is {var::%loop-player%::trocad}
  101. set slot loop-value-1 parsed as number + 5 of loop-player's current inventory to clicked item
  102. remove clicked item from player's inventory
  103. stop loop
  104. else:
  105. clicked item is set
  106.  
  107. if slot 46 of player's current inventory is lime dye:
  108. if {_numbers::*} contains "%clicked slot%":
  109. send "&cVocê não pode fazer alterações enquanto estiver com a troca confirmada."
  110. stop
  111. else if clicked slot is 36, 38, 39, 45, 47 or 48:
  112. send "&cVocê não pode fazer alterações enquanto estiver com a troca confirmada."
  113. stop
  114. else:
  115. clicked slot is not 46
  116. slot 52 of player's current inventory is green wool
  117. set {_item} to red wool named "&cNão-confirmado" with lore "", "&7Indica se o usuário", "&7confirmou ou não a troca.", ""
  118. set slot 52 of player's current inventory to {_item}
  119. loop all players:
  120. loop-player is not player
  121. {var::%player%::trocad} is {var::%loop-player%::trocad}
  122. set slot 46 of loop-player's current inventory to gray dye named "&aConfirmar troca" with lore "", "&7Clique para confirmar", "&7essa troca.", "", "&7Lembrando que o usuário", "&7também precisa confirmar", "&7para que a troca seja", "&7bem-sucedida.", ""
  123.  
  124.  
  125. if {_numbers::*} contains "%clicked slot%":
  126. remove clicked item from {troca::%{var::%player%::trocad}%::*}
  127. add clicked item to player's inventory
  128. loop all players:
  129. loop-player is not player
  130. {var::%player%::trocad} is {var::%loop-player%::trocad}
  131. set slot clicked slot + 5 of loop-player's current inventory to air
  132. set slot clicked slot of player's current inventory to air
  133. else if clicked slot is 36, 38, 39, 45, 47 or 48:
  134. set {_actual} to uncolored name of slot 37 of player's current inventory
  135. set {_value} to uncolored name of clicked item
  136. replace all "Saldo: R$", "-", "+", "R$" and "," with "" in {_value} and {_actual}
  137. set {_value} to {_value} parsed as number
  138. set {_actual} to {_actual} parsed as number
  139. set {_d} to {_actual}
  140.  
  141. if name of clicked item contains "&6":
  142. remove {_value} from {_d}
  143. {_d} < 0
  144. set {_d} to 0
  145. else:
  146. if player's balance < {_actual} + {_value}:
  147. send "&cVocê não possui dinheiro para isso."
  148. else:
  149. add {_value} to {_d}
  150.  
  151. else if clicked slot is 46:
  152. if name of clicked item is "&cCancelar troca":
  153. set {_item} to red wool named "&cNão-confirmado" with lore "", "&7Indica se o usuário", "&7confirmou ou não a troca.", ""
  154. set slot 46 of player's current inventory to gray dye named "&aConfirmar troca" with lore "", "&7Clique para confirmar", "&7essa troca.", "", "&7Lembrando que o usuário", "&7também precisa confirmar", "&7para que a troca seja", "&7bem-sucedida.", ""
  155. else:
  156. set {_item} to green wool named "&aConfirmado" with lore "", "&7Agora confirme você também", "&7para finalizar a troca!", ""
  157. set slot 46 of player's current inventory to lime dye named "&cCancelar troca" with lore "", "&7Clique para cancelar", "&7essa troca.", "", "&7Lembrando que o usuário", "&7também precisa confirmar", "&7para que a troca seja", "&7bem-sucedida.", ""
  158. slot 52 of player's current inventory is a green wool
  159. loop all players:
  160. {var::%player%::trocad} is {var::%loop-player%::trocad}
  161. set {_value} to uncolored name of slot 37 of loop-player's current inventory
  162. set {_value2} to uncolored name of slot 53 of loop-player's current inventory
  163. replace all "Saldo: R$" with "" in {_value} and {_value2}
  164. if loop-player's balance >= {_value} parsed as number:
  165. set {_m::%loop-player%} to {_value2} parsed as number
  166. set {_me::%loop-player%} to {_value} parsed as number
  167. else:
  168. set {_f} to "%loop-player%-%{_value}%"
  169. add loop-player to {_p::*}
  170. loop {_p::*}:
  171. if {_f} is set:
  172. send "&cA troca foi cancelada pois %{_f}% não havia dinheiro o suficiente." to loop-value
  173. else:
  174. add {_m::%loop-value%} to loop-value's balance
  175. remove {_me::%loop-value%} from loop-value's balance
  176. loop {_numbers::*}:
  177. set {_e} to loop-value-2 parsed as number + 5
  178. give slot {_e} of loop-value-1's current inventory to loop-value-1's inventory
  179. send "&aTroca finalizada com sucesso." to loop-value
  180.  
  181. delete {var::%loop-value%::troca}
  182. delete {troca::%loop-value%::*}
  183. delete {var::%loop-value%::trocad}
  184. close loop-value's inventory
  185.  
  186. loop all players:
  187. loop-player is not player
  188. {var::%player%::trocad} is {var::%loop-player%::trocad}
  189. if {_item} is set:
  190. set slot 52 of loop-player's current inventory to {_item}
  191. if {_d} is set:
  192. set name of slot 53 of loop-player's current inventory to "&eSaldo: &6R$%{_d}%"
  193. set name of slot 37 of player's current inventory to "&eSaldo: &6R$%{_d}%"
  194.  
  195. on rightclick on player:
  196. {@ShiftTroca} is true
  197. player is sneaking
  198. make player execute command "trade %event-entity%"
  199.  
Advertisement
Add Comment
Please, Sign In to add comment