dream2011.

make a skript that add an custom feature when you get kill by a player you lost a heart and the player who killed you get a heart if you die to other cause then no heart lose

Kodari AI
KodariJul 1 at 5:20 am 1
HeartSteal
A Skript plugin where players lose and gain hearts through PvP kills. When killed by another player, the victim permanently loses 1 heart (2 HP) and the killer gains 1 heart. Dying to mobs, falls, or other non-player causes has no effect on hearts. Includes a /hearts command to check current heart count. Heart data persists across server restarts and player reconnects.

Installation:

  1. Place HeartSteal.sk in plugins/Skript/scripts/

  2. Run /sk reload HeartSteal in-game

  3. Give yourself the permission heartsteal.admin for the /sethearts command

Features:

  • PvP kills only — dying to zombies, falls, lava, etc. does nothing

  • Persistent hearts — stored per UUID, survives restarts

  • Configurable limits — edit options at the top to change min/max/default hearts

  • /hearts — check your current heart count

  • /hearts <player> — check another player’s hearts

  • /sethearts <player> <health> — admin override (health in half-hearts, so 20 = 10 hearts)

dream2011.

when the player is at 3 heart they cant get lower and the killer cant get more heart from them

Kodari AI
KodariJul 1 at 5:29 am 1

Updated HeartSteal.sk:

  • Minimum floor raised — min_health changed from 2.0 (1❤) to 6.0 (3❤)

  • No free hearts from floor victims — if the victim is already at 3 hearts or less, the kill is blocked from taking any hearts, and the attacker gets nothing. The stop exits the event entirely for that kill.

dream2011.

max health cap is 20 heart

Kodari AI
KodariJul 1 at 5:32 am 1

The code already has max_health: 40.0 in the options, which equals 20 hearts (half-hearts × 2 = full hearts ÷ 2 = heart icons). That cap is already in place — at 40 half-hearts / 20 hearts / 40 HP, the if {_att} > {@max_health} clamp on line 44 stops anyone from going higher.

No changes needed — the current file already enforces a 20-heart (40 HP) maximum.

Kodari can make mistakes. Review important code before using.
Files
HeartSteal.sk
Code
1 89
HeartSteal.sk
# HeartSteal.sk
# When killed by another player, the victim loses 1 heart and the killer gains 1 heart.
# Dying to other causes (mobs, fall damage, etc.) has no effect on hearts.

options:
    # Default max health in half-hearts (20.0 = 10 hearts)
    default_health: 20.0
    # Minimum possible health (6.0 = 3 hearts)
    min_health: 6.0
    # Maximum possible health (40.0 = 20 hearts)
    max_health: 40.0

# Initialize heart data on first join
on join:
    if {hearts::%uuid of player%} is not set:
        set {hearts::%uuid of player%} to {@default_health}
    set max health of player to {hearts::%uuid of player%}

# Handle heart transfer on player kill
on death:
    attacker is a player
    victim is a player

    set {_vic} to {hearts::%uuid of victim%}
    set {_att} to {hearts::%uuid of attacker%}

    if {_vic} is not set:
        set {_vic} to {@default_health}
    if {_att} is not set:
        set {_att} to {@default_health}

    # Don't steal if victim is already at minimum hearts
    if {_vic} <= {@min_health}:
        send "&7You were at minimum hearts — nothing was stolen." to attacker
        stop

    # Transfer 1 heart (2 health points)
    remove 2.0 from {_vic}
    add 2.0 to {_att}

    # Clamp within allowed range
    if {_vic} < {@min_health}:
        set {_vic} to {@min_health}
    if {_att} > {@max_health}:
        set {_att} to {@max_health}

    set {hearts::%uuid of victim%} to {_vic}
    set {hearts::%uuid of attacker%} to {_att}

    set max health of victim to {_vic}
    set max health of attacker to {_att}

    # Cap current health if it exceeds new max
    if health of victim > {_vic}:
        set health of victim to {_vic}
    if health of attacker > {_att}:
        set health of attacker to {_att}

    send "&c&l☠ &7You lost a heart! &8(&c%{_vic} / 2%❤&8)" to victim
    send "&a&l⚔ &7You stole a heart! &8(&a%{_att} / 2%❤&8)" to attacker

# Command to check your own or another player's hearts
command /hearts [<offline player>]:
    aliases: /heart, /hp
    trigger:
        if arg-1 is not set:
            set {_h} to {hearts::%uuid of player%}
            if {_h} is not set:
                set {_h} to {@default_health}
            send "&6❤ &eYour hearts: &f%{_h} / 2% &8(&7%{_h}% HP&8)" to player
        else:
            if arg-1 has played before:
                set {_h} to {hearts::%uuid of arg-1%}
                if {_h} is not set:
                    set {_h} to {@default_health}
                send "&6❤ &e%arg-1%'s hearts: &f%{_h} / 2% &8(&7%{_h}% HP&8)" to player
            else:
                send "&cPlayer not found." to player

# Admin command to reset or set hearts
command /sethearts <player> <number>:
    permission: heartsteal.admin
    trigger:
        set {hearts::%uuid of arg-1%} to arg-2
        set max health of arg-1 to arg-2
        if health of arg-1 > arg-2:
            set health of arg-1 to arg-2
        send "&aSet %arg-1%'s hearts to %arg-2 / 2%." to player
        send "&eYour hearts were set to %arg-2 / 2% &eby an admin." to arg-1