Пример #1
0
 public static void DoProcessUsers()
 {
     if (!Events.bool_1)
     {
         Events.bool_1 = true;
         foreach (UserData current in Users.All)
         {
             NetUser netUser = NetUser.FindByUserID(current.SteamID);
             if (netUser != null && !netUser.did_join)
             {
                 netUser = null;
             }
             List <Countdown> list = new List <Countdown>();
             foreach (Countdown current2 in Users.CountdownList(current.SteamID))
             {
                 if (current2.Expires)
                 {
                     if (current2.Expired)
                     {
                         list.Add(current2);
                     }
                     else if (current2.Command.Equals("pvp", StringComparison.OrdinalIgnoreCase) && current.HasFlag(UserFlags.nopvp) && Convert.ToInt32(current2.TimeLeft) < Core.CommandNoPVPCountdown)
                     {
                         current.SetFlag(UserFlags.nopvp, false);
                         if (netUser != null)
                         {
                             Broadcast.Notice(netUser, "☢", Config.GetMessage("Command.PvP.Enabled", netUser, null), 5f);
                         }
                         Broadcast.NoticeAll("☢", Config.GetMessage("Command.PvP.NoticeEnabled", null, current.Username), netUser, 5f);
                     }
                 }
             }
             foreach (Countdown current3 in list)
             {
                 Users.CountdownRemove(current.SteamID, current3);
             }
             if (current.PremiumDate.Millisecond != 0 && current.PremiumDate < DateTime.Now)
             {
                 Users.SetFlags(current.SteamID, UserFlags.premium, false);
                 Users.SetRank(current.SteamID, Users.DefaultRank);
                 Users.SetPremiumDate(current.SteamID, default(DateTime));
                 Broadcast.Notice(netUser, "☢", Config.GetMessage("Player.Premium.Expired", null, null), 5f);
             }
             if (Core.OwnershipDestroyAutoDisable > 0 && Core.DestoryOwnership.ContainsKey(current.SteamID) && Core.DestoryOwnership[current.SteamID] < DateTime.Now)
             {
                 Core.DestoryOwnership.Remove(current.SteamID);
                 if (netUser != null)
                 {
                     Broadcast.Notice(netUser, "☢", Config.GetMessage("Command.Destroy.Disabled", null, null), 5f);
                 }
             }
             Character character;
             if (netUser != null && netUser.did_join && netUser.admin && Character.FindByUser(netUser.userID, out character))
             {
                 Metabolism component = character.GetComponent <Metabolism>();
                 if (component.GetCalorieLevel() < 3000f)
                 {
                     component.AddCalories(3000f - component.GetCalorieLevel());
                 }
                 if (component.GetRadLevel() > 0f)
                 {
                     component.AddAntiRad(component.GetRadLevel());
                 }
             }
         }
         Events.bool_1 = false;
         if (Core.DatabaseType.Equals("MYSQL") && !Events.bool_3 && DateTime.Now.Subtract(Events.dateTime_0).TotalMilliseconds > Core.MySQL_SyncInterval)
         {
             if (Core.MySQL_LogLevel > 2u)
             {
                 Helper.LogSQL("Thread \"ProcessUsers\": Synchronizing server data from MySQL database", false);
             }
             SystemTimestamp restart = SystemTimestamp.Restart;
             Events.bool_3 = true;
             Core.SQL_UpdateServer();
             if (Core.MySQL_Synchronize)
             {
                 Users.SQL_SynchronizeUsers();
             }
             if (Core.MySQL_Synchronize)
             {
                 Clans.SQL_SynchronizeClans();
             }
             Events.dateTime_0 = DateTime.Now;
             Events.bool_3     = false;
             restart.Stop();
             if (Core.MySQL_LogLevel > 2u)
             {
                 Helper.LogSQL("Thread \"ProcessUsers\": Synchronized, is took " + restart.ElapsedSeconds.ToString("0.0000") + " second(s).", false);
             }
         }
     }
 }
Пример #2
0
 public static void DoProcessUsers()
 {
     if (!bool_1)
     {
         bool_1 = true;
         foreach (UserData data in Users.All)
         {
             Character character;
             NetUser   player = NetUser.FindByUserID(data.SteamID);
             if ((player != null) && !player.did_join)
             {
                 player = null;
             }
             System.Collections.Generic.List <Countdown> list = new System.Collections.Generic.List <Countdown>();
             foreach (Countdown countdown in Users.CountdownList(data.SteamID))
             {
                 if (countdown.Expires)
                 {
                     if (countdown.Expired)
                     {
                         list.Add(countdown);
                     }
                     else if ((countdown.Command.Equals("pvp", StringComparison.OrdinalIgnoreCase) && data.HasFlag(UserFlags.nopvp)) && (Convert.ToInt32(countdown.TimeLeft) < Core.CommandNoPVPCountdown))
                     {
                         data.SetFlag(UserFlags.nopvp, false);
                         if (player != null)
                         {
                             Broadcast.Notice(player, "☢", Config.GetMessage("Command.PvP.Enabled", player, null), 5f);
                         }
                         Broadcast.NoticeAll("☢", Config.GetMessage("Command.PvP.NoticeEnabled", null, data.Username), player, 5f);
                     }
                 }
             }
             foreach (Countdown countdown2 in list)
             {
                 Users.CountdownRemove(data.SteamID, countdown2);
             }
             if ((data.PremiumDate.Millisecond != 0) && (data.PremiumDate < DateTime.Now))
             {
                 Users.SetFlags(data.SteamID, UserFlags.premium, false);
                 Users.SetRank(data.SteamID, Users.DefaultRank);
                 DateTime date = new DateTime();
                 Users.SetPremiumDate(data.SteamID, date);
                 Broadcast.Notice(player, "☢", Config.GetMessage("Player.Premium.Expired", null, null), 5f);
             }
             if (((Core.OwnershipDestroyAutoDisable > 0) && Core.DestoryOwnership.ContainsKey(data.SteamID)) && (Core.DestoryOwnership[data.SteamID] < DateTime.Now))
             {
                 Core.DestoryOwnership.Remove(data.SteamID);
                 if (player != null)
                 {
                     Broadcast.Notice(player, "☢", Config.GetMessage("Command.Destroy.Disabled", null, null), 5f);
                 }
             }
             if (((player != null) && player.did_join) && (player.admin && Character.FindByUser(player.userID, out character)))
             {
                 Metabolism component = character.GetComponent <Metabolism>();
                 if (component.GetCalorieLevel() < 3000f)
                 {
                     component.AddCalories(3000f - component.GetCalorieLevel());
                 }
                 if (component.GetRadLevel() > 0f)
                 {
                     component.AddAntiRad(component.GetRadLevel());
                 }
             }
         }
         bool_1 = false;
         if ((Core.DatabaseType.Equals("MYSQL") && !bool_3) && (DateTime.Now.Subtract(dateTime_0).TotalMilliseconds > Core.MySQL_SyncInterval))
         {
             if (Core.MySQL_LogLevel > 2)
             {
                 Helper.LogSQL("Thread \"ProcessUsers\": Synchronizing server data from MySQL database", false);
             }
             SystemTimestamp restart = SystemTimestamp.Restart;
             bool_3 = true;
             Core.SQL_UpdateServer();
             if (Core.MySQL_Synchronize)
             {
                 Users.SQL_SynchronizeUsers();
             }
             if (Core.MySQL_Synchronize)
             {
                 Clans.SQL_SynchronizeClans();
             }
             dateTime_0 = DateTime.Now;
             bool_3     = false;
             restart.Stop();
             if (Core.MySQL_LogLevel > 2)
             {
                 Helper.LogSQL("Thread \"ProcessUsers\": Synchronized, is took " + restart.ElapsedSeconds.ToString("0.0000") + " second(s).", false);
             }
         }
     }
 }