Solved item name issue

  • Thread starter Deleted member 9590
  • Start date
  • 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 community!

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

Deleted member 9590

  1. Script Version: https://gist.github.com/AggerTV/1c18016963ed2e9b7f1b275db1fb1174
  2. Full Code: https://gist.github.com/AggerTV/4a9159b467646923177fe867835bd631

  3. no errors on reload:


So, my issue is, that I am converting my old skript from 1.12.2 to 1.16.5, and I can no longer use item ids in the variables list. Here is an example of how it would have been on my old 1.12.2 server
Code:
{vagtpris::338} = 80 #sugar

And in 1.16.5 you cannot use item ids, so this is how I have put it
Code:
{vagtpris::sugar_cane} = 80 #sugar

So what my code is, is a sell skript that check what items are in the menu, and then it removes those items and gives the player x amount of money.
But previously when I could use item ids instead of item names, I would check what items the player had put in the menu like this:
Code:
if inventory name of player's current inventory is "&cVagt Kiste":
        if player doesn't have permission "ag":
            set {_Money} to 0
            loop all items in event-inventory:
                if {vagtpris::%id of loop-item%} is set:
                    loop 64 times:
                        add {vagtpris::%id of loop-item%} to {_money}
                        remove 1 of loop-item from player's current inventory

                else:
                    add loop-item to {_items::*}
            loop all items in event-inventory:
                if loop-item isn't air:
                    if player can hold loop-item:
                        give loop-item to player
                    else:
                        drop loop-item at player's location
                    set loop-item to air
            if {_money} is greater than 0:
                add {_money} to player's balance
                send "&aDu tjente &c$%{_money}%&a på at sælge dine ting!"
where I used {vagtpris::%id of loop-item%} to check the price of the item.

But in 1.16.5 I obviously cannot do this, and I'm unsure how to do it.
I tried doing it like this
Code:
if name of player's current inventory is "&cVagt Kiste":
        if player doesn't have permission "ag":
            set {_money} to 0
            loop all items in event-inventory:
                if {vagtpris::%loop-item%} is set:
                    loop 64 times:
                        add {vagtpris::%loop-item%} to {_money}
                        remove 1 of loop-item from player's current inventory

                else:
                    add loop-item to {_items::*}
            loop all items in event-inventory:
                if loop-item isn't air:
                    if player can hold loop-item:
                        give loop-item to player
                    else:
                        drop loop-item at player's location
                    set loop-item to air
            if {_money} is greater than 0:
                add {_money} to player's balance
                send "{@p} &aDu tjente &c$%{_money}%&a på at sælge dine ting!"

but this doesn't work. I'm unsure if it's because the code is somehow incorrect, or if I'm setting the variable incorrectly.

If you need me to elaborate on something, please say so!
[doublepost=1616574700,1616519137][/doublepost]bump
 
Status
Not open for further replies.