Developer Preview

Chat natives

Send messages to the F7 chat and manage suggestions.

Developer Preview. Scripting is live on Neighborly servers – everything on these pages works today. The API is young, so tell us what you need next on Discord.

Send messages to the F7 chat and manage suggestions.

Open in the natives browser Search all 199 natives at once.

SendChatMessage

Server
void SendChatMessage(Player target, string author, string text, table? color)

Sends a chat message to one player or everyone.

Pass -1 to send to everyone. For messages only players on one lot should see, loop over GetPlayersOnLot.

Parameters

ParameterTypeDescription
targetPlayerServer id or -1 for everyone.
authorstringName shown in front.
textstringMessage.
colortable?{ r, g, b }.

Returns

Nothing (void).

Example

AddEventHandler('dayChanged', function(day, weekday)
    if weekday == 'friday' then
        SendChatMessage(-1, 'Bluejay Café', 'Happy hour tonight: all drinks half price!', { 255, 179, 138 })
    end
end)

AddChatMessage

Client
void AddChatMessage(string author, string text, table? color)

Adds a message to the local chat only.

Only the local player sees it. To reach other players, ask the server to use SendChatMessage.

Parameters

ParameterTypeDescription
authorstringName shown in front.
textstringMessage.
colortable?{ r, g, b }.

Returns

Nothing (void).

Example

AddEventHandler('playerSpawned', function()
    AddChatMessage('Tip', 'Use /dice to roll for everyone on your lot.', { 91, 192, 248 })
end)

AddChatSuggestion

Client
void AddChatSuggestion(string name, string help, table? params)

Adds a chat suggestion. Same as the chat:addSuggestion event.

Client only: it runs on the local player's PC and affects only their game. Other players don't see the result unless you tell the server.

Parameters

ParameterTypeDescription
namestringCommand with slash.
helpstringDescription.
paramstable?List of { name, help }.

Returns

Nothing (void).

Example

AddChatSuggestion('/dice', 'Roll a die for everyone on your lot', {
    { name = 'sides', help = 'Number of sides, 2 to 100 (default 6)' }
})

AddChatSuggestion('/tip', 'Tip another player', {
    { name = 'player', help = 'Their server id' },
    { name = 'amount', help = 'Simoleons, 1 to 500' }
})

RemoveChatSuggestion

Client
void RemoveChatSuggestion(string name)

Removes a chat suggestion.

Client only: it runs on the local player's PC and affects only their game. Other players don't see the result unless you tell the server.

Parameters

ParameterTypeDescription
namestringCommand with slash.

Returns

Nothing (void).

Example

AddEventHandler('onResourceStop', function(name)
    if name == GetCurrentResourceName() then
        RemoveChatSuggestion('/dice')
        RemoveChatSuggestion('/tip')
    end
end)

ClearChat

Server
void ClearChat(Player target)

Clears the chat window.

Pass -1 to clear everyone's chat, for example after removing spam.

Parameters

ParameterTypeDescription
targetPlayerServer id or -1.

Returns

Nothing (void).

Example

RegisterCommand('clearchat', function()
    ClearChat(-1)
end, true)

SetChatVisible

Client
void SetChatVisible(boolean visible)

Hides or shows the chat window.

Client only: it runs on the local player's PC and affects only their game. Other players don't see the result unless you tell the server.

Parameters

ParameterTypeDescription
visiblebooleanShow or hide.

Returns

Nothing (void).

Example

RegisterNetEvent('rtx_cinema:movieStarted', function()
    SetChatVisible(false)
    SetHudVisible(false)
end)

RegisterNetEvent('rtx_cinema:movieEnded', function()
    SetChatVisible(true)
    SetHudVisible(true)
end)

IsChatOpen

Client
boolean IsChatOpen()

Checks whether the chat input is open – useful to ignore key presses while typing.

Client only: it runs on the local player's PC and affects only their game. Other players don't see the result unless you tell the server.

Parameters

This native takes no parameters.

Returns

boolean Whether the player is typing in chat.

Example

if IsChatOpen() then
    return
end