> For the complete documentation index, see [llms.txt](https://builderx.rlib.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://builderx.rlib.io/developers/hooks/builderx_mode_onswitch.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://builderx.rlib.io/developers/hooks/builderx_mode_onswitch.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
