private static bool Prefix(ref Chat __instance, ref string user, ref string text, ref Talker.Type type) { // Pings should not add a message to the chat. if (type == Talker.Type.Ping) { return(false); } __instance.AddString(VChatPlugin.GetFormattedMessage(new CombinedMessageType(type), user, text)); return(false); }
/// <summary> /// Triggered when the client receives a global message from the server. /// </summary> /// <remarks>Player name and position are primarily here for future work, player aliases for example.</remarks> /// <param name="senderId">The peer id of the sender</param> /// <param name="pos">The position</param> /// <param name="type">Reserved for future use</param> /// <param name="playerName">The player name</param> /// <param name="text">the message, without a playername or formatting.</param> private static void OnGlobalMessage_Client(long senderId, Vector3 pos, int type, string playerName, string text) { // If the client is connected to a server-sided instance of VChat then only accept messages from the server. if (!GreetingMessage.HasLocalPlayerReceivedGreetingFromServer || senderId == ZNet.instance.GetServerPeer()?.m_uid) { VChatPlugin.Log($"Received a global message from {playerName} ({senderId}) on location {pos} with message \"{text}\"."); if (Chat.instance != null) { var formattedMessage = VChatPlugin.GetFormattedMessage(new CombinedMessageType(CustomMessageType.Global), playerName, text); Chat.instance?.AddString(formattedMessage); } else { VChatPlugin.LogWarning($"Received a message but Chat instance is undefined."); } } else { VChatPlugin.LogWarning($"Ignoring a global message received from a client, reported values: {senderId} \"{playerName}\" on location {pos} with message \"{text}\"."); } }