Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Código desenvolvido por DanielZinh#7616
- # LoS Skripters - EliteSK
- options:
- # Apertar com o direito + shift em um player para oferecer troca
- ShiftTroca: true
- # Estar perto para realizar trocas
- NecessarioEstarPerto: true
- DistanciaMinima: 20 # Blocos
- on unload:
- delete {troca::*}
- command /trade [<player>]:
- aliases: trocar
- trigger:
- if arg 1 is not set:
- send "&cUse /trade (player)"
- else if {troca::%player%::*} contains player:
- send "&cEsse jogador já possui um pedido de troca seu"
- else:
- if "%{troca::%player%::*}%" doesn't contain "%arg-1%":
- if {troca::%arg-1%::*} contains player:
- send "&cVocê já enviou um pedido de troca para esse jogador"
- stop
- if {@NecessarioEstarPerto} is true:
- distance between arg-1 and player > {@DistanciaMinima}
- send "&cVocê está muito longe do jogador." to player
- stop
- send "&f%player% &7enviou um pedido de troca para você, utilize &f/trade %player% &7para aceitar" to arg-1
- send "&7Você enviou um pedido de troca para &f%arg-1%&7." to player
- add player to {troca::%arg-1%::*}
- else:
- if {troca::%player%::*} doesn't contain arg-1:
- send "&cEsse jogador não enviou um pedido de troca para você."
- else if arg-1 is not online:
- send "&cEsse jogador não está mais on-line."
- else if {var::%arg-1%::troca} is set:
- send "&cEsse jogador já está em uma troca."
- else:
- loop all players:
- loop-player is arg-1 or player
- open chest with 6 rows named "&eTroca %arg-1%" to loop-player
- clear {troca::%arg-1%::*} and {troca::%player%::*}
- set {var::%loop-player%::troca} to arg-1
- set {var::%arg-1%::troca} to loop-player
- set {var::%arg-1%::trocad} to arg-1
- set {var::%loop-player%::trocad} to arg-1
- wait 1 tick
- if name of loop-player's current inventory contains "&eTroca":
- set {_e::*} to split "4,13,22,31,30,29,28,27,40,49,50,51" at ","
- loop {_e::*}:
- set slot (loop-value-2 parsed as number) of loop-player's current inventory to black stained glass pane
- 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||"
- 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||"
- 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.||"
- set slot 46 of loop-player's current inventory to dye:8 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.||"
- set slot 38 of loop-player's current inventory to light green stained glass pane named "&2+R$100" with lore "||&aClique para adicionar||&aesse valor à troca||"
- set slot 47 of loop-player's current inventory to light green stained glass pane named "&2+R$1,000" with lore "||&aClique para adicionar||&aesse valor à troca||"
- set slot 39 of loop-player's current inventory to light green stained glass pane named "&2+R$10,000" with lore "||&aClique para adicionar||&aesse valor à troca||"
- set slot 48 of loop-player's current inventory to light green stained glass pane named "&2+R$50,000" with lore "||&aClique para adicionar||&aesse valor à troca||"
- 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.||"
- set slot 52 of loop-player's current inventory to red wool block named "&cNão-confirmado" with lore "&5||&7Indica se o usuário||&7confirmou ou não a troca.||&5"
- on inventory close:
- if name of player's current inventory contains "&eTroca":
- {var::%player%::trocad} is set
- set {_numbers::*} to split "0,1,2,3,9,10,11,12,18,19,20,21" at ","
- loop all players:
- {var::%loop-player%::trocad} is {var::%player%::trocad}
- add loop-player to {_p::*}
- loop {_numbers::*}:
- slot loop-value-2 parsed as number of loop-value-1's current inventory is not air
- give slot loop-value-2 parsed as number of loop-value-1's current inventory to loop-value-1
- loop {_p::*}:
- delete {var::%loop-value%::troca}
- delete {troca::%loop-value%::*}
- delete {var::%loop-value%::trocad}
- if loop-value is not player:
- close loop-value's inventory
- clear {troca::%{var::%loop-value%::trocad}%::*}
- delete {var::%loop-value%::trocad}
- send "&cA troca foi cancelada por %player%&c." to loop-value
- on inventory click:
- if name of player's current inventory contains "&eTroca":
- cancel event
- set {_numbers::*} to split "0,1,2,3,9,10,11,12,18,19,20,21" at ","
- if "%clicked inventory%" is "inventory of %player%":
- if slot 46 of player's current inventory is dye:10:
- send "&cVocê não pode fazer alterações enquanto estiver com a troca confirmada."
- stop
- loop {_numbers::*}:
- slot loop-value parsed as number of player's current inventory is air
- add clicked item to {troca::%{var::%player%::trocad}%::*}
- set slot loop-value parsed as number of player's current inventory to clicked item
- loop all players:
- loop-player is not player
- {var::%player%::trocad} is {var::%loop-player%::trocad}
- set slot loop-value-1 parsed as number + 5 of loop-player's current inventory to clicked item
- remove clicked item from player's inventory
- stop loop
- else:
- clicked item is set
- if slot 46 of player's current inventory is dye:10:
- if {_numbers::*} contains "%clicked slot%":
- send "&cVocê não pode fazer alterações enquanto estiver com a troca confirmada."
- stop
- else if clicked slot is 36, 38, 39, 45, 47 or 48:
- send "&cVocê não pode fazer alterações enquanto estiver com a troca confirmada."
- stop
- else:
- clicked slot is not 46
- slot 52 of player's current inventory is green wool block
- set {_item} to red wool block named "&cNão-confirmado" with lore "||&7Indica se o usuário||&7confirmou ou não a troca.||"
- set slot 52 of player's current inventory to {_item}
- loop all players:
- loop-player is not player
- {var::%player%::trocad} is {var::%loop-player%::trocad}
- set slot 46 of loop-player's current inventory to dye:8 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.||"
- if {_numbers::*} contains "%clicked slot%":
- remove clicked item from {troca::%{var::%player%::trocad}%::*}
- add clicked item to player's inventory
- loop all players:
- loop-player is not player
- {var::%player%::trocad} is {var::%loop-player%::trocad}
- set slot clicked slot + 5 of loop-player's current inventory to air
- set slot clicked slot of player's current inventory to air
- else if clicked slot is 36, 38, 39, 45, 47 or 48:
- set {_actual} to uncolored name of slot 37 of player's current inventory
- set {_value} to uncolored name of clicked item
- replace all "Saldo: R$", "-", "+", "R$" and "," with "" in {_value}
- replace all "Saldo: R$", "-", "+", "R$" and "," with "" in {_actual}
- set {_value} to {_value} parsed as number
- set {_actual} to {_actual} parsed as number
- set {_d} to {_actual}
- if name of clicked item contains "&6":
- remove {_value} from {_d}
- {_d} < 0
- set {_d} to 0
- else:
- if player's balance < {_actual} + {_value}:
- send "&cVocê não possui dinheiro para isso."
- else:
- add {_value} to {_d}
- else if clicked slot is 46:
- if name of clicked item is "&cCancelar troca":
- set {_item} to red wool block named "&cNão-confirmado" with lore "||&7Indica se o usuário||&7confirmou ou não a troca.||"
- set slot 46 of player's current inventory to dye:8 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.||"
- else:
- set {_item} to green wool block named "&aConfirmado" with lore "||&7Agora confirme você também||&7para finalizar a troca!||"
- set slot 46 of player's current inventory to dye:10 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.||"
- slot 52 of player's current inventory is a green wool block
- loop all players:
- {var::%player%::trocad} is {var::%loop-player%::trocad}
- set {_value} to uncolored name of slot 37 of loop-player's current inventory
- set {_value2} to uncolored name of slot 53 of loop-player's current inventory
- replace all "Saldo: R$" with "" in {_value}
- replace all "Saldo: R$" with "" in {_value2}
- if loop-player's balance >= {_value} parsed as number:
- set {_m::%loop-player%} to {_value2} parsed as number
- set {_me::%loop-player%} to {_value} parsed as number
- else:
- set {_f} to "%loop-player%-%{_value}%"
- add loop-player to {_p::*}
- loop {_p::*}:
- if {_f} is set:
- send "&cA troca foi cancelada pois %{_f}% não havia dinheiro o suficiente." to loop-value
- else:
- add {_m::%loop-value%} to loop-value's balance
- remove {_me::%loop-value%} from loop-value's balance
- loop {_numbers::*}:
- set {_e} to loop-value-2 parsed as number + 5
- give slot {_e} of loop-value-1's current inventory to loop-value-1's inventory
- send "&aTroca finalizada com sucesso." to loop-value
- delete {var::%loop-value%::troca}
- delete {troca::%loop-value%::*}
- delete {var::%loop-value%::trocad}
- close loop-value's inventory
- loop all players:
- loop-player is not player
- {var::%player%::trocad} is {var::%loop-player%::trocad}
- if {_item} is set:
- set slot 52 of loop-player's current inventory to {_item}
- if {_d} is set:
- set name of slot 53 of loop-player's current inventory to "&eSaldo: &6R$%{_d}%"
- set name of slot 37 of player's current inventory to "&eSaldo: &6R$%{_d}%"
- on rightclick on player:
- {@ShiftTroca} is true
- player is sneaking
- make player execute command "trade %event-entity%"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement