Selling wheat

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

Mattllama987

Active Member
Aug 5, 2018
225
7
18
24
Hello, I need a little help with a project im working on. Im making a shop skript and seem to be stuck on a little part. How can i make it so if a player has anywhere from 1 to 500 wheat in there inv, and click the sell all button, it will remove it all and multiply the sell cost depending on what group they are in. How can i loop the amount and multiply the money they will get? I hope you understand what im saying hahaha.

Here is the code i have now:

Code:
function wheat(P: player):
    open chest with 3 rows named "&aWheat" to {_P}
    format gui slot 17 of {_P} with command block named "&cSell all" to run:
        loop all items in {_P}'s inventory:
            if loop-value contains wheat:
                send "test" to {_P}


Thanks!
~Matt
 
You dont even need to loop
code_language.skript:
set {_a} to amount of wheat in inventory of {_p}
remove {_a} of wheat from {_p}
add ({_a} * 10) to balance of {_p}
I used `10` as an example, but obviously use whatever number you need
 
Ok, thats way easier than i thought lol. But i get no errors and its not removing the items and giving money.


Code:
function wheat(P: player):
    open chest with 1 rows named "&aWheat" to {_P}
    format gui slot 8 of {_P} with command block named "&cSell all" to run:
        if {_P}'s prefix contains "Outcast":
            set {_a} to amount of wheat in inventory of {_p}
            remove {_a} of wheat from {_p}
            add ({_a} * 10) to balance of {_p}
 
Ok, thats way easier than i thought lol. But i get no errors and its not removing the items and giving money.


Code:
function wheat(P: player):
    open chest with 1 rows named "&aWheat" to {_P}
    format gui slot 8 of {_P} with command block named "&cSell all" to run:
        if {_P}'s prefix contains "Outcast":
            set {_a} to amount of wheat in inventory of {_p}
            remove {_a} of wheat from {_p}
            add ({_a} * 10) to balance of {_p}
oops, change the {_p} to {_P}
 
What version of skript do you have?
[doublepost=1572914380,1572913600][/doublepost]This is the full code here.


Code:
function wheat(P: player):
    open chest with 1 rows named "&aWheat" to {_P}
    format gui slot 8 of {_P} with command block named "&cSell all" to run:
        if {_P}'s prefix contains "Outcast":
            set {_a} to amount of wheat in inventory of {_P}
            Remove {_a} from {_P}
            add ({_a} * 10) to balance of {_P}
    format gui slot 0 of {_P} with red concrete named "&cCancel" to run:
        mainshop(player)
    format gui slot 4 of {_P} with wheat named "&aSell Prices:" with lore "&A+ &fOutcast = 11", "&a+ &fBaron = 27.5", "&a+ &fEarl = 44", "&a+ &fRegent = 60.5", "&a+ &fKnight/Lady = 77", "&a+ &fPrince/Princess = 93.5" and "&a+ &fKing/Queen = 110"
function crops(P: player):
    open chest with 6 rows named "&aCrops" to {_P}
    format gui slot 49 of {_P} with barrier named "&cMain Page" to run:
        mainshop(player)
    format gui slot 0 of {_P} with wheat named "" to run:
        wheat(player)
function mainshop(P: player):
    open chest with 6 rows named "          &c&m=====&aShop&c&m=====" to {_P}
    format gui slot 49 of {_P} with barrier named "&cClose" to close
    format gui slot 0 of {_P} with wheat named "&a&lCrops" to run:
        crops(player)
command /shop:
    trigger:
        mainshop(player)
[doublepost=1572919272][/doublepost]Ok, i think i got it working. Thank you shane! I appreciate it alot. :emoji_slight_smile:

Have a nice day.
 
Status
Not open for further replies.