Solved Get killer from crystal

  • 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.
Apr 22, 2020
18
1
3
24
I'm trying to get the killer from crystal pvp
code_language.skript:
on death of player:
    victim is player
    attacker is end crystal
    add 1 to {kills::%metadata value "playerWhoDetonated" of attacker parsed as player%}
    broadcast "&c%victim% &fwas BLOWN up by &c%metadata value "playerWhoDetonated" of attacker parsed as player%"

#And this is what sets the nbt data
on damage:
    if victim is end crystal:
        set metadata value "playerWhoDetonated" of victim to damager


#This is the error
Can't compare entity with heal reason

I know why you can't do
attacker is end crystal
but I don't know how to do it now
 
Since end crystal is a heal reason, you can't use it as attacker BUT you CAN use attacker and end crystal as text
Example: (should work hopefully)


Code:
on death of player:
    victim is player
    "%attacker%" contains "ender crystal"
    add 1 to {kills::%metadata value "playerWhoDetonated" of attacker parsed as player%}
    broadcast "&c%victim% &fwas BLOWN up by &c%metadata value "playerWhoDetonated" of attacker parsed as player%"
 
#And this is what sets the nbt data
on damage:
    if "%victim%" contains "ender crystal":
        set metadata value "playerWhoDetonated" of victim to damager
 
Since end crystal is a heal reason, you can't use it as attacker BUT you CAN use attacker and end crystal as text
Example: (should work hopefully)


Code:
on death of player:
    victim is player
    "%attacker%" contains "ender crystal"
    add 1 to {kills::%metadata value "playerWhoDetonated" of attacker parsed as player%}
    broadcast "&c%victim% &fwas BLOWN up by &c%metadata value "playerWhoDetonated" of attacker parsed as player%"
 
#And this is what sets the nbt data
on damage:
    if "%victim%" contains "ender crystal":
        set metadata value "playerWhoDetonated" of victim to damager

Thank you! This works, I didn't think of this.
 
Status
Not open for further replies.