On Attempt Attack (Event) — Skript

Addon: Skript · Category: Event · Since: 2.15

Syntax

[on] attack attempt

Description

Called when a player attempts to attack an entity. The event will be cancelled as soon as it is fired for non-living entities. Cancelling this event will prevent the attack and any sounds from being played when attacking. Any damage events will not be called if this is cancelled.

Event Values

  • event-player
  • event-world

Examples

on attack attempt:
    if event is cancelled:
        broadcast "%attacker% failed to attack %victim%!"
    else:
        broadcast "%attacker% damaged %victim%!"
on attempt to attack an animal:
    cancel event
on attempting to attack an entity:
    if victim is a creeper:
        cancel event
on attempt to attack a zombie or creeper:
    attacker isn't holding a diamond sword
    cancel event

View source