All resources

rsg-chat – Docs (v3.2.0)#

Contents#

  1. Files
  2. How it works
  3. Configuration
  4. Exports, events and commands
  5. Database
  6. Security
  7. Server owner how-tos
  8. Troubleshooting

1. Files#

FilePurpose
fxmanifest.luaManifest; depends on rsg-core, oxmysql
shared/config.luaPermissions, limits, default layout, seed channels
client/cl_chat.luaChat UI bridge, channel sync, settings, admin panel
server/main.luaChannels, message routing, PSA, admin callbacks
server/versionchecker.luaGitHub version check
html/NUI (Vue, styles, dropdowns, suggestions)
install.sqlOptional manual table
locales/*.jsonen, de, el, es, fr, ja, nl, pl, pt-br, ro, ru

2. How it works#

  • Replaces the default chat with channels managed in game by admins (/chatadmin), stored in the database.
  • Each channel has a colour, optional prefix, range (global, local, regional, group), optional permission lock, its own length limit and a slash command (e.g. /ooc).
  • group channels are limited to jobs or gangs, with an optional "on duty" rule.
  • Changes sync to players at once. Players only see channels they can use, and the list updates on job or gang change.
  • Players switch channels with the tabs, Tab / Shift+Tab or /channel <id>.
  • Per-player window settings (position, size, font, opacity, timestamps, history, auto-hide) are stored on the player's PC.
  • Messages show the character's first and last name.

3. Configuration#

shared/config.lua:

OptionDefaultMeaning
AdminPermission'admin'Permission for /chatadmin
PSAPermission'admin'Permission to send a server PSA
MessageCooldown1000ms between messages per player
HardMaxLength512Absolute message cap
DefaultChannel'ooc'Starting channel
MaxHistoryCap250Highest history value a player can pick
DistanceLimits{2, 5000}Distance range the admin panel accepts (m)
PermissionLevelslistLevels offered in the admin panel
DefaultSettingstableDefault window layout
ChannelslistSeed channels, only used when the table is empty

Channel fields: id, label, command, prefix, showPrefix, color, range, distance, maxLength, plus jobs, gangs, permission, on-duty option.

4. Exports, events and commands#

NameSideNotes
SendChannelMessage(channelId, author, text)server exportexports['rsg-chat']:SendChannelMessage('staff', 'Server', 'Restart in 5 minutes')
GetChannels()server exportChannel list
rsg-chat:server:sendserver event(channelId, message)
rsg-chat:server:requestChannelsserver eventRequest the channel list
chat:server:ServerPSAserver event(message) server-wide announcement (needs PSAPermission from a client)
rsg-chat:server:adminGetChannels and other admin…callbacksAdmin panel actions, permission-checked
rsg-chat:client:syncChannelsclient event(list, defaultId)
rsg-chat:client:channelMessageclient event(payload)
rsg-chat:client:openAdminclient eventOpen the admin panel
CommandWhoWhat
/chatadminAdminPermissionChannel manager
/channel <id>everyoneSwitch channel
/chatsettingseveryoneWindow settings
/togglechateveryoneHide/show the chat box
/clearchateveryoneClear your own chat
one per channelper channele.g. /ooc, /l, /trade, /staff

5. Database#

CREATE TABLE IF NOT EXISTS `rsg_chat_channels` (
  `id` VARCHAR(32) NOT NULL,
  `data` LONGTEXT NOT NULL,
  `sort` INT NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`)
);

Created on first start. The seed Config.Channels are only imported while the table is empty.

6. Security#

The server works out the sender, checks channel access and range, trims messages, caps length and rate-limits. Clients cannot fake an author or post in channels they can't use. Admin callbacks are permission-checked. PSAs from a client need PSAPermission.

7. How-tos#

  • Add a staff channel: /chatadmin → new channel → set permission to mod or admin.
  • Announce from a script: exports['rsg-chat']:SendChannelMessage('ooc', 'Server', 'Welcome!').
  • Reset a player's layout: they use the Reset layout button in chat settings.

8. Troubleshooting#

ProblemFix
Channel missingPlayer lacks the job, gang or permission
Config channel edits ignoredSeed channels only apply to an empty table; use /chatadmin
Chat hiddenPlayer ran /togglechat
Message rejectedOver the channel limit or MessageCooldown

Support the Project : https://rexshack.tebex.store/

<!-- BEGIN AUTO-REFERENCE (generated from the code; re-run the generator instead of editing by hand) -->

Technical reference#

Generated from the source of rsg-chat 3.2.0. Names, arguments and defaults below are read straight from the code.

Dependencies#

rsg-core, oxmysql

Database#

Tables: rsg_chat_channels.

Tables are created automatically on start while Config.AutoDatabase = true (default). Nothing is ever dropped or overwritten. For a manual install set Config.AutoDatabase = false and import install.sql once.

-- shared/config.lua
Config.AutoDatabase = true -- false = import the SQL file yourself

Configuration#

OptionDefaultNotes
Config.AutoDatabasetruebuild the database tables automatically on start (set false and import the SQL file for a manual install)
Config.AdminPermission'admin'rsg-core permission for /chatadmin (channel manager)
Config.PSAPermission'admin'rsg-core permission needed to send a SERVER PSA
Config.MessageCooldown1000ms between chat messages per player (all channels)
Config.HardMaxLength512absolute cap; a channel's own limit can't go above this
Config.DefaultChannel'ooc'channel players start on (falls back to the first one they can use)
Config.MaxHistoryCap250highest "message history" value players can pick
Config.DistanceLimits{ min = 2, max = 5000 }Distance limits the admin panel will accept (metres)
Config.PermissionLevels{ '', 'helper', 'mod', 'admin', 'headadmin', 'developer', 'god' }Permission levels offered in the admin panel dropdown ('' = everyone)
Config.DefaultSettingstable
Config.Channelstable

Exports#

Server

ExportArgumentsFile
SendChannelMessagechannelId, author, textserver/main.lua
GetChannels``server/main.lua
-- example
local result = exports['rsg-chat']:SendChannelMessage(channelId, author, text)

Callbacks#

CallbackSideArgumentsFile
rsg-chat:server:adminGetChannelsserversrc, cbserver/main.lua
-- client side
RSGCore.Functions.TriggerCallback('rsg-chat:server:adminGetChannels', function(result)
    -- use result
end)

Events#

Server events can be fired by any client, so every handler re-validates the player, the arguments and any permission, distance or cooldown on the server. Never add a reward to a handler without those checks.

EventSideArgumentsFile
chatMessageclient``client/cl_chat.lua
chat:addTemplateclient``client/cl_chat.lua
chat:addMessageclient``client/cl_chat.lua
chat:addSuggestionclient``client/cl_chat.lua
chat:addSuggestionsclient``client/cl_chat.lua
chat:removeSuggestionclient``client/cl_chat.lua
chat:clearclient``client/cl_chat.lua
__cfx_internal:serverPrintclient``client/cl_chat.lua
rsg-chat:client:syncChannelsclientlist, defaultIdclient/cl_chat.lua
rsg-chat:client:channelMessageclientpayloadclient/cl_chat.lua
RSGCore:Client:OnPlayerLoadedclient``client/cl_chat.lua
RSGCore:Client:OnJobUpdateclient``client/cl_chat.lua
RSGCore:Client:OnGangUpdateclient``client/cl_chat.lua
rsg-chat:client:openAdminclient``client/cl_chat.lua
rsg-chat:server:sendserverchannelId, messageserver/main.lua
_chat:messageEnteredserver_, _, messageserver/main.lua
rsg-chat:server:requestChannelsserver``server/main.lua
__cfx_internal:commandFallbackservercommandserver/main.lua
chat:server:ServerPSAservermessageserver/main.lua
-- from a client script
TriggerServerEvent('rsg-chat:server:send', channelId, message)
-- from a server script
TriggerClientEvent('chatMessage', source)

Commands#

CommandNotesFile
/chatsettingsclient/cl_chat.lua
/togglechatclient/cl_chat.lua
/channelclient/cl_chat.lua
/chatadminlocale('help_chatadmin')server/main.lua
/clearchatserver/main.lua

Locales#

Language files in locales/: de, el, en, es, fr, ja, nl, pl, pt-br, ro, ru. Set the language with setr rsg:locale "en".

<!-- END AUTO-REFERENCE -->