1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Give player default item

Discussion in 'Skript' started by Skiddle, Sep 19, 2021.

Thread Status:
Not open for further replies.
  1. Skiddle

    Skiddle Member

    Joined:
    Sep 19, 2021
    Messages:
    1
    Likes Received:
    0
    Sooo, i want to make a shop system, but i don't want to do an if statement for every item so i came up with this code:
    Code (Text):
    1. on right click:
    2.   if name of event-entity is "&7Schmied":
    3.     open chest with 4 rows named "&8Schmiedin" to player
    4.     loop 9 times:
    5.       set slot loop-number + 26 of player's current inventory to black stained glass pane named "&cX"
    6.     set slot 0 of player's current inventory to iron helmet named "&7Eisenhelm &a500$ &c250$" with lore "&8[&7LMB&8] &aKaufen%nl%&8[&7RMB&8] &cVerkaufen"
    7.     set slot 1 of player's current inventory to iron chestplate named "&7Eisenhelm &a750$ &c375$" with lore "&8[&7LMB&8] &aKaufen%nl%&8[&7RMB&8] &cVerkaufen"
    8.     set slot 2 of player's current inventory to iron leggings named "&7Eisenhelm &a500$ &c250$" with lore "&8[&7LMB&8] &aKaufen%nl%&8[&7RMB&8] &cVerkaufen"
    9.     set slot 3 of player's current inventory to iron boots named "&7Eisenhelm &a200$ &c100$" with lore "&8[&7LMB&8] &aKaufen%nl%&8[&7RMB&8] &cVerkaufen"
    10.   if name of event-entity is "&7Farmer":
    11.     open chest with 4 rows named "&8Farmer" to player
    12.     loop 9 times:
    13.       set slot loop-number + 26 of player's current inventory to black stained glass pane named "&cX"
    14.   if name of event-entity is "&7Bauarbeiter":
    15.     open chest with 4 rows named "&8Bauarbeiter" to player
    16.     loop 9 times:
    17.       set slot loop-number + 26 of player's current inventory to black stained glass pane named "&cX"
    18. on inventory click:
    19.   if inventory name of player's current inventory is set:
    20.     if inventory name of player's current inventory is "&8Schmiedin":
    21.       cancel event
    22.       if clicked item is not black stained glass pane:
    23.         if clicked item is not air:
    24.           if "%click type%" contains "LEFT":
    25.             set {_name} to name of clicked item
    26.             set {_temp::*} to {_name} split at " "
    27.             set {_price} to {_temp::2}
    28.             replace "&a" with "" in {_price}
    29.             replace "$" with "" in {_price}
    30.             set {_p} to {_price} parsed as integer
    31.             if {money.%player's uuid%} is smaller than {_p}:
    32.               send "&cNicht genügend Geld"
    33.               stop
    34.             else:
    35.               remove {_p} from {money.%player's uuid%}
    36.               give player clicked item
    37.           else if "%click type%" contains "RIGHT":
    38.             set {_name} to name of clicked item
    39.             set {_temp::*} to {_name} split at " "
    40.             set {_price} to {_temp::3}
    41.             replace "&c" with "" in {_price}
    42.             replace "$" with "" in {_price}
    43.             set {_p} to {_price} parsed as integer
    44.             if player has clicked item in his inventory:
    45.               remove clicked item from player's inventory
    46.               add {_p} to {money.%player's uuid%}
    47.             else:
    48.               send "&cDu kannst das nicht verkaufen"
    49.               stop
    50.     if inventory name of player's current inventory is "&8Farmer":
    51.       cancel event
    52.     if inventory name of player's current inventory is "&8Bauarbeiter":
    53.       cancel event
    So now my problem is that when you buy something you get the name and lore with it (i know how to fix this), but now you can't sell something what doesn't have the name of the clicked item so how do i do this?

    I mean when you craft the item you want to sell so it has the default name or you renamed it in an anvil
     
  2. Minecoll_YT

    Supporter Forums Helper

    Joined:
    Dec 2, 2018
    Messages:
    650
    Likes Received:
    40
    Ich denke mal das du Deutsch bist: Das liegt an dem Addon was du für das GUI nutzt. Es gibt viele Fehler in solchen Addons, um dir mehr Ärgert zu ersparen, nutze am besten die Vanilla Methode von Skript um GUIs zu erstellen.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...