# builderx.pl.ondamage

`builderx.pl.ondamage(` [**ᵖˡᵃʸᵉʳ**](https://wiki.facepunch.com/gmod/Player) attacker,   [**ᵖˡᵃʸᵉʳ**](https://wiki.facepunch.com/gmod/Player) victim,   [**ⁿᵘᵐᵇᵉʳ**](https://wiki.facepunch.com/gmod/number) damage`)`

## ▸ Parameters

&#x20;     ***`ply`**`    ``attacker`*\
&#x20;                         player object (player doing damage)

&#x20;     ***`ply`**`    ``victim`*\
&#x20;                         player object (player injured)

&#x20;     ***`int`**`    ``damage`*\
&#x20;                         returns total damage attacker has done in build mode

## ▸ Description

&#x20;      Runs when player in build mode deals damage to another player (or kills).

&#x20;      Will not run if block damage settings enabled because there won't be damage to report.

## ▸ Example

{% tabs %}
{% tab title="Example 1" %}

```lua
local function your_hook( attacker, victim, damage )

    // your custom hook function here

end
hook.Add( 'builderx.pl.ondamage', 'your_hook_id', your_hook )
```

{% endtab %}

{% tab title="Example 2" %}

```lua
hook.Add( 'builderx.pl.ondamage', 'your_hook_id', function( attacker, victim, damage )

    // your custom hook function here

end )
```

{% endtab %}

{% tab title="Example 3" %}

```lua
local function your_hook( attacker, victim, damage )
    print( attacker )
    print( victim )
    print( damage )
end
hook.Add( 'builderx.pl.ondamage', 'your_hook_id', your_hook )

-- print returns --

Player [1][player_name]
Player [3][Bot03]
19
```

{% endtab %}

{% tab title="Example 4" %}

```lua
local function your_hook( attacker, victim, damage )

    // your custom hook function here

end
rhook.new.rlib( 'builderx_mode_ondamage', your_hook )
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://builderx.rlib.io/developers/hooks/builderx_pl_ondamage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
