How to make it so I can activate right click with multiple items?

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

Ravanox

Member
Dec 30, 2024
3
1
3
24
The problem I'm having is when I right click with the hearts and revive beacon, if I am holding more than 1 of them it just doesn't give me a heart or send me the revive message. How do I make it so you can redeem hearts even if there are multiple of them and redeem revive beacons even if there are multiple of them? My code is below. Can someone fix the code and give me tips on how you fixed it so I don't make the same mistake again?

Code:
# Define heart
on skript load:
    set {heart} to white dye with name "&cHeart"


# Default amount of hearts set
on first join:
    set {heartCount::%uuid of player%} to 20
    set {reviverActive::%uuid of player%} to false
  
# Set heart amount
every 1 tick:
    loop all players:
        if loop-player is a player:
            set the maximum health of the loop-player to {heartCount::%uuid of loop-player%}


# Lifesteal system
on death:
    if all:
        victim is a player
        attacker is a player
    then:
        set {heartCount::%uuid of victim%} to {heartCount::%uuid of victim%} - 1
        set {heartCount::%uuid of attacker%} to {heartCount::%uuid of attacker%} + 1
      
# Natural death
on death:
    if all:
        victim is a player
        attacker is not a player
    then:
        set {heartCount::%uuid of victim%} to {heartCount::%uuid of victim%} - 1
        drop 1 of white dye with name "&cHeart" at location of victim
      
# Max amount of hearts
every 1 tick:
    loop all players:
        if {heartCount::%uuid of loop-player%} > 20:
            set {heartCount::%uuid of loop-player%} to 20
            send "&cYou can only have 20 hearts!" to loop-player
            give or drop a white dye with name "&cHeart" to loop-player
          
# Death-ban
every 1 tick:
    loop all players:
        if {heartCount::%uuid of loop-player%} <= 0:
            ban loop-player due to "&c You have reached 0 hearts!"
          
# Revive pt. 1
on right click:
    if player is holding beacon with name "&bRevive Beacon":
        cancel event
        send "&aYou can now revive a player! Do /revive [username] to revive them!" to player
        send "&a(If you make a spelling error and lose your revive, talk to an admin)." to player
        set {reviverActive::%uuid of player%} to true


# Revive pt. 2
command /revive <text>:
    trigger:
        if {reviverActive::%uuid of player%} = true:
            unban arg-1
            set {reviverActive::%uuid of player%} to false
            remove 1 beacon with name "&bRevive Beacon" from player
            send "&c%arg-1% has been unbanned from the server!"
        else:
            send "&cYou cannot revive a player!" to player
          
# Heart item
on right click:
    if player is holding white dye with name "&cHeart":
        set {heartCount::%uuid of player%} to {heartCount::%uuid of player%} + 1
        remove 1 white dye with name "&cHeart" from player


          
# Withdraw
command /withdraw [<number>]:
    trigger:
        if {heartCount::%uuid of player%} <= 1:
            send "&cYou cannot withdraw a heart!" to player
        else:
            set {_withdrawal} to arg-1
            set {heartCount::%uuid of player%} to {heartCount::%uuid of player%} - {_withdrawal}
            give {_withdrawal} of white dye with name "&cHeart" to player
            send "&cYou now have %{heartCount::%uuid of player%}% hearts!" to player
          
# Give revive beacon and heart
command /give.revive:
    trigger:
        if player is op:
            give player 1 beacon with name "&bRevive Beacon"
        else:
            send "&cYou cannot do this command!" to player
          
command /give.heart:
    trigger:
        if player is op:
            give player 1 white dye with name "&cHeart"
        else:
            send "&cYou cannot do this command!" to player
          
# Make sure nobody's hearts are not defined
every 1 tick:
    loop all players:
        {heartCount::%uuid of loop-player%} is not set:
            set {heartCount::%uuid of loop-player%} to 20
 
The problem I'm having is when I right click with the hearts and revive beacon, if I am holding more than 1 of them it just doesn't give me a heart or send me the revive message. How do I make it so you can redeem hearts even if there are multiple of them and redeem revive beacons even if there are multiple of them? My code is below. Can someone fix the code and give me tips on how you fixed it so I don't make the same mistake again?

Code:
# Define heart
on skript load:
    set {heart} to white dye with name "&cHeart"


# Default amount of hearts set
on first join:
    set {heartCount::%uuid of player%} to 20
    set {reviverActive::%uuid of player%} to false
 
# Set heart amount
every 1 tick:
    loop all players:
        if loop-player is a player:
            set the maximum health of the loop-player to {heartCount::%uuid of loop-player%}


# Lifesteal system
on death:
    if all:
        victim is a player
        attacker is a player
    then:
        set {heartCount::%uuid of victim%} to {heartCount::%uuid of victim%} - 1
        set {heartCount::%uuid of attacker%} to {heartCount::%uuid of attacker%} + 1
     
# Natural death
on death:
    if all:
        victim is a player
        attacker is not a player
    then:
        set {heartCount::%uuid of victim%} to {heartCount::%uuid of victim%} - 1
        drop 1 of white dye with name "&cHeart" at location of victim
     
# Max amount of hearts
every 1 tick:
    loop all players:
        if {heartCount::%uuid of loop-player%} > 20:
            set {heartCount::%uuid of loop-player%} to 20
            send "&cYou can only have 20 hearts!" to loop-player
            give or drop a white dye with name "&cHeart" to loop-player
         
# Death-ban
every 1 tick:
    loop all players:
        if {heartCount::%uuid of loop-player%} <= 0:
            ban loop-player due to "&c You have reached 0 hearts!"
         
# Revive pt. 1
on right click:
    if player is holding beacon with name "&bRevive Beacon":
        cancel event
        send "&aYou can now revive a player! Do /revive [username] to revive them!" to player
        send "&a(If you make a spelling error and lose your revive, talk to an admin)." to player
        set {reviverActive::%uuid of player%} to true


# Revive pt. 2
command /revive <text>:
    trigger:
        if {reviverActive::%uuid of player%} = true:
            unban arg-1
            set {reviverActive::%uuid of player%} to false
            remove 1 beacon with name "&bRevive Beacon" from player
            send "&c%arg-1% has been unbanned from the server!"
        else:
            send "&cYou cannot revive a player!" to player
         
# Heart item
on right click:
    if player is holding white dye with name "&cHeart":
        set {heartCount::%uuid of player%} to {heartCount::%uuid of player%} + 1
        remove 1 white dye with name "&cHeart" from player


         
# Withdraw
command /withdraw [<number>]:
    trigger:
        if {heartCount::%uuid of player%} <= 1:
            send "&cYou cannot withdraw a heart!" to player
        else:
            set {_withdrawal} to arg-1
            set {heartCount::%uuid of player%} to {heartCount::%uuid of player%} - {_withdrawal}
            give {_withdrawal} of white dye with name "&cHeart" to player
            send "&cYou now have %{heartCount::%uuid of player%}% hearts!" to player
         
# Give revive beacon and heart
command /give.revive:
    trigger:
        if player is op:
            give player 1 beacon with name "&bRevive Beacon"
        else:
            send "&cYou cannot do this command!" to player
         
command /give.heart:
    trigger:
        if player is op:
            give player 1 white dye with name "&cHeart"
        else:
            send "&cYou cannot do this command!" to player
         
# Make sure nobody's hearts are not defined
every 1 tick:
    loop all players:
        {heartCount::%uuid of loop-player%} is not set:
            set {heartCount::%uuid of loop-player%} to 20
A fix would be just checking the name of the item instead of the type and name. Could be wrong, but when you put white dye with name "&6Example"; it might think you only are referring to one.