Solved money 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 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.

SoMuchWessel

Active Member
Apr 3, 2017
147
3
18
47
Hi guys,

I want to make a command like /saldo that shows how much money you have in your inventory.
I have a couple of items that are worth something. this is the list:
Fermented spider eye: 10
Blaze powder: 20
Magma cream: 50
Rabbit foot: 100
Rabbit hide: 250
Clay: 500
Gunpowder: -50
Flint: -250
Slimeball: -250
Brick: -500

I want the command to check if the player has items of these in his inventory, if so, i want a code to do the math so that at the end, the saldo will be shown.
Like if you have 10 spider eyes, 1 magma cream, 1 blazepowder, and 2 gunpowders, that it will be:
10x10 = 100
1x50 = 50
1x 20
2x -50
Total (the message to the player): Saldo: 120

Can someone help me with this?
 
TRY something like this for every item (not tested):
code_language.skript:
command /howmuchmoney:
    trigger:
        if player has gunpowder:
            set {_powder} to number of all gunpowders in player's inventory
            wait a tick
            set {_powderprice} to ({_powder} * 10)
            send "You have %{_powderprice}% moneys in your inventory" to player
        else:
            send "You don't have any item that you can sell in your inventory." to player
 
TRY something like this for every item (not tested):
code_language.skript:
command /howmuchmoney:
    trigger:
        if player has gunpowder:
            set {_powder} to number of all gunpowders in player's inventory
            wait a tick
            set {_powderprice} to ({_powder} * 10)
            send "You have %{_powderprice}% moneys in your inventory" to player
        else:
            send "You don't have any item that you can sell in your inventory." to player

Error: Cant understand this expression: 'number of all gunpowders in player's inventory'
 
It's working fine for me. What's the version of Skript?

EDIT:
Woops, my mistake. You need SkRayFall for that expression.
 
It worked for me with "gunpowders" too, but ok.
So, is it working? Is this what you need?
 
Status
Not open for further replies.