Skip to content
GAMPEONCreate
New project
Preview: this works today, but details can still change.

Text chat

GAMPEON ships a chat resource that works like the one in FiveM. Players press T in the game, type and press Enter. Text goes to everyone on the server, and text that starts with / runs a command.

server.cfg
ensure chat
set chat_maxLength 256 # optional, 1 to 512 characters
  • T opens the chat, Enter sends, Escape closes.
  • New lines appear at the top left and fade out after 10 seconds.
  • When you type /, the chat shows matching commands with their help text.
  • Colour codes like ^1 and HTML from FiveM templates are removed, because the chat shows plain text.
  1. The game sends what the player typed to the server as _chat:messageEntered.
  2. The server trims the text to chat_maxLength and allows 5 messages per player in 10 seconds.
  3. It fires the local server event chatMessage with source, the player’s name and the text.
  4. If no handler called CancelEvent(), it sends the line to every player and prints it in the server console.

The name always comes from the player’s GAMPEON account. Players cannot send messages under another name.

Server scripts can filter or replace messages:

server.lua
AddEventHandler('chatMessage', function(source, name, message)
if message:lower():find('free gampeons') then
CancelEvent()
TriggerClientEvent('chat:addMessage', source, {
color = { 255, 140, 0 },
args = { 'Server', 'Please do not post scams.' },
})
end
end)

/name arguments runs the command name:

  1. Commands that client scripts registered with RegisterCommand run first, in the player’s game.
  2. Any other command goes to the server and runs there as the player, with the player’s permissions. A restricted command the player may not use does nothing, and the game log shows Access denied for command 'name'.

When a player joins, the chat lists the server’s commands that this player may use as suggestions. Add help text or client commands with chat:addSuggestion.

On servers whose client scripts the game blocks (see Which servers may send client scripts), only /commands work.

Send these to players from server scripts with TriggerClientEvent, or fire them in client scripts with TriggerEvent.

Event Arguments Effect
chat:addMessage { args = { author, text }, color = { r, g, b } } Adds a line. A plain string works too.
chat:addMessage { template = '{0} paid {1}', args = { 'Ann', '20' } } Adds a line built from the template.
chatMessage author, { r, g, b }, text Adds a line, the older FiveM form.
chat:addSuggestion '/name', 'help' Shows the command with help text while typing /.
chat:addSuggestions { { name = '/a', help = '…' }, … } Several suggestions at once.
chat:removeSuggestion '/name' Removes a suggestion.
chat:clear Clears the chat.
server.lua
RegisterCommand('announce', function(source, args)
TriggerClientEvent('chat:addMessage', -1, {
color = { 255, 200, 0 },
args = { 'Announcement', table.concat(args, ' ') },
})
end, true)

chat:addTemplate exists so FiveM resources do not fail, but it does nothing: the chat has no web interface.

Games built on GAMPEON can draw their own chat instead of the built-in window. The chat resource stays the same; only the window changes.

  • Turn the built-in window off with BuiltInChat=False under [GampeonScripting] in DefaultGame.ini.
  • UGampeonClientScripting has OnChatMessage, OnChatCleared and OnChatSuggestion for Blueprints and C++, and SubmitChat to send what the player typed.

Client scripts can also write to the chat window directly with Gampeon.ChatAddMessage and the other chat functions. Most resources should use the events above instead, so they also work with other chat resources.

gp_fakeplayer say <id> <text> in gampeon-server types into the chat of a fake player that joined with gp_fakeplayer client. Chat lines that reach the player are printed as [client <id>/chatbox].

  • Same events and the same chatMessage with CancelEvent().
  • The chat shows plain text: no HTML, no colour codes inside a line, no templates with styling.
  • Suggestions list the command and its help text, without the parameter list.

Report a problem with this pageOther ways to give feedback