opx_infinitychat
Server
Last updated on
The chat contract on the server — lines in the server's own voice.
local chat = OPX.Api.Get('chat')From server code inside opx_infinity. Both answer a Result and never yield. The line is the server's voice: not attributed to a player, skips the per-player rate limit. Text is cleaned and bounded like a player's. Other resources use the SendChat and BroadcastChat exports.
A message is a string, or { text, author?, kind? }:
kind:chat,system(default),info,warningorerror.author: cut to 64 characters.
Send
One line to one connected player.
chat.Send(target, message)Parameters
- target:
integer— player id - message:
string | table
Returns
Resulttrue— errorschat.noPlayer,chat.invalidMessage,chat.invalidKind
chat.Send(playerId, { kind = 'warning', text = 'Restart in 5 minutes.' })Broadcast
One line to many players. Distance uses the server's own positions.
chat.Broadcast(message, options)Parameters
- message:
string | table - options?:
table— none: every player.- bucket?:
integer— routing bucket. - radius?:
number— metres, up to 10 000; needsorigin. - origin?:
integer | table— a player id or{ x, y, z }. A player origin also limits to that player's bucket unlessbucketis given.
- bucket?:
Returns
Resultinteger(players reached) — errorschat.invalidMessage,chat.invalidKind,chat.invalidScope
local sent = chat.Broadcast('Gunfire reported.', { origin = playerId, radius = 50 })
if sent.ok then print(sent.value .. ' players heard it') end