Solved Adding a command

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

g1ps

New Member
May 1, 2021
6
0
1
25
Where can I add command execution after purchasing an item?
Code:
function buySlot(p: player, base: integer):
  set {_uuid} to uuid of {_p}
  set {_price} to (100000*{_base})
  if {base::%{_uuid}%} is less than {_base}:
    if {base::%{_uuid}%}+1 is {_base}:
      if balance of {_p} is more than or equal to {_price}:
        remove {_price} from balance of {_p}
        add 1 to {base::%{_uuid}%}
        send "&aSuccessfully purchased this item." to {_p}
      else:
        send "&cError: &aNot enough money." to {_p}
    else:
      send "&cError: &aBuy first&n%{base::%{_uuid}%}+1%&r &arank." to {_p}
  else:
    send "&cError: &aYou already purchased this." to {_p}

Code:
on inventory click:
  if inventory name of current inventory of player is "&2&lРанги":
    cancel event
    if clicked slot is 10:
      if name of clicked slot contains "&a&lUPGRADE&8:":
        set {_x} to uncolored name of clicked slot
        replace all "UPGRADE: " with "" in {_x}
        set {_base} to {_x} parsed as a integer
        buySlot(player, {_base})
 
Code:
function buySlot(p: player, base: integer):
  set {_uuid} to uuid of {_p}
  set {_price} to (100000*{_base})
  if {base::%{_uuid}%} is less than {_base}:
    if {base::%{_uuid}%}+1 is {_base}:
      if balance of {_p} is more than or equal to {_price}:
        remove {_price} from balance of {_p}
        add 1 to {base::%{_uuid}%}
        send "&aSuccessfully purchased this item." to {_p}
        # HERE (make console/player execute command "")
      else:
        send "&cError: &aNot enough money." to {_p}
    else:
      send "&cError: &aBuy first&n%{base::%{_uuid}%}+1%&r &arank." to {_p}
  else:
    send "&cError: &aYou already purchased this." to {_p}

line 10
 
I added (10 line).He writes to me that "There's no player in a function event"

Code:
function buySlot(p: player, base: integer):
  set {_uuid} to uuid of {_p}
  set {_price} to (100000*{_base})
  if {base::%{_uuid}%} is less than {_base}:
    if {base::%{_uuid}%}+1 is {_base}:
      if balance of {_p} is more than or equal to {_price}:
        remove {_price} from balance of {_p}
        add 1 to {base::%{_uuid}%}
        send "&aSuccessfully purchased this item." to {_p}
        make console execute command "/broadcast %player% Bought rank &f1"
      else:
        send "&cError: &aNot enough money." to {_p}
    else:
      send "&cОшибка: &aКупи сначала &n%{base::%{_uuid}%}+1%&r &aранг." to {_p}
  else:
    send "&cError: &aYou already purchased this." to {_p}
 
Status
Not open for further replies.