private static bool LineOfSightInternal(
        Vector3 p0,
        Vector3 p1,
        int layerMask,
        float padding0,
        float padding1)
    {
        Vector3 vector3_1 = Vector3.op_Subtraction(p1, p0);
        float   magnitude = ((Vector3) ref vector3_1).get_magnitude();

        if ((double)magnitude <= (double)padding0 + (double)padding1)
        {
            return(true);
        }
        Vector3    vector3_2 = Vector3.op_Division(vector3_1, magnitude);
        Vector3    vector3_3 = Vector3.op_Multiply(vector3_2, padding0);
        Vector3    vector3_4 = Vector3.op_Multiply(vector3_2, padding1);
        RaycastHit raycastHit;

        if (!Physics.Linecast(Vector3.op_Addition(p0, vector3_3), Vector3.op_Subtraction(p1, vector3_4), ref raycastHit, layerMask, (QueryTriggerInteraction)1))
        {
            if (ConVar.Vis.lineofsight)
            {
                ConsoleNetwork.BroadcastToAllClients("ddraw.line", (object)60f, (object)Color.get_green(), (object)p0, (object)p1);
            }
            return(true);
        }
        if (ConVar.Vis.lineofsight)
        {
            ConsoleNetwork.BroadcastToAllClients("ddraw.line", (object)60f, (object)Color.get_red(), (object)p0, (object)p1);
            ConsoleNetwork.BroadcastToAllClients("ddraw.text", (object)60f, (object)Color.get_white(), (object)((RaycastHit) ref raycastHit).get_point(), (object)((Object)((RaycastHit) ref raycastHit).get_collider()).get_name());
        }
        return(false);
    }
Exemple #2
0
    private static bool LineOfSightInternal(Vector3 p0, Vector3 p1, int layerMask, float padding0, float padding1)
    {
        RaycastHit raycastHit;
        Vector3    vector3 = p1 - p0;
        float      single  = vector3.magnitude;

        if (single <= padding0 + padding1)
        {
            return(true);
        }
        Vector3 vector31 = vector3 / single;
        Vector3 vector32 = vector31 * padding0;
        Vector3 vector33 = vector31 * padding1;

        if (!UnityEngine.Physics.Linecast(p0 + vector32, p1 - vector33, out raycastHit, layerMask, QueryTriggerInteraction.Ignore))
        {
            if (ConVar.Vis.lineofsight)
            {
                ConsoleNetwork.BroadcastToAllClients("ddraw.line", new object[] { 60f, Color.green, p0, p1 });
            }
            return(true);
        }
        if (ConVar.Vis.lineofsight)
        {
            ConsoleNetwork.BroadcastToAllClients("ddraw.line", new object[] { 60f, Color.red, p0, p1 });
            ConsoleNetwork.BroadcastToAllClients("ddraw.text", new object[] { 60f, Color.white, raycastHit.point, raycastHit.collider.name });
        }
        return(false);
    }
    private IEnumerator ServerRestartWarning(string info, int iSeconds)
    {
        if (iSeconds >= 0)
        {
            if (!string.IsNullOrEmpty(info))
            {
                ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)("<color=#fff>SERVER</color> Restarting: " + info));
            }
            for (int i = iSeconds; i > 0; --i)
            {
                if (i == iSeconds || i % 60 == 0 || i < 300 && i % 30 == 0 || (i < 60 && i % 10 == 0 || i < 10))
                {
                    ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)("<color=#fff>SERVER</color> Restarting in " + (object)i + " seconds!"));
                    Debug.Log((object)("Restarting in " + (object)i + " seconds"));
                }
                yield return((object)CoroutineEx.waitForSeconds(1f));
            }
            ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)"<color=#fff>SERVER</color> Restarting");
            yield return((object)CoroutineEx.waitForSeconds(2f));

            foreach (BasePlayer basePlayer in BasePlayer.activePlayerList.ToArray())
            {
                basePlayer.Kick("Server Restarting");
            }
            yield return((object)CoroutineEx.waitForSeconds(1f));

            ConsoleSystem.Run(ConsoleSystem.Option.get_Server(), "quit", (object[])Array.Empty <object>());
        }
    }
Exemple #4
0
        /// <summary>
        /// Broadcasts the specified chat message and prefix to all players
        /// </summary>
        /// <param name="message"></param>
        /// <param name="userId"></param>
        /// <param name="prefix"></param>
        /// <param name="args"></param>
        public void Broadcast(string message, string prefix, ulong userId = 0, params object[] args)
        {
            message = args.Length > 0 ? string.Format(Formatter.ToUnity(message), args) : Formatter.ToUnity(message);
            var formatted = prefix != null ? $"{prefix} {message}" : message;

            ConsoleNetwork.BroadcastToAllClients("chat.add", userId, formatted, 1.0);
        }
 protected void PrintToConsole(string format, params object[] args)
 {
     if (BasePlayer.activePlayerList.Count >= 1)
     {
         ConsoleNetwork.BroadcastToAllClients(String.Concat("echo ", (args.Length != 0 ? String.Format(format, args) : format)), Array.Empty <object>());
     }
 }
Exemple #6
0
        object OnUserChat(IPlayer player, string message)
        {
            object hookResult = Interface.CallHook("OnBetterChat", player, message);

            if (hookResult is string)
            {
                message = (string)hookResult;
            }
            else if (hookResult != null)
            {
                return(null);
            }

            var output = ChatGroup.FormatMessage(player, message);

            if (output == null)
            {
                return(null);
            }

#if RUST
            ConsoleNetwork.BroadcastToAllClients("chat.add", new object[] { player.Id, output.Chat });
#else
            server.Broadcast(output.Chat);
#endif

            Puts(output.Console);

            return(true);
        }
Exemple #7
0
 /// <summary>
 /// Print a message to every players chat log
 /// </summary>
 /// <param name="format"></param>
 /// <param name="args"></param>
 protected void PrintToChat(string format, params object[] args)
 {
     if (BasePlayer.activePlayerList.Count >= 1)
     {
         ConsoleNetwork.BroadcastToAllClients("chat.add", 0, args.Length > 0 ? string.Format(format, args) : format, 1f);
     }
 }
Exemple #8
0
        public static void cinematic_stop(Arg arg)
        {
            if (!arg.IsServerside)
            {
                return;
            }
            BasePlayer basePlayer = ArgEx.Player(arg);

            if (!(basePlayer == null))
            {
                string strCommand = string.Empty;
                if (basePlayer.IsAdmin || basePlayer.IsDeveloper)
                {
                    strCommand = arg.cmd.FullName + " " + arg.FullString + " " + basePlayer.UserIDString;
                }
                else if (Server.cinematic)
                {
                    strCommand = arg.cmd.FullName + " " + basePlayer.UserIDString;
                }
                if (Server.cinematic)
                {
                    ConsoleNetwork.BroadcastToAllClients(strCommand);
                }
                else if (basePlayer.IsAdmin || basePlayer.IsDeveloper)
                {
                    ConsoleNetwork.SendClientCommand(arg.Connection, strCommand);
                }
            }
        }
    private void DebugHurt(HitInfo info)
    {
        if (!ConVar.Vis.damage)
        {
            return;
        }
        if (info.PointStart != info.PointEnd)
        {
            ConsoleNetwork.BroadcastToAllClients("ddraw.arrow", 60, Color.cyan, info.PointStart, info.PointEnd, 0.1f);
            ConsoleNetwork.BroadcastToAllClients("ddraw.sphere", 60, Color.cyan, info.HitPositionWorld, 0.01f);
        }
        string text = "";

        for (int i = 0; i < info.damageTypes.types.Length; i++)
        {
            float num = info.damageTypes.types[i];
            if (num != 0f)
            {
                string[] obj = new string[5] {
                    text, " ", null, null, null
                };
                DamageType damageType = (DamageType)i;
                obj[2] = damageType.ToString().PadRight(10);
                obj[3] = num.ToString("0.00");
                obj[4] = "\n";
                text   = string.Concat(obj);
            }
        }
        string text2 = string.Concat("<color=lightblue>Damage:</color>".PadRight(10), info.damageTypes.Total().ToString("0.00"), "\n<color=lightblue>Health:</color>".PadRight(10), health.ToString("0.00"), " / ", (health - info.damageTypes.Total() <= 0f) ? "<color=red>" : "<color=green>", (health - info.damageTypes.Total()).ToString("0.00"), "</color>", "\n<color=lightblue>HitEnt:</color>".PadRight(10), this, "\n<color=lightblue>HitBone:</color>".PadRight(10), info.boneName, "\n<color=lightblue>Attacker:</color>".PadRight(10), info.Initiator, "\n<color=lightblue>WeaponPrefab:</color>".PadRight(10), info.WeaponPrefab, "\n<color=lightblue>Damages:</color>\n", text);

        ConsoleNetwork.BroadcastToAllClients("ddraw.text", 60, Color.white, info.HitPositionWorld, text2);
    }
Exemple #10
0
    private void DebugHurt(HitInfo info)
    {
        if (!ConVar.Vis.damage)
        {
            return;
        }
        if (Vector3.op_Inequality(info.PointStart, info.PointEnd))
        {
            ConsoleNetwork.BroadcastToAllClients("ddraw.arrow", (object)60, (object)Color.get_cyan(), (object)info.PointStart, (object)info.PointEnd, (object)0.1f);
            ConsoleNetwork.BroadcastToAllClients("ddraw.sphere", (object)60, (object)Color.get_cyan(), (object)info.HitPositionWorld, (object)0.01f);
        }
        string str1 = "";

        for (int index = 0; index < info.damageTypes.types.Length; ++index)
        {
            float type = info.damageTypes.types[index];
            if ((double)type != 0.0)
            {
                str1 = str1 + " " + ((DamageType)index).ToString().PadRight(10) + type.ToString("0.00") + "\n";
            }
        }
        string str2 = "<color=lightblue>Damage:</color>".PadRight(10) + info.damageTypes.Total().ToString("0.00") + "\n<color=lightblue>Health:</color>".PadRight(10) + this.health.ToString("0.00") + " / " + ((double)this.health - (double)info.damageTypes.Total() <= 0.0 ? (object)"<color=red>" : (object)"<color=green>") + (this.health - info.damageTypes.Total()).ToString("0.00") + "</color>" + "\n<color=lightblue>HitEnt:</color>".PadRight(10) + (object)this + "\n<color=lightblue>HitBone:</color>".PadRight(10) + info.boneName + "\n<color=lightblue>Attacker:</color>".PadRight(10) + (object)info.Initiator + "\n<color=lightblue>WeaponPrefab:</color>".PadRight(10) + (object)info.WeaponPrefab + "\n<color=lightblue>Damages:</color>\n" + str1;

        ConsoleNetwork.BroadcastToAllClients("ddraw.text", (object)60, (object)Color.get_white(), (object)info.HitPositionWorld, (object)str2);
    }
Exemple #11
0
 /// <summary>
 /// Print a message to every players console log
 /// </summary>
 /// <param name="format"></param>
 /// <param name="args"></param>
 protected void PrintToConsole(string format, params object[] args)
 {
     if (BasePlayer.activePlayerList.Count < 1)
     {
         return;
     }
     ConsoleNetwork.BroadcastToAllClients("echo " + (args.Length > 0 ? string.Format(format, args) : format));
 }
Exemple #12
0
 void BroadcastChat(string name, string message, ulong userId = 0, string censormessage = "")
 {
     if (string.IsNullOrEmpty(censormessage))
     {
         censormessage = message;
     }
     ConsoleNetwork.BroadcastToAllClients("chat.add", userId, string.IsNullOrEmpty(name) ? $"{censormessage}" : $"{name}: {censormessage}");
 }
 private static void HandleClientUpdate(ClientStatusUpdate <EasyAntiCheat.Server.Hydra.Client> clientStatus)
 {
     using (TimeWarning.New("AntiCheatKickPlayer", 10L))
     {
         EasyAntiCheat.Server.Hydra.Client client = clientStatus.get_Client();
         Connection connection = EACServer.GetConnection(client);
         if (connection == null)
         {
             Debug.LogError((object)("EAC status update for invalid client: " + (object)((EasyAntiCheat.Server.Hydra.Client) ref client).get_ClientID()));
         }
         else
         {
             if (EACServer.ShouldIgnore(connection))
             {
                 return;
             }
             if (clientStatus.get_RequiresKick())
             {
                 string message = clientStatus.get_Message();
                 if (string.IsNullOrEmpty(message))
                 {
                     message = clientStatus.get_Status().ToString();
                 }
                 Debug.Log((object)("[EAC] Kicking " + (object)(ulong)connection.userid + " (" + message + ")"));
                 connection.authStatus = (__Null)"eac";
                 ((Network.Server)Net.sv).Kick(connection, "EAC: " + message);
                 DateTime?nullable = new DateTime?();
                 if (clientStatus.IsBanned(ref nullable))
                 {
                     connection.authStatus = (__Null)"eacbanned";
                     Interface.CallHook("OnPlayerBanned", (object)connection, (object)connection.authStatus);
                     ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)("<color=#fff>SERVER</color> Kicking " + (string)connection.username + " (banned by anticheat)"));
                     if (!nullable.HasValue)
                     {
                         Entity.DeleteBy((ulong)connection.userid);
                     }
                 }
                 EACServer.easyAntiCheat.UnregisterClient(client);
                 EACServer.client2connection.Remove(client);
                 EACServer.connection2client.Remove(connection);
                 EACServer.connection2status.Remove(connection);
             }
             else if (clientStatus.get_Status() == 2)
             {
                 EACServer.OnAuthenticatedLocal(connection);
                 EACServer.easyAntiCheat.SetClientNetworkState(client, false);
             }
             else
             {
                 if (clientStatus.get_Status() != 5)
                 {
                     return;
                 }
                 EACServer.OnAuthenticatedRemote(connection);
             }
         }
     }
 }
Exemple #14
0
 public void Broadcast(string message, string prefix, ulong userId = 0L, params object[] args)
 {
     if (!String.IsNullOrEmpty(message))
     {
         message = (args.Length != 0 ? String.Format(Formatter.ToUnity(message), args) : Formatter.ToUnity(message));
         string str = (prefix != null ? String.Concat(prefix, ": ", message) : message);
         ConsoleNetwork.BroadcastToAllClients("chat.add", new Object[] { userId, str, 1 });
     }
 }
 protected void PrintToChat(string format, params object[] args)
 {
     if (BasePlayer.activePlayerList.Count >= 1)
     {
         System.Object[] objArray = new Object[] { 0, null, null };
         objArray[1] = (args.Length != 0 ? String.Format(format, args) : format);
         objArray[2] = 1f;
         ConsoleNetwork.BroadcastToAllClients("chat.add", objArray);
     }
 }
Exemple #16
0
    private static bool LineOfSightInternal(Vector3 p0, Vector3 p1, int layerMask, float padding0, float padding1)
    {
        if (!ValidBounds.Test(p0))
        {
            return(false);
        }
        if (!ValidBounds.Test(p1))
        {
            return(false);
        }
        Vector3 vector    = p1 - p0;
        float   magnitude = vector.magnitude;

        if (magnitude <= padding0 + padding1)
        {
            return(true);
        }
        Vector3    vector2     = vector / magnitude;
        Ray        ray         = new Ray(p0 + vector2 * padding0, vector2);
        float      maxDistance = magnitude - padding0 - padding1;
        bool       flag;
        RaycastHit hitInfo;

        if (((uint)layerMask & 0x800000u) != 0)
        {
            flag = Trace(ray, 0f, out hitInfo, maxDistance, layerMask, QueryTriggerInteraction.Ignore);
            if (ConVar.AntiHack.losradius > 0f && !flag)
            {
                flag = Trace(ray, ConVar.AntiHack.losradius, out hitInfo, maxDistance, layerMask, QueryTriggerInteraction.Ignore);
            }
        }
        else
        {
            flag = UnityEngine.Physics.Raycast(ray, out hitInfo, maxDistance, layerMask, QueryTriggerInteraction.Ignore);
            if (ConVar.AntiHack.losradius > 0f && !flag)
            {
                flag = UnityEngine.Physics.SphereCast(ray, ConVar.AntiHack.losradius, out hitInfo, maxDistance, layerMask, QueryTriggerInteraction.Ignore);
            }
        }
        if (!flag)
        {
            if (ConVar.Vis.lineofsight)
            {
                ConsoleNetwork.BroadcastToAllClients("ddraw.line", 60f, Color.green, p0, p1);
            }
            return(true);
        }
        if (ConVar.Vis.lineofsight)
        {
            ConsoleNetwork.BroadcastToAllClients("ddraw.line", 60f, Color.red, p0, p1);
            ConsoleNetwork.BroadcastToAllClients("ddraw.text", 60f, Color.white, hitInfo.point, hitInfo.collider.name);
        }
        return(false);
    }
    private void DebugHurt(HitInfo info)
    {
        if (!ConVar.Vis.damage)
        {
            return;
        }
        if (info.PointStart != info.PointEnd)
        {
            ConsoleNetwork.BroadcastToAllClients("ddraw.arrow", new object[] { 60, Color.cyan, info.PointStart, info.PointEnd, 0.1f });
            ConsoleNetwork.BroadcastToAllClients("ddraw.sphere", new object[] { 60, Color.cyan, info.HitPositionWorld, 0.01f });
        }
        string str = "";

        for (int i = 0; i < (int)info.damageTypes.types.Length; i++)
        {
            float single = info.damageTypes.types[i];
            if (single != 0f)
            {
                string[]   strArrays  = new string[] { str, " ", null, null, null };
                DamageType damageType = (DamageType)i;
                strArrays[2] = damageType.ToString().PadRight(10);
                strArrays[3] = single.ToString("0.00");
                strArrays[4] = "\n";
                str          = string.Concat(strArrays);
            }
        }
        object[] initiator = new object[18];
        initiator[0] = "<color=lightblue>Damage:</color>".PadRight(10);
        float single1 = info.damageTypes.Total();

        initiator[1]  = single1.ToString("0.00");
        initiator[2]  = "\n<color=lightblue>Health:</color>".PadRight(10);
        single1       = this.health;
        initiator[3]  = single1.ToString("0.00");
        initiator[4]  = " / ";
        initiator[5]  = (this.health - info.damageTypes.Total() <= 0f ? "<color=red>" : "<color=green>");
        single1       = this.health - info.damageTypes.Total();
        initiator[6]  = single1.ToString("0.00");
        initiator[7]  = "</color>";
        initiator[8]  = "\n<color=lightblue>HitEnt:</color>".PadRight(10);
        initiator[9]  = this;
        initiator[10] = "\n<color=lightblue>HitBone:</color>".PadRight(10);
        initiator[11] = info.boneName;
        initiator[12] = "\n<color=lightblue>Attacker:</color>".PadRight(10);
        initiator[13] = info.Initiator;
        initiator[14] = "\n<color=lightblue>WeaponPrefab:</color>".PadRight(10);
        initiator[15] = info.WeaponPrefab;
        initiator[16] = "\n<color=lightblue>Damages:</color>\n";
        initiator[17] = str;
        string str1 = string.Concat(initiator);

        ConsoleNetwork.BroadcastToAllClients("ddraw.text", new object[] { 60, Color.white, info.HitPositionWorld, str1 });
    }
 private static void HandleClientUpdate(ClientStatusUpdate <EasyAntiCheat.Server.Hydra.Client> clientStatus)
 {
     using (TimeWarning timeWarning = TimeWarning.New("AntiCheatKickPlayer", (long)10))
     {
         EasyAntiCheat.Server.Hydra.Client client = clientStatus.Client;
         Connection connection = EACServer.GetConnection(client);
         if (connection == null)
         {
             Debug.LogError(string.Concat("EAC status update for invalid client: ", client.ClientID));
         }
         else if (!EACServer.ShouldIgnore(connection))
         {
             if (clientStatus.RequiresKick)
             {
                 string message = clientStatus.Message;
                 if (string.IsNullOrEmpty(message))
                 {
                     message = clientStatus.Status.ToString();
                 }
                 Debug.Log(string.Concat(new object[] { "[EAC] Kicking ", connection.userid, " (", message, ")" }));
                 connection.authStatus = "eac";
                 Network.Net.sv.Kick(connection, string.Concat("EAC: ", message));
                 DateTime?nullable = null;
                 if (clientStatus.IsBanned(out nullable))
                 {
                     connection.authStatus = "eacbanned";
                     Interface.CallHook("OnPlayerBanned", connection, connection.authStatus);
                     ConsoleNetwork.BroadcastToAllClients("chat.add", new object[] { 0, string.Concat("<color=#fff>SERVER</color> Kicking ", connection.username, " (banned by anticheat)") });
                     if (!nullable.HasValue)
                     {
                         Entity.DeleteBy(connection.userid);
                     }
                 }
                 EACServer.easyAntiCheat.UnregisterClient(client);
                 EACServer.client2connection.Remove(client);
                 EACServer.connection2client.Remove(connection);
                 EACServer.connection2status.Remove(connection);
             }
             else if (clientStatus.Status == ClientStatus.ClientAuthenticatedLocal)
             {
                 EACServer.OnAuthenticatedLocal(connection);
                 EACServer.easyAntiCheat.SetClientNetworkState(client, false);
             }
             else if (clientStatus.Status == ClientStatus.ClientAuthenticatedRemote)
             {
                 EACServer.OnAuthenticatedRemote(connection);
             }
         }
     }
 }
Exemple #19
0
 public static void Broadcast(this Plugin plugin, string langKey, params object[] args)
 {
     if (!RegistredPlugins.ContainsKey(plugin.Name))
     {
         Logger.Error($"'{plugin.Name}' пытается вызвать RustyLang.Broadcast, но он не содержит список сообщений");
         return;
     }
     if (!RegistredPlugins[plugin.Name].ContainsKey(langKey))
     {
         Logger.Error($"'{plugin.Name}' пытается вызвать RustyLang.Broadcast, но он не содержит указанное сообщение '{langKey}'");
         return;
     }
     ConsoleNetwork.BroadcastToAllClients("chat.add", 0, string.Format(RegistredPlugins[plugin.Name][langKey], args));
 }
 public static void RestartServer(string strNotice, int iSeconds)
 {
     if (Object.op_Equality((Object)SingletonComponent <ServerMgr> .Instance, (Object)null))
     {
         return;
     }
     if (((ServerMgr)SingletonComponent <ServerMgr> .Instance).restartCoroutine != null)
     {
         ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)"<color=#fff>SERVER</color> Restart interrupted!");
         ((MonoBehaviour)SingletonComponent <ServerMgr> .Instance).StopCoroutine(((ServerMgr)SingletonComponent <ServerMgr> .Instance).restartCoroutine);
         ((ServerMgr)SingletonComponent <ServerMgr> .Instance).restartCoroutine = (IEnumerator)null;
     }
     ((ServerMgr)SingletonComponent <ServerMgr> .Instance).restartCoroutine = ((ServerMgr)SingletonComponent <ServerMgr> .Instance).ServerRestartWarning(strNotice, iSeconds);
     ((MonoBehaviour)SingletonComponent <ServerMgr> .Instance).StartCoroutine(((ServerMgr)SingletonComponent <ServerMgr> .Instance).restartCoroutine);
     ((ServerMgr)SingletonComponent <ServerMgr> .Instance).UpdateServerInformation();
 }
Exemple #21
0
        void LandingCheck(BaseEntity entity)
        {
            var distance = Vector3.Distance(entity.transform.position, GetGroundPosition(entity.transform.position));

            if (distance >= 10f)
            {
                timer.Once(1f, () => LandingCheck(entity));
                return;
            }

            var pos      = entity.transform.position;
            var startPos = new Vector3(pos.x, pos.y + 5 + supplyDropArrowLength, pos.z);
            var endPos   = new Vector3(pos.x, pos.y + 5, pos.z);
            var args     = new object[] { supplyDropArrowTime, Color.white, startPos, endPos, supplyDropArrowSize };

            ConsoleNetwork.BroadcastToAllClients("ddraw.arrow", args);
        }
Exemple #22
0
        object OnUserChat(IPlayer player, string message)
        {
            if (!IsRightToLeft(message))
            {
                return(null);
            }

            var color = player.IsAdmin ? "#aaff55" : "#55aaff";

            message = covalence.FormatText($"[{color}]{player.Name}[/#]") + ": " + RtlText(message);
#if RUST
            ConsoleNetwork.BroadcastToAllClients("chat.add", player.Id, message);
#else
            server.Broadcast(message);
#endif
            return(true);
        }
Exemple #23
0
 public static void Broadcast(string message, string username = "******", string color = "#eee", ulong userid = 0uL)
 {
     if (Interface.CallHook("OnServerMessage", message, username, color, userid) == null)
     {
         string text = username.EscapeRichText();
         ConsoleNetwork.BroadcastToAllClients("chat.add", 2, 0, "<color=" + color + ">" + text + "</color> " + message);
         ChatEntry chatEntry = default(ChatEntry);
         chatEntry.Channel  = ChatChannel.Server;
         chatEntry.Message  = message;
         chatEntry.UserId   = userid.ToString();
         chatEntry.Username = username;
         chatEntry.Color    = color;
         chatEntry.Time     = Epoch.Current;
         ChatEntry chatEntry2 = chatEntry;
         History.Add(chatEntry2);
         RCon.Broadcast(RCon.LogType.Chat, chatEntry2);
     }
 }
Exemple #24
0
    public static void RestartServer(string strNotice, int iSeconds)
    {
        if (SingletonComponent <ServerMgr> .Instance == null)
        {
            return;
        }
        if (SingletonComponent <ServerMgr> .Instance.restartCoroutine != null)
        {
            ConsoleNetwork.BroadcastToAllClients("chat.add", new object[] { 0, "<color=#fff>SERVER</color> Restart interrupted!" });
            SingletonComponent <ServerMgr> .Instance.StopCoroutine(SingletonComponent <ServerMgr> .Instance.restartCoroutine);

            SingletonComponent <ServerMgr> .Instance.restartCoroutine = null;
        }
        SingletonComponent <ServerMgr> .Instance.restartCoroutine = SingletonComponent <ServerMgr> .Instance.ServerRestartWarning(strNotice, iSeconds);

        SingletonComponent <ServerMgr> .Instance.StartCoroutine(SingletonComponent <ServerMgr> .Instance.restartCoroutine);

        SingletonComponent <ServerMgr> .Instance.UpdateServerInformation();
    }
Exemple #25
0
        public static void Broadcast(string message, string username = "******", string color = "#eee", ulong userid = 0)
        {
            if (Interface.CallHook("OnServerMessage", (object)message, (object)username, (object)color, (object)userid) != null)
            {
                return;
            }
            string str = StringEx.EscapeRichText(username);

            ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)("<color=" + color + ">" + str + "</color> " + message));
            Chat.ChatEntry chatEntry = new Chat.ChatEntry()
            {
                Message  = message,
                UserId   = userid,
                Username = username,
                Color    = color,
                Time     = Epoch.get_Current()
            };
            Chat.History.Add(chatEntry);
            RCon.Broadcast(RCon.LogType.Chat, (object)chatEntry);
        }
Exemple #26
0
    private IEnumerator ServerRestartWarning(string info, int iSeconds)
    {
        int j = 0;

        if (iSeconds < 0)
        {
            yield break;
        }
        if (!string.IsNullOrEmpty(info))
        {
            object[] objArray = new object[] { 0, string.Concat("<color=#fff>SERVER</color> Restarting: ", info) };
            ConsoleNetwork.BroadcastToAllClients("chat.add", objArray);
        }
        for (int i = iSeconds; i > 0; i = j - 1)
        {
            if (i == iSeconds || i % 60 == 0 || i < 300 && i % 30 == 0 || i < 60 && i % 10 == 0 || i < 10)
            {
                object[] objArray1 = new object[] { 0, string.Format("<color=#fff>SERVER</color> Restarting in {0} seconds!", i) };
                ConsoleNetwork.BroadcastToAllClients("chat.add", objArray1);
                UnityEngine.Debug.Log(string.Format("Restarting in {0} seconds", i));
            }
            yield return(CoroutineEx.waitForSeconds(1f));

            j = i;
        }
        object[] objArray2 = new object[] { 0, "<color=#fff>SERVER</color> Restarting" };
        ConsoleNetwork.BroadcastToAllClients("chat.add", objArray2);
        yield return(CoroutineEx.waitForSeconds(2f));

        BasePlayer[] array = BasePlayer.activePlayerList.ToArray();
        for (j = 0; j < (int)array.Length; j++)
        {
            array[j].Kick("Server Restarting");
        }
        yield return(CoroutineEx.waitForSeconds(1f));

        ConsoleSystem.Run(ConsoleSystem.Option.Server, "quit", Array.Empty <object>());
    }
Exemple #27
0
        public static void Broadcast(string message, string username = "******", string color = "#eee", ulong userid = 0L)
        {
            if (Interface.CallHook("OnServerMessage", message, username, color, userid) != null)
            {
                return;
            }
            string str = username.EscapeRichText();

            object[] objArray = new object[] { 0, null };
            objArray[1] = string.Concat(new string[] { "<color=", color, ">", str, "</color> ", message });
            ConsoleNetwork.BroadcastToAllClients("chat.add", objArray);
            Chat.ChatEntry chatEntry = new Chat.ChatEntry()
            {
                Message  = message,
                UserId   = userid,
                Username = username,
                Color    = color,
                Time     = Epoch.Current
            };
            Chat.ChatEntry chatEntry1 = chatEntry;
            Chat.History.Add(chatEntry1);
            RCon.Broadcast(RCon.LogType.Chat, chatEntry1);
        }
Exemple #28
0
        void DrawArrow(BaseEntity entity)
        {
            //var color = HexToColor(arrowColor); // TODO: Fix this causing NRE, add default color too
            var pos      = entity.transform.position;
            var startPos = new Vector3(pos.x, pos.y + 5 + arrowLength, pos.z);
            var endPos   = new Vector3(pos.x, pos.y + 5, pos.z);
            var args     = new object[] { arrowUntilEmpty ? 0.1f : arrowTime, Color.white, startPos, endPos, arrowSize };

            if (arrowOnLanding && !arrowUntilEmpty)
            {
                ConsoleNetwork.BroadcastToAllClients("ddraw.arrow", args);
            }
            else if (arrowUntilEmpty)
            {
                timers[entity] = timer.Every(0.1f, () =>
                {
                    if (entity.IsDestroyed)
                    {
                        timers[entity]?.Destroy(); return;
                    }
                    ConsoleNetwork.BroadcastToAllClients("ddraw.arrow", args);
                });
            }
        }
Exemple #29
0
        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);
        }
Exemple #30
0
 public void BroadcastChat(string name, string message = null, string userId = "0")
 {
     ConsoleNetwork.BroadcastToAllClients("chat.add", userId, message != null ? $"<color=orange>{name}</color>: {message}" : name, 1.0);
 }