IEnumerator WaitForRequest(QueueItem info) { using (var www = new WWW(info.url)) { yield return(www); if (SignArtist == null) { yield break; } var player = info.sender; if (www.error != null) { player.ChatMessage(string.Format(SignArtist.Error, www.error)); //SignArtist.CoolDowns.Remove(player); } else { if (www.size > SignArtist.MaxSize) { player.ChatMessage(SignArtist.SizeError); //SignArtist.CoolDowns.Remove(player); ActiveLoads--; Next(); yield break; } var img = info.raw ? www.bytes : GetImageBytes(www); if (img.Length <= SignArtist.MaxSize) { var sign = info.sign; if (sign.textureID > 0U) { FileStorage.server.Remove(sign.textureID, FileStorage.Type.png, sign.net.ID); } ClearStream(); stream.Write(img, 0, img.Length); sign.textureID = FileStorage.server.Store(stream, FileStorage.Type.png, sign.net.ID); ClearStream(); sign.SendNetworkUpdate(); Interface.Oxide.CallHook("OnSignUpdated", sign, player); player.ChatMessage(SignArtist.Loaded); if (SignArtist.ConsoleLog) { ServerConsole.PrintColoured(System.ConsoleColor.DarkYellow, string.Format(SignArtist.ConsoleLogMsg, player.userID, player.displayName, sign.textureID, info.url)); } //Resources.UnloadUnusedAssets(); } else { player.ChatMessage(SignArtist.SizeError); //SignArtist.CoolDowns.Remove(player); } } ActiveLoads--; Next(); } }
IEnumerator WaitForRequest(WWW www, QueueItem info) { yield return(www); BasePlayer player = info.sender; if (www.error == null) { if (www.size <= MaxSize) { Signage sign = info.sign; if (sign.textureID > 0U) { FileStorage.server.Remove(sign.textureID, FileStorage.Type.png); } sign.textureID = FileStorage.server.Store(www.bytes, FileStorage.Type.png); sign.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); player.ChatMessage(Loaded); if (ConsoleLog) { ServerConsole.PrintColoured(System.ConsoleColor.DarkYellow, ConsoleLogMsg .Replace("{steam}", player.userID.ToString()) .Replace("{name}", player.displayName) .Replace("{id}", sign.textureID.ToString()) .Replace("{url}", info.url)); } } else { player.ChatMessage(SizeError); CoolDowns.Remove(player); } } else { player.ChatMessage(Error.Replace("{error}", www.error)); CoolDowns.Remove(player); } ActiveLoads--; if (QueueList.Count > 0) { Next(); } }
internal static bool sayAs(ChatChannel targetChannel, ulong userId, string username, string message, BasePlayer player = null) { if (!player) { player = null; } if (!enabled) { return(false); } if (player != null && player.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute)) { return(false); } ServerUsers.UserGroup userGroup = ServerUsers.Get(userId)?.group ?? ServerUsers.UserGroup.None; if (userGroup == ServerUsers.UserGroup.Banned) { return(false); } string text = message.Replace("\n", "").Replace("\r", "").Trim(); if (text.Length > 128) { text = text.Substring(0, 128); } if (text.Length <= 0) { return(false); } if (text.StartsWith("/") || text.StartsWith("\\")) { Interface.CallHook("IOnPlayerCommand", player, message); return(false); } text = text.EscapeRichText(); object obj = Interface.CallHook("IOnPlayerChat", userId, username, text, targetChannel, player); if (obj is bool) { return((bool)obj); } if (serverlog) { ServerConsole.PrintColoured(ConsoleColor.DarkYellow, string.Concat("[", targetChannel, "] ", username, ": "), ConsoleColor.DarkGreen, text); string text2 = player?.ToString() ?? $"{username}[{userId}]"; switch (targetChannel) { case ChatChannel.Team: DebugEx.Log("[TEAM CHAT] " + text2 + " : " + text); break; case ChatChannel.Cards: DebugEx.Log("[CARDS CHAT] " + text2 + " : " + text); break; default: DebugEx.Log("[CHAT] " + text2 + " : " + text); break; } } bool flag = userGroup == ServerUsers.UserGroup.Owner || userGroup == ServerUsers.UserGroup.Moderator; bool num = ((player != null) ? player.IsDeveloper : DeveloperList.Contains(userId)); string text3 = "#5af"; if (flag) { text3 = "#af5"; } if (num) { text3 = "#fa5"; } string text4 = username.EscapeRichText(); ChatEntry chatEntry = default(ChatEntry); chatEntry.Channel = targetChannel; chatEntry.Message = text; chatEntry.UserId = ((player != null) ? player.UserIDString : userId.ToString()); chatEntry.Username = username; chatEntry.Color = text3; chatEntry.Time = Epoch.Current; ChatEntry chatEntry2 = chatEntry; History.Add(chatEntry2); RCon.Broadcast(RCon.LogType.Chat, chatEntry2); switch (targetChannel) { case ChatChannel.Cards: { if (player == null) { return(false); } if (!player.isMounted) { return(false); } CardTable cardTable = player.GetMountedVehicle() as CardTable; if (cardTable == null || !cardTable.GameController.PlayerIsInGame(player)) { return(false); } List <Network.Connection> obj2 = Facepunch.Pool.GetList <Network.Connection>(); cardTable.GameController.GetConnectionsInGame(obj2); if (obj2.Count > 0) { ConsoleNetwork.SendClientCommand(obj2, "chat.add2", 3, userId, text, text4, text3, 1f); } Facepunch.Pool.FreeList(ref obj2); return(true); } case ChatChannel.Global: if (Server.globalchat) { ConsoleNetwork.BroadcastToAllClients("chat.add2", 0, userId, text, text4, text3, 1f); return(true); } break; case ChatChannel.Team: { RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindPlayersTeam(userId); if (playerTeam == null) { return(false); } List <Network.Connection> onlineMemberConnections = playerTeam.GetOnlineMemberConnections(); if (onlineMemberConnections != null) { ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add2", 1, userId, text, text4, text3, 1f); } Util.BroadcastTeamChat(playerTeam, userId, text4, text, text3); return(true); } } if (player != null) { float num2 = 2500f; foreach (BasePlayer activePlayer in BasePlayer.activePlayerList) { float sqrMagnitude = (activePlayer.transform.position - player.transform.position).sqrMagnitude; if (!(sqrMagnitude > num2)) { ConsoleNetwork.SendClientCommand(activePlayer.net.connection, "chat.add2", 0, userId, text, text4, text3, Mathf.Clamp01(num2 - sqrMagnitude + 0.2f)); } } return(true); } return(false); }
private bool OnPlayerChat(ConsoleSystem.Arg arg, Chat.ChatChannel channel) { var player = arg.Player(); var text = arg.GetString(0, "text").Replace("\n", "").Replace("\r", "").Trim().EscapeRichText(); if (Chat.serverlog) { ServerConsole.PrintColoured(ConsoleColor.DarkYellow, string.Concat("[", channel.ToString(), "] ", player.displayName, ": "), ConsoleColor.DarkGreen, text); DebugEx.Log(channel == Chat.ChatChannel.Team ? $"[TEAM CHAT] {player} : {text}" : $"[CHAT] {player} : {text}"); } var color = "#5af"; var displayName = player.displayName.EscapeRichText(); player.NextChatTime = Time.realtimeSinceStartup + 1.5f; var chatEntry = new Chat.ChatEntry { Channel = channel, Message = text, UserId = player.UserIDString, Username = player.displayName, Color = color, Time = Epoch.Current }; RCon.Broadcast(RCon.LogType.Chat, chatEntry); if (channel != Chat.ChatChannel.Global) { if (channel == Chat.ChatChannel.Team) { var team = arg.Player().Team; var list = team?.GetOnlineMemberConnections(); if (list == null) { return(false); } ConsoleNetwork.SendClientCommand(list, "chat.add2", new object[] { 1, player.userID, text, displayName, color, 1f }); return(false); } } else if (ConVar.Server.globalchat) { ConsoleNetwork.BroadcastToAllClients("chat.add2", 0, player.userID, text, displayName, color, 1f); return(false); } var radius = 2500f; foreach (var basePlayer2 in BasePlayer.activePlayerList) { var sqrMagnitude = (basePlayer2.transform.position - player.transform.position).sqrMagnitude; if (sqrMagnitude <= radius) { ConsoleNetwork.SendClientCommand(basePlayer2.net.connection, "chat.add2", 0, player.userID, text, displayName, color, Mathf.Clamp01(radius - sqrMagnitude + 0.2f)); } } return(false); }
public static void say(ConsoleSystem.Arg arg) { if (!Chat.enabled) { arg.ReplyWith("Chat is disabled."); return; } BasePlayer basePlayer = arg.Player(); if (!basePlayer) { return; } if (basePlayer.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute)) { return; } if (!basePlayer.IsAdmin && !basePlayer.IsDeveloper) { if (basePlayer.NextChatTime == 0f) { basePlayer.NextChatTime = UnityEngine.Time.realtimeSinceStartup - 30f; } if (basePlayer.NextChatTime > UnityEngine.Time.realtimeSinceStartup) { basePlayer.NextChatTime += 2f; float nextChatTime = basePlayer.NextChatTime - UnityEngine.Time.realtimeSinceStartup; Connection connection = basePlayer.net.connection; object[] objArray = new object[] { 0, null }; float single = nextChatTime + 0.5f; objArray[1] = string.Concat("You're chatting too fast - try again in ", single.ToString("0"), " seconds"); ConsoleNetwork.SendClientCommand(connection, "chat.add", objArray); if (nextChatTime > 120f) { basePlayer.Kick("Chatting too fast"); } return; } } string str = arg.GetString(0, "text").Trim(); if (str.Length > 128) { str = str.Substring(0, 128); } if (str.Length <= 0) { return; } if (str.StartsWith("/") || str.StartsWith("\\")) { if (Interface.CallHook("IOnPlayerCommand", arg) != null) { return; } return; } str = str.EscapeRichText(); if (Interface.CallHook("IOnPlayerChat", arg, str) != null) { return; } if (Chat.serverlog) { ServerConsole.PrintColoured(new object[] { ConsoleColor.DarkYellow, string.Concat(basePlayer.displayName, ": "), ConsoleColor.DarkGreen, str }); DebugEx.Log(string.Format("[CHAT] {0} : {1}", basePlayer.ToString(), str), StackTraceLogType.None); } string str1 = "#5af"; if (basePlayer.IsAdmin) { str1 = "#af5"; } if (basePlayer.IsDeveloper) { str1 = "#fa5"; } string str2 = basePlayer.displayName.EscapeRichText(); basePlayer.NextChatTime = UnityEngine.Time.realtimeSinceStartup + 1.5f; Chat.ChatEntry chatEntry = new Chat.ChatEntry() { Message = str, UserId = basePlayer.userID, Username = basePlayer.displayName, Color = str1, Time = Epoch.Current }; Chat.ChatEntry chatEntry1 = chatEntry; Chat.History.Add(chatEntry1); RCon.Broadcast(RCon.LogType.Chat, chatEntry1); if (ConVar.Server.globalchat) { ConsoleNetwork.BroadcastToAllClients("chat.add2", new object[] { basePlayer.userID, str, str2, str1, 1f }); arg.ReplyWith(""); return; } float single1 = 2500f; foreach (BasePlayer basePlayer1 in BasePlayer.activePlayerList) { Vector3 vector3 = basePlayer1.transform.position - basePlayer.transform.position; float single2 = vector3.sqrMagnitude; if (single2 > single1) { continue; } ConsoleNetwork.SendClientCommand(basePlayer1.net.connection, "chat.add2", new object[] { basePlayer.userID, str, str2, str1, Mathf.Clamp01(single1 - single2 + 0.2f) }); } arg.ReplyWith(""); }
public static void say(ConsoleSystem.Arg arg) { if (!Chat.enabled) { arg.ReplyWith("Chat is disabled."); } else { BasePlayer basePlayer = arg.Player(); if (!Object.op_Implicit((Object)basePlayer) || basePlayer.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute)) { return; } if (!basePlayer.IsAdmin && !basePlayer.IsDeveloper) { if ((double)basePlayer.NextChatTime == 0.0) { basePlayer.NextChatTime = Time.get_realtimeSinceStartup() - 30f; } if ((double)basePlayer.NextChatTime > (double)Time.get_realtimeSinceStartup()) { basePlayer.NextChatTime += 2f; float num = basePlayer.NextChatTime - Time.get_realtimeSinceStartup(); ConsoleNetwork.SendClientCommand(basePlayer.net.get_connection(), "chat.add", (object)0, (object)("You're chatting too fast - try again in " + (num + 0.5f).ToString("0") + " seconds")); if ((double)num <= 120.0) { return; } basePlayer.Kick("Chatting too fast"); return; } } string str1 = arg.GetString(0, "text").Trim(); if (str1.Length > 128) { str1 = str1.Substring(0, 128); } if (str1.Length <= 0) { return; } if (str1.StartsWith("/") || str1.StartsWith("\\")) { if (Interface.CallHook("IOnPlayerCommand", (object)arg) != null) { ; } } else { string str2 = StringEx.EscapeRichText(str1); if (Interface.CallHook("IOnPlayerChat", (object)arg) != null) { return; } if (Chat.serverlog) { ServerConsole.PrintColoured((object)ConsoleColor.DarkYellow, (object)(basePlayer.displayName + ": "), (object)ConsoleColor.DarkGreen, (object)str2); DebugEx.Log((object)string.Format("[CHAT] {0} : {1}", (object)((object)basePlayer).ToString(), (object)str2), (StackTraceLogType)0); } string str3 = "#5af"; if (basePlayer.IsAdmin) { str3 = "#af5"; } if (basePlayer.IsDeveloper) { str3 = "#fa5"; } string str4 = StringEx.EscapeRichText(basePlayer.displayName); basePlayer.NextChatTime = Time.get_realtimeSinceStartup() + 1.5f; Chat.ChatEntry chatEntry = new Chat.ChatEntry() { Message = str2, UserId = basePlayer.userID, Username = basePlayer.displayName, Color = str3, Time = Epoch.get_Current() }; Chat.History.Add(chatEntry); RCon.Broadcast(RCon.LogType.Chat, (object)chatEntry); if (Server.globalchat) { ConsoleNetwork.BroadcastToAllClients("chat.add2", (object)basePlayer.userID, (object)str2, (object)str4, (object)str3, (object)1f); arg.ReplyWith(""); } else { float num = 2500f; foreach (BasePlayer activePlayer in BasePlayer.activePlayerList) { Vector3 vector3 = Vector3.op_Subtraction(((Component)activePlayer).get_transform().get_position(), ((Component)basePlayer).get_transform().get_position()); float sqrMagnitude = ((Vector3) ref vector3).get_sqrMagnitude(); if ((double)sqrMagnitude <= (double)num) { ConsoleNetwork.SendClientCommand(activePlayer.net.get_connection(), "chat.add2", (object)basePlayer.userID, (object)str2, (object)str4, (object)str3, (object)Mathf.Clamp01((float)((double)num - (double)sqrMagnitude + 0.200000002980232))); } } arg.ReplyWith(""); } } } }
private bool OnPlayerChat(BasePlayer player, string message, Chat.ChatChannel channel) { if (Chat.serverlog) { ServerConsole.PrintColoured(ConsoleColor.DarkYellow, string.Concat("[", channel, "] ", player.displayName, ": "), ConsoleColor.DarkGreen, message); var str = (player != null ? player.ToString() : null) ?? $"{player.displayName}[{player.userID}]"; if (channel == Chat.ChatChannel.Team) { DebugEx.Log("[TEAM CHAT] " + str + " : " + message); } else { DebugEx.Log("[CHAT] " + str + " : " + message); } } var color = "#5af"; var displayName = player.displayName.EscapeRichText(); var chatEntry = new Chat.ChatEntry { Channel = channel, Message = message, UserId = player.UserIDString, Username = displayName, Color = color, Time = Epoch.Current }; RCon.Broadcast(RCon.LogType.Chat, chatEntry); if (channel != Chat.ChatChannel.Global) { if (channel == Chat.ChatChannel.Team) { var playerTeam = RelationshipManager.Instance.FindPlayersTeam(player.userID); if (playerTeam == null) { return(false); } var onlineMemberConnections = playerTeam.GetOnlineMemberConnections(); if (onlineMemberConnections != null) { ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add2", 1, player.userID, message, displayName, color, 1f); } playerTeam.BroadcastTeamChat(player.userID, displayName, message, color); return(true); } } else if (ConVar.Server.globalchat) { ConsoleNetwork.BroadcastToAllClients("chat.add2", 0, player.userID, message, displayName, color, 1f); return(true); } if (player == null) { return(true); } var radius = 2500f; foreach (var basePlayer in BasePlayer.activePlayerList) { var sqrMagnitude = (basePlayer.transform.position - player.transform.position).sqrMagnitude; if (sqrMagnitude <= radius) { ConsoleNetwork.SendClientCommand(basePlayer.net.connection, "chat.add2", 0, player.userID, message, displayName, color, Mathf.Clamp01(radius - sqrMagnitude + 0.2f)); } } return(true); }
public static void On_Chat(ConsoleSystem.Arg arg) { if (arg.ArgsStr.StartsWith("\"/") && !arg.ArgsStr.StartsWith("\"/ ")) { On_Command(arg); return; } if (!ConVar.Chat.enabled) { arg.ReplyWith("Chat is disabled."); } else { if (arg.ArgsStr == "\"\"") { return; } BasePlayer basePlayer = arg.Player(); if (!basePlayer) { return; } ChatEvent pChat = new ChatEvent(Server.GetPlayer(basePlayer), arg); string str = arg.GetString(0, "text"); if (str.Length > 128) { str = str.Substring(0, 128); } if (str.Length <= 0) { return; } if (ConVar.Chat.serverlog) { ServerConsole.PrintColoured(new object[] { ConsoleColor.DarkYellow, basePlayer.displayName + ": ", ConsoleColor.DarkGreen, str }); ConVar.Server.Log("Log.Chat.txt", string.Format("{0}/{1}: {2}\r\n", basePlayer.userID, basePlayer.displayName, str)); Debug.Log(string.Format("[CHAT] {0}: {1}", basePlayer.displayName, str)); } string arg2 = "#5af"; if (basePlayer.IsAdmin()) { arg2 = "#af5"; } if (DeveloperList.IsDeveloper(basePlayer)) { arg2 = "#fa5"; } OnNext("On_Chat", pChat); string text2 = string.Format("<color={2}>{0}</color>: {1}", basePlayer.displayName.Replace('<', '[').Replace('>', ']'), pChat.FinalText, arg2); if (pChat.FinalText != "") { Logger.ChatLog(pChat.BroadcastName, pChat.OriginalText); arg.ReplyWith(pChat.Reply); if (ConVar.Server.globalchat) { ConsoleSystem.Broadcast("chat.add", basePlayer.userID, text2, 1); } else { float num = 2500; foreach (Connection current in Net.sv.connections) { if (current.player != null) { float sqrMagnitude = (current.player.transform.position - basePlayer.transform.position).sqrMagnitude; if (sqrMagnitude <= num) { ConsoleSystem.SendClientCommand(current, "chat.add", basePlayer.userID, text2, Mathf.Clamp01(num - sqrMagnitude + 0.2f)); } } } } } } }