Untitled
raw download clone
TEXT
views 22
,
size 4368 b
on join:
 if {bp::%uuid of player%} != 1:
  set {bp::%uuid of player%} to 1
  set {bpa::%uuid of player%} to 1
  delete {bp1n::%uuid of player%}
  set {bp1n::%uuid of player%} to "Back Pack 1"
  set metadata tag "bp1" of player to chest inventory with 1 row named {bp1n::%uuid of player%}
  set metadata tag "bpshop" of player to chest inventory with 3 rows named "&bBackPack &2Shop&r!" 
  set slot integers between 0 and 26 of metadata tag "bpshop" of player to black stained glass pane named " "
  set slot 10 of metadata tag "bpshop" of player to red stained glass pane named "&c&lClose"
  set slot 13 of metadata tag "bpshop" of player to brown wool named "&6+1 Backpack" with lore "&r&a%{bpa::%uuid of player%}% &r+1 &atotal" and "&r&7Cost &c&l%({bpa::%uuid of player%} * 10000)%"
  set {bp::%uuid of player%} to 1
  set {bp1s::%uuid of player%} to 1
 else:
  set {_li} to 1
  loop {bpa::%uuid of player%} times:
   setBPs(player, {_li})
   set {_li} to ({_li} + 1)
  set metadata tag "bpshop" of player to chest inventory with 3 rows named "&bBackPack &2Shop&r!" 
  set slot integers between 0 and 26 of metadata tag "bpshop" of player to black stained glass pane named "  "
  set slot 10 of metadata tag "bpshop" of player to red stained glass pane named "&c&lClose"
  set slot 13 of metadata tag "bpshop" of player to brown wool named "&6+1 Backpack" with lore "&r&a%{bpa::%uuid of player%}% &r+1 &atotal" and "&r&7Cost &c&l%({bpa::%uuid of player%} * 10000)%"

function setBPs(p: player, a: number):
 set {_bpi} to 0
 set {_u} to uuid of {_p}
 set metadata tag "bp%{_a}%" of {_p} to chest inventory with {bp%{_a}%s::%{_u}%} rows named "%{bp%{_a}%n::%{_u}%}%"
 loop {bp%{_a}%::%{_u}%::*}:
  set slot {_bpi} of metadata tag "bp%{_a}%" of {_p} to loop-value
  set {_bpi} to ({_bpi} + 1)
command /backpack <text> [<text>] [<text>]:
 aliases: /bp
 usage: &6Use &c/bp (shop/number/name) &6to either go into the backpack shop, name, or open a backpack!
 trigger:
  if arg-2 is not set:
   if arg-1 is "shop":
    set slot 13 of metadata tag "bpshop" of player to brown wool named "&6+1 Backpack" with lore "&r&a%{bpa::%uuid of player%}% &r+1 &atotal" and "&r&7Cost &c&l%({bpa::%uuid of player%} * 10000)%"
    open metadata tag "bpshop" of player to player
   else:
    open metadata tag "bp%arg-1%" of player to player
    set {bpv::%uuid of player%} to arg-1
    set {bpvp::%uuid of player%} to player
  else if arg-2 = "name" or "rename":
   if player has permission "bpn.sk":
    set {bp%arg-1%n::%uuid of player%} to arg-3
  else if player has permission "op":
   open metadata tag "bp%arg-1%" of (arg-2 parsed as player) to player
   set {bpv::%uuid of player%} to arg-1
   set {bpvp::%uuid of player%} to (arg-2 parsed as player)

on inventory close:
 set {_bpv} to {bpv::%uuid of player%}
 event-inventory is (metadata tag "bp%{_bpv}%" of {bpvp::%uuid of player%}):
  set {bp%{_bpv}%::%player's uuid%::*} to (slots (integers from 0 to (rows of (metadata tag "bp%{_bpv}%" of {bpvp::%uuid of player%}))*9-1) of (metadata tag "bp%{_bpv}%" of {bpvp::%uuid of player%}))
  delete {bpvp::%uuid of player%}

on inventory click:
 if event-inventory = (metadata tag "bpshop" of player):
  if event- slot = 10:
   cancel event
   close player's inventory
  else if event-slot = 13:
   if player's balance >= ({bpa::%uuid of player%} * 10000):
    send "Come back soon!" to player
    remove ({bpa::%uuid of player%} * 10000) from player's balance
    set {bpa::%uuid of player%} to ({bpa::%uuid of player%} + 1)
    set {bp%{bpa::%uuid of player%}%s::%uuid of player%} to 1
    set {bp%{bpa::%uuid of player%}%n::%uuid of player%} to "Back Pack %{bpa::%uuid of player%}%"
   else:
    send "Poor! Come back LATER!" to player
   cancel event
   close player's inventory
  else if event-slot = 16:
   send "upgrade" to player
   cancel event
   close player's inventory
  else:
   cancel event

on quit:
 loop all players:
  if {bpvp::%uuid of loop-player%} = player:
   close loop-player's inventory

command /unsetbp <offline player>:
 permission: op
 trigger:
  delete {bp::%uuid of arg-1%}
  delete {bpa::%uuid of arg-1%}
command /debugp <offline player> <text> [<text>]:
 permission: op
 trigger:
  #send arg-2 to player
  send "%{%arg-2%::%uuid of arg-1%}%" to player
close fullscreen
Login or Register to edit or fork this paste. It's free.