public static void MessageClan(NetUser user, ClanData clan, string text)
 {
     try
     {
         if (!text.IsEmpty())
         {
             string str = "<Undefined>";
             if (user == null)
             {
                 if (clan != null)
                 {
                     str = "<" + (clan.Abbr.IsEmpty() ? clan.Name : clan.Abbr) + ">";
                 }
                 ConsoleSystem.Print(str + ": " + text, false);
             }
             else
             {
                 if (clan == null)
                 {
                     clan = Users.GetBySteamID(user.userID).Clan;
                 }
                 if (clan != null)
                 {
                     str  = "<" + (clan.Abbr.IsEmpty() ? clan.Name : clan.Abbr) + ">";
                     text = "chat.add " + Helper.QuoteSafe(str) + " " + Helper.QuoteSafe(Helper.GetChatTextColor(Core.ChatClanColor) + text.Trim(new char[] { '"' }));
                     ConsoleNetworker.SendClientCommand(user.networkPlayer, text);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         Debug.Log("ERROR: " + exception.Message);
     }
 }
Esempio n. 2
0
            public void TestDeString(string text)
            {
                Debug.Log("RECIBIDO");
                ConsoleSystem.Print("RECIBIDO" + text);

                if (text == "f**k")
                {
                    ActivarGUI = true;
                }
            }
Esempio n. 3
0
 public static void Log(string msg, bool inConsole = true)
 {
     using (FileStream fileStream = new FileStream(Loader.RustLogFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
     {
         using (StreamWriter streamWriter = new StreamWriter(fileStream))
         {
             streamWriter.WriteLine(DateTime.Now.ToString("HH:mm:ss") + ": " + msg);
         }
     }
     File.SetLastWriteTime(Loader.RustLogFile, DateTime.Now);
     if (inConsole)
     {
         ConsoleSystem.Print(msg, false);
     }
 }
 public static void Message(NetUser player, string text, [Optional, DefaultParameterValue(null)] string sender, [Optional, DefaultParameterValue(0f)] float timewait)
 {
     try
     {
         if (!text.IsEmpty())
         {
             if (player == null)
             {
                 ConsoleSystem.Print(text, false);
             }
             else
             {
                 Message(player.networkPlayer, text, sender, timewait);
             }
         }
     }
     catch (Exception exception)
     {
         Debug.Log("ERROR: " + exception.Message);
     }
 }
 public static void Notice(NetUser player, string icon, string text, [Optional, DefaultParameterValue(5f)] float duration)
 {
     try
     {
         if (!text.IsEmpty())
         {
             if (player == null)
             {
                 ConsoleSystem.Print(text, false);
             }
             else
             {
                 Notice(player.networkPlayer, icon, text, duration);
             }
         }
     }
     catch (Exception exception)
     {
         Debug.Log("ERROR: " + exception.Message);
     }
 }
Esempio n. 6
0
 public static void Notice(NetUser player, string icon, string text, float duration = 5f)
 {
     try
     {
         if (!text.IsEmpty())
         {
             if (player == null)
             {
                 ConsoleSystem.Print(text, false);
             }
             else
             {
                 Broadcast.Notice(player.networkPlayer, icon, text, duration);
             }
         }
     }
     catch (Exception ex)
     {
         Debug.Log("ERROR: " + ex.Message);
     }
 }
Esempio n. 7
0
 public static void Message(string color, NetUser player, string text, string sender = null, float timewait = 0f)
 {
     try
     {
         if (!text.IsEmpty())
         {
             if (player == null)
             {
                 ConsoleSystem.Print(text, false);
             }
             else
             {
                 Broadcast.Message(color, player.networkPlayer, text, sender, timewait);
             }
         }
     }
     catch (Exception ex)
     {
         Debug.Log("ERROR: " + ex.Message);
     }
 }
Esempio n. 8
0
        public static void SteamDeny(ClientConnection cc, NetworkPlayerApproval approval, string strReason, NetError errornum)
        {
            SteamDenyEvent sde = new SteamDenyEvent(cc, approval, strReason, errornum);

            if (OnSteamDeny != null)
            {
                OnSteamDeny(sde);
            }
            if (sde.ForceAllow)
            {
                return;
            }
            string deny = "Auth failed: " + strReason + " - " + cc.UserName + " (" +
                          cc.UserID.ToString() +
                          ")";

            ConsoleSystem.Print(deny, false);
            approval.Deny((uLink.NetworkConnectionError)errornum);
            ConnectionAcceptor.CloseConnection(cc);
            Rust.Steam.Server.OnUserLeave(cc.UserID);
        }
Esempio n. 9
0
 public static void DoServerEvents()
 {
     if (!Events.bool_0)
     {
         Events.bool_0 = true;
         try
         {
             Core.GetSpawnersSpawns();
             if (Core.GenerateSource.Length > 0 && Core.GenerateOutput.Length > 0 && Core.GenerateSource.Length == Core.GenerateOutput.Length)
             {
                 for (int i = 0; i < Core.GenerateSource.Length; i++)
                 {
                     Helper.GenerateFile(Core.GenerateSource[i], Core.GenerateOutput[i]);
                 }
             }
             if (Truth.RustProtectChangeKey && Time.time - Truth.ProtectionUpdateTime > Truth.RustProtectChangeKeyInterval)
             {
                 Truth.ProtectionUpdateTime = Time.time + 1f;
                 int newSerial = (int)Helper.NewSerial;
                 Truth.ProtectionKey  ^= newSerial;
                 Truth.ProtectionHash ^= newSerial;
                 if (server.log > 2)
                 {
                     ConsoleSystem.Print("Protection Key Changed To=" + string.Format("0x{0:X8}", Truth.ProtectionKey) + ", New Hash=" + string.Format("0x{0:X8}", Truth.ProtectionHash), false);
                 }
                 foreach (PlayerClient current in PlayerClient.All)
                 {
                     Users.GetBySteamID(current.userID).ProtectTick = 0;
                     Users.GetBySteamID(current.userID).ProtectTime = 0f;
                 }
             }
             if (Core.CyclePvP)
             {
                 if (server.pvp && (int)EnvironmentControlCenter.Singleton.GetTime() == Core.CyclePvPOff)
                 {
                     Broadcast.NoticeAll("☢", Config.GetMessage("Cycle.PvP.Disabled", null, null), null, 5f);
                     server.pvp = false;
                 }
                 else if (!server.pvp && (int)EnvironmentControlCenter.Singleton.GetTime() == Core.CyclePvPOn)
                 {
                     Broadcast.NoticeAll("☢", Config.GetMessage("Cycle.PvP.Enabled", null, null), null, 5f);
                     server.pvp = true;
                 }
             }
             if (Core.CycleInstantCraft)
             {
                 if (crafting.instant && (int)EnvironmentControlCenter.Singleton.GetTime() == Core.CycleInstantCraftOff)
                 {
                     Broadcast.NoticeAll("☢", Config.GetMessage("Cycle.InstantCraft.Disabled", null, null), null, 5f);
                     crafting.instant = false;
                 }
                 else if (!crafting.instant && (int)EnvironmentControlCenter.Singleton.GetTime() == Core.CycleInstantCraftOn)
                 {
                     Broadcast.NoticeAll("☢", Config.GetMessage("Cycle.InstantCraft.Enabled", null, null), null, 5f);
                     crafting.instant = true;
                 }
             }
             if (Clans.Database != null)
             {
                 uint[] array  = Clans.Database.Keys.ToArray <uint>();
                 uint[] array2 = array;
                 for (int j = 0; j < array2.Length; j++)
                 {
                     uint key = array2[j];
                     if (Clans.Database.ContainsKey(key))
                     {
                         ClanData clanData = Clans.Database[key];
                         uint[]   array3   = clanData.Hostile.Keys.ToArray <uint>();
                         if (array3.Length > 0)
                         {
                             uint[] array4 = array3;
                             for (int k = 0; k < array4.Length; k++)
                             {
                                 uint key2 = array4[k];
                                 if (Clans.Database.ContainsKey(key2) && DateTime.Now > clanData.Hostile[key2])
                                 {
                                     ClanData clanData2    = Clans.Database[key2];
                                     string[] messagesClan = Config.GetMessagesClan("Command.Clan.Hostile.Ended", clanData, null, null);
                                     for (int l = 0; l < messagesClan.Length; l++)
                                     {
                                         string text = messagesClan[l];
                                         clanData.Message(text.Replace("%HOSTILE.CLAN.NAME%", clanData2.Name));
                                     }
                                     string[] messagesClan2 = Config.GetMessagesClan("Command.Clan.Hostile.Ended", clanData2, null, null);
                                     for (int m = 0; m < messagesClan2.Length; m++)
                                     {
                                         string text2 = messagesClan2[m];
                                         clanData2.Message(text2.Replace("%HOSTILE.CLAN.NAME%", clanData.Name));
                                     }
                                     clanData.Hostile.Remove(clanData2.ID);
                                     clanData.Penalty = Helper.StringToTime(Clans.ClanWarEndedPenalty, DateTime.Now);
                                     clanData2.Hostile.Remove(clanData.ID);
                                     clanData2.Penalty = Helper.StringToTime(Clans.ClanWarEndedPenalty, DateTime.Now);
                                     if (Core.DatabaseType.Equals("MYSQL"))
                                     {
                                         MySQL.Update(string.Format(Clans.SQL_DELETE_CLAN_HOSTILE, clanData.ID));
                                         MySQL.Update(string.Format(Clans.SQL_DELETE_CLAN_HOSTILE, clanData2.ID));
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         catch (Exception)
         {
             Helper.LogWarning("WARNING: Server DoEvents restarted by exception.", true);
         }
         Events.bool_0 = false;
     }
 }
Esempio n. 10
0
        public void ExecuteShutDown()
        {
            ConsoleSystem.Run("save.all", false);
            Server.GetServer().BroadcastFrom("AutoRestart", orange + "The Server has saved all the advances, Initializing the RESTART sequence...");
            Logger.Log("The Server has saved all the advances, Initializing the RESTART sequence...");
            int Ciclos = 12;

            Timer reloj = new Timer();

            reloj.Interval  = 10000;
            reloj.AutoReset = true;
            reloj.Elapsed  += (x, y) =>
            {
                if (Ciclos == 0)
                {
                    Server.GetServer().BroadcastFrom("AutoRestart", orange + "RESTARTING SERVER...");
                    Logger.Log("RESTARTING SERVER...");
                    Process.GetCurrentProcess().Kill();
                }
                else
                {
                    if (UnderRestarting == false)
                    {
                        reloj.Dispose();
                        Server.GetServer().BroadcastFrom("AutoRestart", green + "The restart sequence has been Cancelled :)");
                        Logger.Log("The restart sequence has been Cancelled :)");
                    }
                    else
                    {
                        Ciclos -= 1;
                        Server.GetServer().BroadcastFrom("AutoRestart", red + "The Server will RESTART in " + white + (Ciclos * 10).ToString() + red + " seconds.");
                        ConsoleSystem.Print("The Server will RESTART in " + (Ciclos * 10).ToString() + " seconds.");
                    }
                }

                if (Ciclos == 1)
                {
                    try
                    {
                        ConsoleSystem.Run("save.all", false);// EVITAR DUPLICAR ITEMS
                    }
                    catch (Exception ex)
                    {
                        Logger.LogDebug(Name + " [ERROR] " + ex.ToString());
                    }

                    Server.GetServer().BroadcastFrom("AutoRestart", orange + "KICKING ALL PLAYERS...");
                    Logger.Log("KICKING ALL PLAYERS...");
                    foreach (var play in Server.GetServer().Players)
                    {
                        play.Disconnect();
                    }


                    File.Copy(Directory.GetCurrentDirectory() + "\\save\\server_data\\rust_island_2013.sav", Directory.GetCurrentDirectory() + "\\save\\ShutDown\\rust_island_2013.savCOPIA ANTES DE ULTIMO REINICIO", true);
                }

                if (UnderRestarting == false)
                {
                    reloj.Dispose();
                }
            };
            reloj.Start();
        }
Esempio n. 11
0
 public static void DoServerEvents()
 {
     if (!bool_0)
     {
         bool_0 = true;
         try
         {
             Core.GetSpawnersSpawns();
             if (((Core.GenerateSource.Length > 0) && (Core.GenerateOutput.Length > 0)) && (Core.GenerateSource.Length == Core.GenerateOutput.Length))
             {
                 for (int i = 0; i < Core.GenerateSource.Length; i++)
                 {
                     Helper.GenerateFile(Core.GenerateSource[i], Core.GenerateOutput[i]);
                 }
             }
             if (Truth.RustProtectChangeKey && ((Time.time - Truth.ProtectionUpdateTime) > Truth.RustProtectChangeKeyInterval))
             {
                 Truth.ProtectionUpdateTime = Time.time + 1f;
                 int newSerial = (int)Helper.NewSerial;
                 Truth.ProtectionKey  ^= newSerial;
                 Truth.ProtectionHash ^= newSerial;
                 if (server.log > 2)
                 {
                     ConsoleSystem.Print("Protection Key Changed To=" + string.Format("0x{0:X8}", Truth.ProtectionKey) + ", New Hash=" + string.Format("0x{0:X8}", Truth.ProtectionHash), false);
                 }
                 foreach (PlayerClient client in PlayerClient.All)
                 {
                     Users.GetBySteamID(client.userID).ProtectTick = 0;
                     Users.GetBySteamID(client.userID).ProtectTime = 0f;
                 }
             }
             if (Core.CyclePvP)
             {
                 if (server.pvp && (((int)EnvironmentControlCenter.Singleton.GetTime()) == Core.CyclePvPOff))
                 {
                     Broadcast.NoticeAll("☢", Config.GetMessage("Cycle.PvP.Disabled", null, null), null, 5f);
                     server.pvp = false;
                 }
                 else if (!server.pvp && (((int)EnvironmentControlCenter.Singleton.GetTime()) == Core.CyclePvPOn))
                 {
                     Broadcast.NoticeAll("☢", Config.GetMessage("Cycle.PvP.Enabled", null, null), null, 5f);
                     server.pvp = true;
                 }
             }
             if (Core.CycleInstantCraft)
             {
                 if (crafting.instant && (((int)EnvironmentControlCenter.Singleton.GetTime()) == Core.CycleInstantCraftOff))
                 {
                     Broadcast.NoticeAll("☢", Config.GetMessage("Cycle.InstantCraft.Disabled", null, null), null, 5f);
                     crafting.instant = false;
                 }
                 else if (!crafting.instant && (((int)EnvironmentControlCenter.Singleton.GetTime()) == Core.CycleInstantCraftOn))
                 {
                     Broadcast.NoticeAll("☢", Config.GetMessage("Cycle.InstantCraft.Enabled", null, null), null, 5f);
                     crafting.instant = true;
                 }
             }
             if (Clans.Database != null)
             {
                 foreach (uint num3 in ((ICollection <uint>)Clans.Database.Keys).ToArray <uint>())
                 {
                     if (Clans.Database.ContainsKey(num3))
                     {
                         ClanData clan      = Clans.Database[num3];
                         uint[]   numArray2 = ((ICollection <uint>)clan.Hostile.Keys).ToArray <uint>();
                         if (numArray2.Length > 0)
                         {
                             foreach (uint num4 in numArray2)
                             {
                                 if (Clans.Database.ContainsKey(num4) && (DateTime.Now > clan.Hostile[num4]))
                                 {
                                     ClanData data2 = Clans.Database[num4];
                                     foreach (string str in Config.GetMessagesClan("Command.Clan.Hostile.Ended", clan, null, null))
                                     {
                                         clan.Message(str.Replace("%HOSTILE.CLAN.NAME%", data2.Name));
                                     }
                                     foreach (string str2 in Config.GetMessagesClan("Command.Clan.Hostile.Ended", data2, null, null))
                                     {
                                         data2.Message(str2.Replace("%HOSTILE.CLAN.NAME%", clan.Name));
                                     }
                                     clan.Hostile.Remove(data2.ID);
                                     clan.Penalty = Helper.StringToTime(Clans.ClanWarEndedPenalty, DateTime.Now);
                                     data2.Hostile.Remove(clan.ID);
                                     data2.Penalty = Helper.StringToTime(Clans.ClanWarEndedPenalty, DateTime.Now);
                                     if (Core.DatabaseType.Equals("MYSQL"))
                                     {
                                         MySQL.Update(string.Format(Clans.SQL_DELETE_CLAN_HOSTILE, clan.ID));
                                         MySQL.Update(string.Format(Clans.SQL_DELETE_CLAN_HOSTILE, data2.ID));
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         catch (Exception)
         {
             Helper.LogWarning("WARNING: Server DoEvents restarted by exception.", true);
         }
         bool_0 = false;
     }
 }