Exports

There are 17 exports included with the script (all are client-side).

IsSitting

Returns if the local player is sitting.

exports.sit:IsSitting()

Example

---@return boolean isSitting
local isSitting = exports.sit:IsSitting()
print("isSitting:", isSitting)

IsLaying

Returns if the local player is laying down.

exports.sit:IsLaying()

Example

---@return boolean isLaying
local isLaying = exports.sit:IsLaying()
print("isLaying:", isLaying)

IsSittingOrLaying

Returns if the local player is sitting or laying.

exports.sit:IsSittingOrLaying()

Example

---@return boolean isSittingOrLaying
local isSittingOrLaying = exports.sit:IsSittingOrLaying()
print("isSittingOrLaying:", isSittingOrLaying)

IsNearSeat

Returns if the local player is closer than Config.MaxInteractionDist to a seat.

exports.sit:IsNearSeat()

Example

---@return boolean isNearSeat
local isNearSeat = exports.sit:IsNearSeat()
print("isNearSeat:", isNearSeat)

IsNearBed

Returns if the local player is closer than Config.MaxInteractionDist to a bed.

exports.sit:IsNearBed()

Example

---@return boolean isNearBed
local isNearBed = exports.sit:IsNearBed()
print("isNearBed:", isNearBed)

GetClosestSeat

Returns the closest seat to the player.

exports.sit:GetClosestSeat()

Example

---@return boolean found if any position was found or not
---@return table closest table containing the data about the closest seat
local found, closest = exports.sit:GetClosestSeat()
if found then
    -- print(json.encode(closest, {indent=true}))
    print("type:", closest.type) -- "sit"
    print("entity:", closest.entity) -- number (0 if poly)
    print("coords:", closest.coords) -- coords, vector3
    print("distance:", closest.distance) -- distance, number
    print("name:", closest.name) -- Poly name (if applicable)
    print("group:", closest.group) -- Poly group
else
    print("No seat was found!")
end

GetClosestBed

Returns the closest bed to the player.

exports.sit:GetClosestBed()

Example

---@return boolean found if any position was found or not
---@return table closest table containing the data about the closest bed
local found, closest = exports.sit:GetClosestBed()
if found then
    -- print(json.encode(closest, {indent=true}))
    print("type:", closest.type) -- "sit"
    print("entity:", closest.entity) -- number (0 if poly)
    print("coords:", closest.coords) -- coords, vector3
    print("distance:", closest.distance) -- distance, number
    print("name:", closest.name) -- Poly name (if applicable)
    print("group:", closest.group) -- Poly group
else
    print("No seat was found!")
end

SitOnClosestSeat

Makes the local player sit on the closest seat.

exports.sit:SitOnClosestSeat()

LayOnClosestBed

Makes the local player lay down on the closest bed.

exports.sit:LayOnClosestBed()

StopCurrentAction

Makes the local player get up if they are sitting or laying down.

exports.sit:StopCurrentAction()

Example

if exports.sit:IsSitting() or exports.sit:IsLaying() then
    exports.sit:StopCurrentAction()
end

DisableSitting

Disables sitting. If reason isn't specified it will be handled as 'default' internally.

exports.sit:DisableSitting(state, reason)

Example

---@param boolean state
---@param string reason
exports.sit:DisableSitting(true, 'dead')

DisableLaying

Disables laying. If reason isn't specified it will be handled as 'default' internally.

exports.sit:DisableLaying(state, reason)

Example

---@param boolean state
---@param string reason
exports.sit:DisableLaying(true, 'dead')

DisableSittingAndLaying

Disables sitting and laying. If reason isn't specified it will be handled as 'default' internally.

exports.sit:DisableSittingAndLaying(state, reason)

Example

---@param boolean state
---@param string reason
exports.sit:DisableSittingAndLaying(true, 'dead')

IsSittingDisabled

Returns if sitting is disabled as the first return value, and the reason (if applicable) as the second value.

exports.sit:IsSittingDisabled()

Example

---@return boolean isDisabled
---@return table reasons
local isDisabled, reasons = exports.sit:IsSittingDisabled()
print(isDisabled, json.encode(reasons, {indent=true}))

IsLayingDisabled

Returns if laying is disabled as the first return value, and the reason (if applicable) as the second value.

exports.sit:IsLayingDisabled()

Example

---@return boolean isDisabled
---@return table reasons
local isDisabled, reasons = exports.sit:IsLayingDisabled()
print(isDisabled, json.encode(reasons, {indent=true}))

GetSitDisableReasons

Returns the reasons that sitting is disabled, returns an empty table if there are no reasons.

exports.sit:GetSitDisableReasons()

Example

---@return table reasons
local reasons = exports.sit:GetSitDisableReasons()
print(json.encode(reasons, {indent = true}))

GetLayDisableReasons

Returns the reasons that laying is disabled, returns an empty table if there are no reasons.

exports.sit:GetLayDisableReasons()

Example

---@return table reasons
local reasons = exports.sit:GetLayDisableReasons()
print(json.encode(reasons, {indent = true}))

Last updated