> 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 %}
