chat:addMessage

关于

触发此事件使您可以向此客户端发送聊天消息。 消息对象结构:

message = {
  template = template,
  color = color,
  multiline = true,
  args = {author, otherArgs...}
}

事件名称

chat:addMessage

参数

object message

示例

本示例从客户端脚本向本地玩家发送聊天消息(只有执行客户端会看到此消息)。

Lua 示例:
TriggerEvent('chat:addMessage', {
  color = { 255, 0, 0},
  multiline = true,
  args = {"Me", "Please be careful to not step on too many snails!"}
})
C# 示例:
TriggerEvent("chat:addMessage", new
{
    color = new[] {255, 0, 0},
    multiline = true,
    args = new[] {"Me", "Please be careful to not step on too many snails!"}
});
JavaScript 示例:
emit('chat:addMessage', {
    color: [255, 0, 0],
    multiline: true,
    args: ['Me', 'Please be careful to not step on too many snails!']
});

示例结果:

screenshot-1

上次修改 2020-03-30: Added JavaScript example (e95d915)