# builderx.mode.onswitch

`builderx.mode.onswitch(` [**ᵖˡᵃʸᵉʳ**](https://wiki.facepunch.com/gmod/Player) pl,   [**ᵇᵒᵒˡ**](https://wiki.facepunch.com/gmod/boolean) bIsBuild,   [**ᵇᵒᵒˡ**](https://wiki.facepunch.com/gmod/boolean) bIsForced,   [**ᵇᵒᵒˡ**](https://wiki.facepunch.com/gmod/boolean) bHalo,   [**ᵇᵒᵒˡ**](https://wiki.facepunch.com/gmod/boolean) bHud`)`

## ▸ Parameters

&#x20;     ***`ply`**`    ``pl`*\
&#x20;                         player object

&#x20;     ***`bool`**`   ``bIsBuild`*\
&#x20;                         returns **true** if player switching to **build mode**; false for pvp mode

&#x20;     ***`bool`**`   ``bIsForced`*\
&#x20;                         returns **true** if player forced to switch by admin command (ulx, sam, etc)

&#x20;    ***`bool`**`   ``bHalo`*\
&#x20;                         returns **true** if halo enabled on player

&#x20;    ***`bool`**`   ``bHud`*\
&#x20;                         returns **true** if player has head hud enabled

## ▸ Description

&#x20;      Runs when player switches modes

## ▸ Example

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

```lua
local function your_hook( pl, bIsBuild, bIsForced, bHalo, bHud )

    // your custom hook function here

end
hook.Add( 'builderx.mode.onswitch', 'your_hook_id', your_hook )
```

{% endtab %}

{% tab title="Example 2" %}

```lua
hook.Add( 'builderx.mode.onswitch', 'your_hook_id', function( pl, bIsBuild, bIsForced, bHalo, bHud )

    // your custom hook function here

end )
```

{% endtab %}

{% tab title="Example 3" %}

```lua
local function your_hook( pl, bIsBuild, bIsForced, bHalo, bHud )

    // your custom hook function here

end
rhook.new.rlib( 'builderx_mode_onswitch', 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_mode_onswitch.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.
