Solved Sell item based on lore

  • 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.

TheVedel1

Member
Jul 28, 2017
14
0
1
27
Hi guys, I'm trying to sell an item based on it's lore, yet it doesnt work. I only get error with the sell-all part "%number% %text% is not valid item data"

Not sure what it means.

Yet first sell script doesnt work, yet no errors. Any ideas why? Thank you.

Skript:

code_language.skript:
on right click on player:
    if name of clicked player is "&a&lTrader":#12
        set {_lore::*} to lore of player's tool split by "||"
        if "%{_lore::*}%" contains "Sell Price:":
            loop {_lore::*}:
                set {_price::*} to uncolored loop-value parsed as "Sell Price: %number% Gold"
                play "BLOCK_NOTE_XYLOPHONE" to player at volume 1
                remove 1 of item from player's inventory
                add {_price::1} to player's balance
                send "&6You sold your item for: &e%{_price::1}% %{_price::*}% %{_lore::*}% Gold" to player
                send "&6You now have: &e%player's balance% Gold" to player
                exit loop
                stop
        else:
            send "&cYou cant sell this item" to player
            
command /sellall:
    trigger:
        loop all items in player's inventory:
            set {_lore::*} to lore of loop-item split by "||"
            loop {_lore::*}:
                set {_test::*} to uncolored loop-value parsed as "Sell Price: %number% %text%"
                play "BLOCK_NOTE_XYLOPHONE" to player at volume 1
                remove 1 of loop-item from player's inventory
                add {_test::1} to player's balance
                send "&6You sold your item for: &e%{_test::1}% Gold" to player
                send "&6You now have: &e%player's balance% Gold" to player
                exit loop
                stop
 
Use the help request layout.

code_language.skript:
set {_lore::*} to lore of player's tool split at "||"
loop {_lore::*}: #each loop is a different line of lore
    loop-value contains "Sell Price:" #if the line of lore is the line that contains the sell price...
    set {_price::*} to loop-value split at "Sell Price: " #then we get the values using split, the first one returns 'sell price:' and '10 gold' for example.
    set {_price::*} to {_price::2} split at " Gold" #we want the '10 gold' part so {_price::2}. We split it into '10' and 'Gold'
    set {_price} to {_price::1} parsed as number #we only want the number, so {_price::1}
    message "the item sells for %{_price}%" #and there you have it
    stop loop #we don't need to keep looping as we got what we wanted already.
if {_price} is not set:
    message "the item can't be sold"
    stop

Try this. I have not used split in a long time so maybe it doesn't work. You get the idea.
 
Use the help request layout.

code_language.skript:
set {_lore::*} to lore of player's tool split at "||"
loop {_lore::*}: #each loop is a different line of lore
    loop-value contains "Sell Price:" #if the line of lore is the line that contains the sell price...
    set {_price::*} to loop-value split at "Sell Price: " #then we get the values using split, the first one returns 'sell price:' and '10 gold' for example.
    set {_price::*} to {_price::2} split at " Gold" #we want the '10 gold' part so {_price::2}. We split it into '10' and 'Gold'
    set {_price} to {_price::1} parsed as number #we only want the number, so {_price::1}
    message "the item sells for %{_price}%" #and there you have it
    stop loop #we don't need to keep looping as we got what we wanted already.
if {_price} is not set:
    message "the item can't be sold"
    stop

Try this. I have not used split in a long time so maybe it doesn't work. You get the idea.

Thanks for trying to help out, yet I get no errors and it doesnt work.
[doublepost=1504686544,1504628010][/doublepost]Is it possible to read the last line of an item's lore? Dont see anything in documentation.
[doublepost=1505073737][/doublepost]Anyone?
 
Is it possible to read the last line of an item's lore? Dont see anything in documentation.

code_language.skript:
set {_L::*} to lore of player's tool split at "||"
set {_imlastone} to {_L::%size of {_L::*}%}


btw what do you mean "Doesn't work" its don't show send message from xUndefined code?
 
code_language.skript:
set {_L::*} to lore of player's tool split at "||"
set {_imlastone} to {_L::%size of {_L::*}%}


btw what do you mean "Doesn't work" its don't show send message from xUndefined code?

I tried debugging, and it's like the "loop-value" doesnt work. Btw, how does that code work?
 
I tryed... Uhm youre right. He forget to add

"%loop-value%"

so just change only one line:

code_language.skript:
"%loop-value%" contains "Sell Price:"
 
I tryed... Uhm youre right. He forget to add

"%loop-value%"

so just change only one line:

code_language.skript:
"%loop-value%" contains "Sell Price:"
Great, works uncolored. How do you parse it as uncolored text again?
[doublepost=1505077498,1505077392][/doublepost]
I tryed... Uhm youre right. He forget to add

"%loop-value%"

so just change only one line:

code_language.skript:
"%loop-value%" contains "Sell Price:"
And what about getting the quantity of the held item? I've never been able to do that.
 
Great, works uncolored. How do you parse it as uncolored text again?
[doublepost=1505077498,1505077392][/doublepost]
And what about getting the quantity of the held item? I've never been able to do that.
The Number its already parsing (%{_price}%), and uncolored just this
code_language.skript:
set {_lore::*} to uncolored lore of player's tool split at "||"


%amount of player's tool%
 
The Number its already parsing (%{_price}%), and uncolored just this
code_language.skript:
set {_lore::*} to uncolored lore of player's tool split at "||"


%amount of player's tool%
You have no idea how much you're helping us dude. Thank you very much.

Would this work: loop amount of player's tool times:
[doublepost=1505078268,1505078155][/doublepost]I'm trying to write a sellall skript, with this too. Looping all players items, looping amount of loop-item etc.
 
You have no idea how much you're helping us dude. Thank you very much.

Would this work: loop amount of player's tool times:
[doublepost=1505078268,1505078155][/doublepost]I'm trying to write a sellall skript, with this too. Looping all players items, looping amount of loop-item etc.

Im unsure with the loop player's inventory. i never did it.
code_language.skript:
loop all item in player's inventory:
    loop-item is player's held item:
        send "%amount of loop-item% More founds. Lets me do the jobs"
        add amount of loop-item to {_sellall}
    send "Alright. i found in player's inventory %{_sellall}% Items"


#edit:

i found my old skript... Easier way:
code_language.skript:
set {_amount} to number of player's tool in player's inventory
 
Status
Not open for further replies.