Solved Shop

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

Runakai

Supporter
Apr 27, 2018
496
32
28
21
Yeah, it's me again. So..

code_language.skript:
on inventory click:       
    if event-inventory is not player's inventory:
        if name of player's current inventory is "&cErze":
            cancel event 
            if clicked slot is 9:
                close inventory of player
                make player execute command "/shop"
            if player has enough space for 64 dirt:
                clicked item is not air:
                    clicked slot is 0:
                        if clicked type is LEFT mouse:
                            if {coins::%player%} is more than {@ironpricebuyandsell}-1:
                                give player a iron ingot
                                remove {@ironpricebuyandsell} from {coins::%player%}
                                send "{@buyed1}"
                        else if clicked type is right mouse:
                            loop all items in the player's inventory:
                                if loop-item is iron ingot:
                                    if amount of loop-item is more than 0:
                                        remove 1 iron ingot from the player
                                        play "NOTE_PLING" to player at volume 0.2
                                        add {@ironpricebuyandsell} to {coins::%player%}
                                        #send "{@selled1}"
                                    else:
                                        send "{@needone}"
                        else if clicked type is right mouse button with shift:
                            loop all items in the player's inventory:
                                if loop-item is iron ingot:
                                    if amount of loop-item is more than 63:
                                        set {_amountitem} to amount of loop-item
                                        remove 64 iron ingot from the player
                                        play "NOTE_PLING" to player at volume 0.2
                                        add {@ironpricebuyandsell}*64 to {coins::%player%}
                                        #send "{@selledstack}"
                                    else:
                                        send "{@needstack}"
                        else if clicked type is left mouse button with shift:
                            if {coins::%player%} is more than {@ironpricebuyandsell}*64-1:
                                remove {@ironpricebuyandsell}*64 from {coins::%player%}
                                send "{@buyedstack}"
                                loop 64 times:
                                    wait 1 tick
                                    give player a iron ingot

I want skript to ignore actually the total amount of the item in the player's inventory. They should just sell 1 if they have more than 1 in their inventory. But with this skript, when i have e.g 10 stacks of Iron ingots, it sells 10 iron ingots although it should just sell one.
 
you need to do, loop-items in {_player}'s inventory,

code_language.skript:
function Sell(player: player, block: item):
    set {_Amount} to amount of {_block} in {_player}'s inventory
    send "%{_Amount}%" to {_player}
 
you need to do, loop-items in {_player}'s inventory,

code_language.skript:
function Sell(player: player, block: item):
    set {_Amount} to amount of {_block} in {_player}'s inventory
    send "%{_Amount}%" to {_player}
Everything is working alright but I just want the Skript to remove 1 of the iron I got but it removes 1 from every stack it looped and not 1 from the whole amount of the item Ingots in the inventory
 
code_language.skript:
    loop all items in the player's inventory:
        if loop-item is iron ingot:
            if amount of loop-item is more than 0:
                remove 1 iron ingot from the player"

    #Cant you use this instead of this ^?


    if player's inventory contains a iron ingot:
        remove 1 irong ingot from player's inventory
 
Status
Not open for further replies.