having trouble with metadata...

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

Smore

Member
Dec 22, 2019
2
0
1
23
  • Skript Version: Skript 2.4
    Skript Author: Bensku
    Minecraft Version: 1.15
    ---
    Full Code:
    Code:
    on right click:
        if player is holding 1 red carpet named ".":
            set the item's name to "0"
            set {reload.%player%} to 0
        else if player is holding 1 red carpet named "0":
            if player has 1 pumpkin seeds:
                if {reload.%player%} is 0:   
                    set {reload.%player%} to 1
                    set the item's name to "reloading....."
                    wait 10 ticks
                    set the item's name to "reloading...."
                    wait 10 ticks
                    set the item's name to "reloading..."
                    wait 10 ticks
                    set the item's name to "reloading.."
                    wait 10 ticks
                    set the item's name to "reloading."
                    wait 4 ticks
                    set the item's name to "30"
                    remove 1 pumpkin seeds from the player's inventory
                    set metadata value "Ammo" of item to "30"
                    wait 1 tick
                    set {reload.%player%} to 0
                else if {reload.%player%} is 1:
                    play sound "block.anvil.place" with volume 5 at player
            else if player does not have pumpkin seeds:
                play sound "block.lever.click" with volume 3 at player
        else if player is holding 1 red carpet:
            if {reload.%player%} is 0:
                if metadata value "Ammo" of event-item is not "0":
                    play sound "entity.firework_rocket.blast" with volume 5 and pitch 0.3 at player
                    make the player shoot a snowball at speed 10 forward
                    set {_ammo} to metadata value "Ammo" of item
                    remove 1 from {_ammo}
                    set metadata value "Ammo" of item to "%{_ammo}%"
                    set the item's name to "%{_ammo}%"
    
    on shoot:
        if shooter is a player:
            if shooter is holding 1 red carpet:
                set metadata value "Damage" of projectile to "5"
    
    on damage:
        attacker is a player:
            set {_damage} to metadata value "Damage" of projectile
            set damage to {_damage} parsed as an integer

    Errors on Reload: none


    Console Errors: none

    Other Useful Info:
  • what i'm trying to do is set the item's name to the metadata value "Ammo"

    Addons using:
    Skellett 1.9.8, SkQuery 4.1.2

    Troubleshooting:

    Have you tried searching the docs? Yes
    Have you tried searching the forums? Yes
    What other methods have you tried to fix it? I have done just about everything under the sun my low IQ brain can think of.
 
it's because you are trying to remove a number from text, don't set metadata to "30", set it to 30, without ""

also I have never thought that items can hold metadata, maybe a new version feature

some extra tips:
1. use {variable::%uuid of player%} format
2. use loops instead of repetitive wait 10 ticks and message

you can shorten this:
Code:
[LIST=1]
[*]                set {_ammo} to metadata value "Ammo" of item
[*]                remove 1 from {_ammo}
[*]                set metadata value "Ammo" of item to "%{_ammo}%"
[/LIST]
into:
Code:
[LIST=1]
[*]                set {_ammo} to metadata value "Ammo" of item
[*]                set metadata value "Ammo" of item to {_ammo}-1

[/LIST]
 
Thx mate, i was banging my head against a wall (almost literally) trying to figure it out.
 
Status
Not open for further replies.