Item variable help

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

Eryx

Member
Mar 4, 2025
1
0
1
15
I am looking for some help making a weapons system with this script, I have reduced it to everything I believe would be helpful for this, The {ammo} variable is public so it would be the same on all items, I want each item to have it's own amount of ammo it can contain, any suggestions as to how?
Code:
on load:
    set {zip-lore::*} to "&59mm - 2 DMG" and "The ol reliable" and "can hold 6 ammo" and "%randomDataForLoreUnstack()%"
on left click:
    "%player's held item's lore%" contains "gun"
    if lore of player's tool contains "9mm - 2 DMG gun":
        if {ammo} is greater than 0:
            fire(event-player, 17, 2)
            set {ammo} to {ammo} -1
            send action bar ">> %{ammo}%" to player
    else if lore of player's tool contains "automatic":
        if {ammo} is greater than 0:
            loop 4 times:
                fire(event-player, 17, 2)
                set {ammo} to {ammo} -1
                send action bar ">> %{ammo}%" to player
                wait 1 tick
on right click:
    if lore of player's tool contains "9mm - 2 DMG":
        if player has 6 gold nugget with lore "handgun ammo":
            set {_rmv} to 6 - {ammo}
            loop {_rmv} times:
                remove 1 gold nugget with lore "handgun ammo" from player
            set {ammo} to 6
            send action bar ">> %{ammo}%" to player
            play sound "mob.blaze.hit" with volume 1 and pitch 1.5 to player
    permission: skript.comptech.cheats
    trigger:
        if arg-1 is "zip":
            give player magma cream named "&6Zip Gun" with lore {zip-lore::*}
            give player gold nugget named "&69mm ammo" with lore "handgun ammo"
            set {ammo} to 6
 
make a list like
Code:
set {ammoAmount::%{_itemName}%} to {ammo} #easy way to retrieve ammo by item name