> For the complete documentation index, see [llms.txt](https://docs.mosotoscripts.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mosotoscripts.com/scripts/mst_seatbelt/exports-and-events.md).

# Exports & Events

***

### Exports

<details>

<summary><code>HasSeatbelt</code></summary>

```lua
exports['mst_seatbelt']:HasSeatbelt()
```

The **HasSeatbelt** export allows you to check if the local player is currently wearing a seatbelt. This export returns the current seatbelt state.

**How to use?**

To check if the local player is wearing a seatbelt, use the following code:

```lua
-- Check if local player is wearing a seatbelt
local hasSeatbelt = exports['mst_seatbelt']:HasSeatbelt()
if hasSeatbelt then
    print("You are wearing a seatbelt")
else
    print("You are not wearing a seatbelt")
end
```

**Return value**:

* Returns `true` if the local player is wearing a seatbelt
* Returns `false` if the local player is not wearing a seatbelt

</details>

<details>

<summary><code>ToggleSeatbelt</code></summary>

```lua
exports['mst_seatbelt']:ToggleSeatbelt()
```

The **ToggleSeatbelt** export allows you to toggle the seatbelt state for the local player. This will fasten the seatbelt if it's unfastened, or unfasten it if it's fastened.

**How to use?**

To toggle the local player's seatbelt, use the following code:

```lua
-- Toggle local player's seatbelt
local success = exports['mst_seatbelt']:ToggleSeatbelt()
if success then
    print("Seatbelt toggled successfully")
else
    print("Failed to toggle seatbelt (not in vehicle, vehicle excluded, or menu is open)")
end
```

**Return value**:

* Returns `true` if the seatbelt was toggled successfully
* Returns `false` if the player is not in a vehicle, the vehicle is excluded, or the pause menu is active

</details>

<details>

<summary><code>SetSeatbelt</code></summary>

```lua
exports['mst_seatbelt']:SetSeatbelt(state)
```

The **SetSeatbelt** export allows you to set the seatbelt state for the local player to a specific value (fastened or unfastened).

**How to use?**

To set the local player's seatbelt state, use the following code:

```lua
-- Fasten the seatbelt
local success = exports['mst_seatbelt']:SetSeatbelt(true)
if success then
    print("Seatbelt fastened")
else
    print("Failed to fasten seatbelt")
end

-- Unfasten the seatbelt
local success = exports['mst_seatbelt']:SetSeatbelt(false)
if success then
    print("Seatbelt unfastened")
else
    print("Failed to unfasten seatbelt")
end
```

**Parameters:**

* `state` (boolean): The desired seatbelt state. `true` to fasten, `false` to unfasten.

**Return value**:

* Returns `true` if the seatbelt state was set successfully
* Returns `false` if the player is not in a vehicle, the vehicle is excluded, the pause menu is active, the player is dead, or the seatbelt animation is still playing

</details>


---

# 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://docs.mosotoscripts.com/scripts/mst_seatbelt/exports-and-events.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.
