Buyshop

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

ZuRiKan

Member
Mar 16, 2023
3
0
1
32
Hello,

this is my first post. I've been scripting for a few months now and I have to say I've learned a lot. However, I still have a lot to look up.

I am currently writing a purchase shop and have the following problem.

It actually runs quite well in the functions I've written. BUT custom items (renames, lores, enchantments) will also be affected. These should not be counted or removed. One function is buy per stack and the other function is buy inventory. I hope you can help me.

Code:
function takeitem_l(i: item, m: number, c: number, p: player):
    set {_item} to {_i}
    set {_cost} to {_c}
    set {_maxstack} to {_m}
    if {_item} is not air:
        if {_cost} > 0:
            if {_p} has {_maxstack} of {_item}:
                remove {_maxstack} of {_item} from {_p}'s inventory
                set {_money} to {_cost}
                execute console command "eco give %{_p}% %{_money}%"
            else:
                message "Du hast nicht genügend Items" to {_p}

function takeitem_r(i: item, m: number, c: number, p: player):
    set {_item} to {_i}
    set {_cost} to {_c}
    set {_maxstack} to {_m}
    if {_item} is not air:
        if {_cost} > 0:
            set {_amount} to amount of {_item} in {_p}'s inventory
            if {_amount} > 0:
                set {_stacks} to floor({_amount}/{_maxstack})
                set {_amountr} to {_stacks} * {_maxstack}
                set {_money} to {_cost} * {_stacks}
                remove {_amountr} of {_item} from {_p}'s inventory
                execute console command "eco give %{_p}% %{_money}%"
            else:
                message "Du hast nicht genügend Items" to {_p}
 
Status
Not open for further replies.