Take a piece of a String

  • 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 community!

    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.

Marto_0

Member
Jul 14, 2017
15
1
3
So im trying to make a skript. That a GUI will popup. And u can dump ur stuff in. And it will automaticly sell. So i made a start. But im stuck at something. When i put 10 cobblestone to the GUI
so "add "%item%" to {inventory.%player%::*}". The value that will be added to {inventory.%player%::*} is 10 cobble_stone. Im trying to have all values of the blocks in a yml file like: "cobble_stone: 2". But the value that gets added is "10 cobble_stone" So i was wondering. How i can take the 10 away from the cobble_stone. And set the "10" to a local variable. That will loop how much the items has to be sold. And that a local variable is "cobble_stone" that i can read from the yml.

code_language.skript:
command /sellgui:
    trigger:
        wait 2 tick
        open chest with 6 rows named "Sell GUI" to player
        file "plugins/Skript/Files/ItemPrices.yml"'s line 3


on store:
    if name of player's current inventory contains "Sell GUI":
        add "%item%" to {inventory.%player%::*}

on unstore:
    if name of player's current inventory contains "Sell GUI":
        loop {inventory.%player%::*}:
            set {_item} to loop-value
            if {_item} = "%loop-value%":
                remove "%item%" from {inventory.%player%::*}



On Inventory Close:
    loop {inventory.%player%::*}:
        broadcast "%loop-value%"
        set {_MoneySell} to single value "%loop-value%" get of "plugins/Skript/Files/ItemPrices.yml"
        broadcast "%{_MoneySell}%"
        remove loop-value from {inventory.%player%::*}
    reset {inventory.%player%::*}

Thanks for reading.
Sorry for the wurst english ever btw o3o
 
Status
Not open for further replies.