Getting the last attacker

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

dudle

Active Member
Jan 31, 2017
135
0
16
44
Category: PvP

Suggested name: LastAttacker (or whatever you prefer, I don't mind any)

What I want: I want a short script that when a player dies because of anything, it would send the last attacker of the player (if it's set) a message like "You killed %victim's display name%" and it will send a message to the victim saying that they have been killed by that last attacker's display name and their hearts remaining. If the last attacker isn't set, it will just act as victim committed suicide. I tried to do this but couldn't manage to, so if someone can make this for me I'll appreciate it!

Ideas for commands: none

Ideas for permissions: none

When I'd like it by: Monday the 20th or Tuesday 21st, please.
 
There you go:

code_language.skript:
on death of player:

  attacker is a player
  send "<yellow>You have been killed by %attacker's display name% <light gray>(<light green>%attacker's health%<light red>❤<light gray>)<reset>." to victim
  send "<yellow>You've killed %vitim's display name%<reset>." to attacker
 
There you go:

code_language.skript:
on death of player:

  attacker is a player
  send "<yellow>You have been killed by %attacker's display name% <light gray>(<light green>%attacker's health%<light red>❤<light gray>)<reset>." to victim
  send "<yellow>You've killed %vitim's display name%<reset>." to attacker
i also made this but it won’t work. look what i want is so that for example if i die because of burning in lava, and i’ve been hit by someone before this death event happened, it would get that player that hit me and just send them the msg saying that they have killed me (even tho there weren’t the ones that made me die) if they’re on. does this make sense kinda??
 
code_language.skript:
on death of player:
 
  if {last-attacker::%victim%} is set:
    send "<yellow>You have been killed by %{last-attacker::%victim%}'s display name% <light gray>(<light green>%{last-attacker::%victim%}'s health%<light red>❤<light gray>)<reset>." to victim
    send "<yellow>You've killed %vitim's display name%<reset>." to {last-attacker::%victim%}

on damage of player:

  if attacker is a player:

    set {last-attacker::%victim%} to attacker
    wait 3 seconds
    clear {last-attacker::%victim%}
 
Last edited:
im pretty sure tuske has a %last attacker% expression
Well there's %last damage cause% and %last entity damage of player% from TuSKe, but it says that it can't understand that expression for some reason, even though i've got the plugin installed

code_language.skript:
on death of player:
 
  if {last-attacker::%victim%} is set:
    send "<yellow>You have been killed by %attacker's display name% <light gray>(<light green>%attacker's health%<light red>❤<light gray>)<reset>." to victim
    send "<yellow>You've killed %vitim's display name%<reset>." to {last-attacker::%victim%}

on damage of player:

  if attacker is a player:

    set {last-attacker::%victim%} to attacker
    wait 3 seconds
    clear {last-attacker::%victim%}
the display name of the attacker says <none>