Lua Chat System — Server API — ChatSpeaker
Lua Chat System — Server API — ChatSpeaker
A ChatSpeaker is the representation of one entity that may speak in a ChatChannel. Each Player
connected to the game automatically has an associated ChatSpeaker. Additional ChatSpeakers may be constructed for non-players (such as announcers or hint messages) using ChatService:AddSpeaker().
Properties
Name
- Type: string
Name
- Description: The name of the speaker, used in referencing this speaker while calling many other functions.
Methods
JoinChannel
- Parameters: string
channelName
- Description: Adds the speaker to the channel with the given
channelName
- Returns: void
LeaveChannel
- Parameters: string
channelName
- Description: Removes the speaker from the channel with the given
channelName
- Returns: void
GetChannelList
- Parameters: None
- Description: Returns a list of the names of all the channels the speaker is in.
- Returns: array<string>
IsInChannel
- Parameters: string
channelName
- Description: Returns whether the speaker is in the channel with the given
channelName
. - Returns: bool
SayMessage
- Parameters: string
message
, stringchannelName
, dictionary<string, Variant>extraData
- Description: Causes the speaker to say
message
and return the ChatMessage object created in doing so. - Returns: ChatMessage
SendMessage
- Parameters: string
message
, stringchannel
, stringfromSpeaker
- Description: Sends a message to the ChatSpeaker with the given
fromSpeaker
name. If no such speaker is in the channel, this method creates a warning and the speaker will not see the message. - Returns: void
SendSystemMessage
- Parameters: string
message
, stringchannelName
- Description: Sends a system message to the ChatChannel with the given
channelName
. If the speaker is not in the channel, then this message will create a warning and other speakers in the channel will not see the message. - Returns: void
GetPlayer
- Parameters: None
- Description: Returns the
Player
object associated with the speaker. If the speaker is not for a player (a bot) then this returnsnil
. - Returns:
Player
ornil
SetExtraData
- Parameters: string
key
, Variantdata
- Description: Sets some extra data for the speaker under a specific
key
. Whenever the speaker sends a ChatMessage this extra data is attached to the message if none is explicitly provided with the message. For example, this allows the speaker’s chat color to be set. - Returns: void
GetExtraData
- Parameters: string
key
- Description: Returns the extra data associated with the given
key
, set using SetExtraData. - Returns: Variant
SetMainChannel
- Parameters: string
channelName
- Description: Sets the speaker to talk in the provided channel. Fires MainChannelSet.
- Returns:
nil
Events
SaidMessage
- Parameters: ChatMessage
message
, stringchannelName
- Description: Fired when the speaker sends a ChatMessage to the ChatChannel
ReceivedMessage
- Parameters: ChatMessage
message
, stringchannelName
- Description: Fired when the speaker receives a ChatMessage from another speaker on a ChatChannel
ReceivedSystemMessage
- Parameters: ChatMessage
message
, stringchannelName
- Description: Fired when the speaker receives a system ChatMessage from a ChatChannel with the given
channelName
.
ChannelJoined
- Parameters: string
channelName
, stringchannelWelcomeMessage
- Description: Fired when the speaker joins the ChatChannel with the given
channelName
.
ChannelLeft
- Parameters: string
channelName
- Description: Fired when the speaker leaves a ChatChannel with the given
channelName
.
Muted
- Parameters: string
channelName
, stringreason = nil
, intduration = 0
- Description: Fired when the speaker is muted on the ChatChannel with the given
channelName
for the given duration (if provided). There may or may not be areason
provided.
Unmuted
- Parameters: string
channelName
- Description: Fired when the speaker is unmuted on the ChatChannel with the given
channelName
.
ExtraDataUpdated
- Parameters: string
key
, Variantdata
- Description: Fired when the default value of a key in the speaker’s extra data is updated using SetExtraData.
MainChannelSet
- Parameters: string
channelName
- Description: Fired when the speakers main channel is changed to the ChatChannel with the given
channelName
.