Exports & Events

This section contains all the exports provided by the script. For best results, make changes with someone knowledgeable in Lua to prevent errors.


Exports

chevron-rightHasSeatbelthashtag
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:

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

chevron-rightToggleSeatbelthashtag
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:

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

chevron-rightSetSeatbelthashtag
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:

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

Last updated