跳转至

公告与聊天函数


GCNoticeSend(aIndex, type, message)

向指定玩家发送公告消息。

  • 参数:
    • aIndex (integer): 玩家索引。
    • type (integer): 公告类型(见下表)。
    • message (string): 消息文本。
  • 返回值: void
类型 显示方式
0 普通(聊天区域)
1 蓝色弹窗(屏幕中央)
2 公会公告
3 顶部滚动公告
4 红色弹窗(屏幕中央)
GCNoticeSend(aIndex, 1, "Blue popup message")
GCNoticeSend(aIndex, 0, "Normal chat message")

GCNoticeSendToAll(type, message)

向所有在线玩家发送公告消息。

  • 参数:
    • type (integer): 公告类型(与 GCNoticeSend 相同)。
    • message (string): 消息文本。
  • 返回值: void
GCNoticeSendToAll(0, "Server will restart in 5 minutes!")

GCChatTargetSend(lpObj, targetIndex, message)

从一个对象向另一个对象发送聊天消息。常用于 NPC 对话。

  • 参数:
    • lpObj (GameObject): 来源对象(NPC 或玩家)。
    • targetIndex (integer): 目标玩家索引。
    • message (string): 消息文本。
  • 返回值: void
GCChatTargetSend(npc, player.Index, "Hello, adventurer!")

PostSend(type, messageIndex, playerName, message)

通过邮件系统发送消息(所有玩家可见的全局/本地公告)。

  • 参数:
    • type (integer): 邮件类型(0-3 = 本地,4-7 = 全局)。
    • messageIndex (integer): 消息模板索引。
    • playerName (string): 邮件中显示的发送者名称。
    • message (string): 消息内容。
  • 返回值: boolean
PostSend(0, 0, "System", "Event starting in Lorencia!")
PostSend(4, 0, "System", "Global announcement!")

GetMessage(aIndex, msgId)

根据玩家配置的语言,从多语言 XML 文件(English.xmlSpanish.xml 等)中获取文本字符串。消息 ID 对应语言 XML 中 <Msg> 标签的 ID 属性。

  • 参数:
    • aIndex (integer): 玩家索引(用于确定玩家的语言)。
    • msgId (integer): 在语言 XML 文件中定义的消息 ID。
  • 返回值: string — 本地化的消息文本,如果未找到 ID 则返回 ""
-- XML: <Msg ID="2000" Text="存款成功!" />
local msg = GetMessage(aIndex, 2000)
GCNoticeSend(aIndex, 1, msg)  -- 以玩家的语言显示消息

GetMapName(aIndex, mapIndex)

根据玩家配置的语言,从多语言 XML 文件中获取本地化的地图名称。

  • 参数:
    • aIndex (integer): 玩家索引(用于确定玩家的语言)。
    • mapIndex (integer): 地图索引编号。
  • 返回值: string — 本地化的地图名称,如果未找到则返回 ""
local mapName = GetMapName(aIndex, 0)  -- 例如 "Lorencia"
GCNoticeSend(aIndex, 1, "欢迎来到 " .. mapName)