⚑exports

Overview

SL-Chat provides various exports for both client and server-side scripts. These allow you to integrate the chat system with your other resources.


Client Exports

Chat State

isChatActive

Check if chat input is currently active.

local isActive = exports['sl-chat']:isChatActive()

if isActive then
    -- Chat is open
end
Returns
Type
Description

isActive

boolean

true if chat is open


Messages

addMessage

Add a message to the chat.

Parameter
Type
Description

message

string/table

Message content or structured message


Suggestions

addSuggestion

Add a command suggestion.

Parameter
Type
Description

name

string

Command name (with /)

help

string

Command description

params

table

Parameter definitions


addSuggestions

Add multiple suggestions at once.


removeSuggestion

Remove a command suggestion.


3D Display

addDisplay

Add 3D text above a player's head.

Parameter
Type
Description

text

string

Text to display

serverId

number

Player's server ID

color

table

RGB color {r, g, b}

duration

number

Duration in milliseconds

background

table

Optional background color

displaySettings

table

Optional settings override

Returns
Type
Description

displayId

number

Unique ID for the display


removeDisplay

Remove a 3D display by ID.


Cursor

isCursorActive

Check if cursor is active in chat.


setCursorActive

Set cursor state.


toggleCursor

Toggle cursor on/off.


disableCursor

Force disable cursor.


Streamer Mode

isStreamerMode

Check if streamer mode is active.


setStreamerMode

Set streamer mode state.


Server Exports

SendTemplate

NEW! Send predefined template messages to players.

Parameter
Type
Description

templateType

string

Template name: SYSTEM, WELCOME, ERROR, SUCCESS, INFO, WARNING

playerId

number

Target player server ID

message

string

Message content

Examples:


Messages

addMessage

Send message to player(s).

Parameter
Type
Description

target

number

Player ID or -1 for all

message

string/table

Message content


Suggestions

addSuggestion

Add suggestion (server-side).


addSuggestions

Add multiple suggestions.


removeSuggestion

Remove suggestion.


Modes

registerMode

Register a chat mode/channel.

Parameter
Type
Description

name

string

Unique mode identifier

displayName

string

Display name in UI

color

string

Mode color (hex)

isChannel

boolean

Is this a channel

isGlobal

boolean

Is globally visible

seObject

string

ACE permission required

cb

function

Message callback


Hooks

registerMessageHook

Register a hook for all messages.

Hook Reference Methods:

Method
Description

hookRef.updateMessage(data)

Modify message properties

hookRef.cancel()

Cancel message

hookRef.setRouting(target)

Set message target

hookRef.setSeObject(object)

Set ACE permission filter


Logging

LogToDiscord

Send log to Discord webhook.


LogChatCommand

Log a chat command.


GetPlayerIdentifiersData

Get player's identifiers.


Events

Client Events

Event
Description

chat:addMessage

Add chat message

chat:addSuggestion

Add command suggestion

chat:addSuggestions

Add multiple suggestions

chat:removeSuggestion

Remove suggestion

chat:addMode

Add chat mode

chat:removeMode

Remove chat mode

chat:addTemplate

Add message template

chat:clear

Clear chat

w-chat:SendRPMessage

Send RP command message

w-chat:triggerDisplay

Trigger 3D text display

w-chat:chatClosed

Chat was closed

Server Events

Event
Description

chat:init

Player chat initialized

_chat:messageEntered

Player sent message

w-chat:server:log

Log to Discord

w-chat:server:logCommand

Log chat command


Usage Examples

Custom Notification System

Integration with Other Scripts

Custom 3D Text


Next Steps

Last updated