Solved Sell all not working

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

Potato

Active Member
Feb 24, 2020
57
1
0
17
I tried to create a /Sell all skript, and this is what my final result came into. But somehow it can't register if the player has the specific item(s)..

Code:
Options:
    troutPRICE: 10.0
    bfishPRICE: 7.0
    tunaPRICE: 5.0

Command /Sell [<String>]:
    trigger:
        if arg-1 is "All":
            if player has raw_fish with name "&7Trout" or clownfish with name "&7Butterfly Fish" or 349:1 with name "&7Tuna":
                set {_Trout} to number of 349 named "&7Trout" in player's inventory
                set {_Bfish} to number of clownfish named "&7Butterfly Fish" in player's inventory
                set {_Tuna} to number of 349:1 named "&7Tuna" in player's inventory
                loop {_trout} times
                remove 1 raw fish named "&7Trout" from player's inventory
                loop {_Bfish} times
                remove 1 clownfish named "&7Butterfly Fish" from player's inventory
                loop {_Tuna} times
                remove 1 349:1 named "&7Tuna" from player's inventory
                if {_trout} > 0:
                    set {_Trout1} to {_Trout} * {@troutPRICE}
                if {_Bfish} > 0:
                    set {_Bfish1} to {_Bfish} * {@bfishPRICE}
                if {Tuna} > 0:
                    set {_Tuna1} to {_Tuna} * {@tunaPRICE}
                set {_Sum} to {_trout1} + {_Bfish1} + {_Tuna1}
                Add {_Sum} to player's balance
                send "&bYou sold all your fish for a total of &a%{_Sum}%&b!"
                play "BLOCK_NOTE_PLING" to player
            else:
                send "&cYou have nothing to sell.."
 
Here is a fixed version of sell all (Works for me):

Code:
options:
    troutPRICE: 10.0
    bfishPRICE: 7.0
    tunaPRICE: 5.0
 
command /sell [<string>]:
    trigger:
        if arg-1 is not set:
            send "&cUsage: /sell all"
            stop
        if arg-1 is "all":
            if player has a fish or clownfish or salmon:
                set {_trout} to number of raw fish named "&7Trout" in player's inventory
                set {_bfish} to number of clownfish named "&7Butterfly Fish" in player's inventory
                set {_tuna} to number of raw salmon named "&7Tuna" in player's inventory
                if {_trout} and {_bfish} and {_tuna} = 0:
                    send "&cYou cannot sell this type of fish!"
                    stop
                if {_trout} > 0:
                    set {_troutPrice} to {_trout} * {@troutPRICE}
                if {_bfish} > 0:
                    set {_bfishPrice} to {_bfish} * {@bfishPRICE}
                if {_tuna} > 0:
                    set {_tunaPrice} to {_tuna} * {@tunaPRICE}
                loop {_trout} times:
                    remove 1 raw fish named "&7Trout" from player's inventory
                loop {_bfish} times:
                    remove 1 clownfish named "&7Butterfly Fish" from player's inventory
                loop {_tuna} times:
                    remove 1 raw salmon named "&7Tuna" from player's inventory
                set {_total} to {_troutPrice} + {_bfishPrice} + {_tunaPrice}
                Add {_total} to player's balance
                send "&bYou sold all your fish for a total of &a$%{_total}%&b!"
                play "BLOCK_NOTE_PLING" to player
            else:
                send "&cYou have nothing to sell.."
                stop
 
Here is a fixed version of sell all (Works for me):

Code:
options:
    troutPRICE: 10.0
    bfishPRICE: 7.0
    tunaPRICE: 5.0
 
command /sell [<string>]:
    trigger:
        if arg-1 is not set:
            send "&cUsage: /sell all"
            stop
        if arg-1 is "all":
            if player has a fish or clownfish or salmon:
                set {_trout} to number of raw fish named "&7Trout" in player's inventory
                set {_bfish} to number of clownfish named "&7Butterfly Fish" in player's inventory
                set {_tuna} to number of raw salmon named "&7Tuna" in player's inventory
                if {_trout} and {_bfish} and {_tuna} = 0:
                    send "&cYou cannot sell this type of fish!"
                    stop
                if {_trout} > 0:
                    set {_troutPrice} to {_trout} * {@troutPRICE}
                if {_bfish} > 0:
                    set {_bfishPrice} to {_bfish} * {@bfishPRICE}
                if {_tuna} > 0:
                    set {_tunaPrice} to {_tuna} * {@tunaPRICE}
                loop {_trout} times:
                    remove 1 raw fish named "&7Trout" from player's inventory
                loop {_bfish} times:
                    remove 1 clownfish named "&7Butterfly Fish" from player's inventory
                loop {_tuna} times:
                    remove 1 raw salmon named "&7Tuna" from player's inventory
                set {_total} to {_troutPrice} + {_bfishPrice} + {_tunaPrice}
                Add {_total} to player's balance
                send "&bYou sold all your fish for a total of &a$%{_total}%&b!"
                play "BLOCK_NOTE_PLING" to player
            else:
                send "&cYou have nothing to sell.."
                stop

Thanks Duck
 
Status
Not open for further replies.