Amount of Items in Inventory

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

Nexurant

New Member
Jun 12, 2019
7
0
0
Hey.

I'm trying to set up a command where players can use /diamond and it sells all their diamonds for them. Certain ranks also get sell bonuses (25% more, 50% etc). I'm running 1.8 dev37c Skript. I've looked at other posts, and the code I'm using should work fine. Is it because of my Skript version? If so, is there a workaround? Error message: https://gyazo.com/4bf23ef5a8102b661261e49c2c393fc0

Code:
command /diamond:
    description: Sell Diamonds
    trigger:
        set {_} to amount of diamonds in player's inventory
        if {_} = 0:
            message "&c» &7You do not have any &bDiamonds&7!"
            stop
        if player has permission "sell.titan":
            add {_}*6.25 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*6.25&7. &a(25%% RANK BONUS)"
            stop
       
        if player has permission "sell.mystic":
            add {_}*7.50 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*7.50&7. &a(50%% RANK BONUS)"
            stop
        if player has permission "sell.legend":
            add {_}*10 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*10&7. &a(100%% RANK BONUS)"
            stop
       
        add {_}*5 to {balance::%player's uuid%}
        stop
        send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*5&7."

Thanks in advance
 
Last edited:
try this
Code:
set {_} to item amount of diamonds in player's inventory
 
Try this:
Code:
command /diamond:
    description: Sell Diamonds
    trigger:
        loop all items in inventory of player:
            if loop-item is diamond:
                set {_} to item amount of loop-item
        if {_} = 0:
            message "&c» &7You do not have any &bDiamonds&7!"
            stop
        if player has permission "sell.titan":
            add {_}*6.25 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*6.25&7. &a(25%% RANK BONUS)"
            stop
      
        if player has permission "sell.mystic":
            add {_}*7.50 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*7.50&7. &a(50%% RANK BONUS)"
            stop
        if player has permission "sell.legend":
            add {_}*10 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*10&7. &a(100%% RANK BONUS)"
            stop
      
        add {_}*5 to {balance::%player's uuid%}
        stop
        send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*5&7."
 
Try this:
Code:
command /diamond:
    description: Sell Diamonds
    trigger:
        loop all items in inventory of player:
            if loop-item is diamond:
                set {_} to item amount of loop-item
        if {_} = 0:
            message "&c» &7You do not have any &bDiamonds&7!"
            stop
        if player has permission "sell.titan":
            add {_}*6.25 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*6.25&7. &a(25%% RANK BONUS)"
            stop
     
        if player has permission "sell.mystic":
            add {_}*7.50 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*7.50&7. &a(50%% RANK BONUS)"
            stop
        if player has permission "sell.legend":
            add {_}*10 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*10&7. &a(100%% RANK BONUS)"
            stop
     
        add {_}*5 to {balance::%player's uuid%}
        stop
        send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*5&7."


Getting this error: https://gyazo.com/48bde33db3267ee7f05975670848042f.
Could you tell me what Skript version you're using and if you're using any addons?
 
Or do this:
code_language.skript:
set {_inv} to player's inventory
if {_inv} doesn't contains diamonds:
    message "&c» &7You do not have any &bDiamonds&7!"
    stop
if {_inv} contains diamonds:
    set {_diamonds} to amount of diamonds in {_inv}
# do something
 
Hey.

I'm trying to set up a command where players can use /diamond and it sells all their diamonds for them. Certain ranks also get sell bonuses (25% more, 50% etc). I'm running 1.8 dev37c Skript. I've looked at other posts, and the code I'm using should work fine. Is it because of my Skript version? If so, is there a workaround? Error message: https://gyazo.com/4bf23ef5a8102b661261e49c2c393fc0

Code:
command /diamond:
    description: Sell Diamonds
    trigger:
        set {_} to amount of diamonds in player's inventory
        if {_} = 0:
            message "&c» &7You do not have any &bDiamonds&7!"
            stop
        if player has permission "sell.titan":
            add {_}*6.25 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*6.25&7. &a(25%% RANK BONUS)"
            stop
      
        if player has permission "sell.mystic":
            add {_}*7.50 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*7.50&7. &a(50%% RANK BONUS)"
            stop
        if player has permission "sell.legend":
            add {_}*10 to {balance::%player's uuid%}
            send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*10&7. &a(100%% RANK BONUS)"
            stop
      
        add {_}*5 to {balance::%player's uuid%}
        stop
        send "&a» &7You sold &f%{_}%&7 Diamonds for &f${_}*5&7."

Thanks in advance


Do this maybe?


code_language.skript:
set {_a} to 0
loop all items in player's inventory:
    if loop-item is diamond:
        add amount of loop-item to {_a}
if {_a} is 0:
    #CODE
else:
    #CODE
 
Or do this:
code_language.skript:
set {_inv} to player's inventory
if {_inv} doesn't contains diamonds:
    message "&c» &7You do not have any &bDiamonds&7!"
    stop
if {_inv} contains diamonds:
    set {_diamonds} to amount of diamonds in {_inv}
# do something
Do this maybe?


code_language.skript:
set {_a} to 0
loop all items in player's inventory:
    if loop-item is diamond:
        add amount of loop-item to {_a}
if {_a} is 0:
    #CODE
else:
    #CODE
Both don't work.

I've tried my original code on a 1.15 server with the latest version of Skript and no addons and it appears to be working fine. The expression that I'm trying to use on my 1.8 server requires Skript 2.0. Why isn't dev37c working?
 
Status
Not open for further replies.