コード例 #1
0
 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);
     }
 }
コード例 #2
0
 public static void Remove(ClanData clandata)
 {
     if (clandata != null)
     {
         Clans.Remove(clandata.ID);
     }
 }
コード例 #3
0
        public static bool MemberJoin(ClanData clanData, UserData userData)
        {
            if (((clanData == null) || (userData == null)) || clanData.Members.ContainsKey(userData))
            {
                return(false);
            }
            ClanMemberFlags flags = 0;

            if (clanData.LeaderID == userData.SteamID)
            {
                flags |= ClanMemberFlags.management | ClanMemberFlags.dismiss | ClanMemberFlags.invite;
            }
            if (Core.DatabaseType.Equals("MYSQL"))
            {
                MySQL.Update(string.Format(SQL_INSERT_MEMBER, userData.SteamID, clanData.ID, flags.ToString().Replace(" ", "")));
            }
            clanData.Members.Add(userData, flags);
            userData.Clan = clanData;
            NetUser player = NetUser.FindByUserID(userData.SteamID);

            if (player != null)
            {
                Broadcast.Message(player, Config.GetMessageClan("Command.Clan.PlayerJoined", clanData, null, userData), null, 0f);
            }
            return(true);
        }
コード例 #4
0
 public static bool AcceptsWar(ClanData declared_clan, ClanData accepted_clan)
 {
     if (((declared_clan != null) && (accepted_clan != null)) && (declared_clan != accepted_clan))
     {
         DateTime time = Helper.StringToTime(ClanWarAcceptedTime, DateTime.Now);
         if (time <= DateTime.Now)
         {
             time = time.AddDays(14.0);
         }
         if (!accepted_clan.Hostile.ContainsKey(declared_clan.ID))
         {
             accepted_clan.Hostile.Add(declared_clan.ID, time);
             Broadcast.MessageClan(accepted_clan, Config.GetMessageClan("Command.Clan.Hostile.Accepted", declared_clan, null, null));
             if (Core.DatabaseType.Equals("MYSQL"))
             {
                 DateTime time2 = accepted_clan.Hostile[declared_clan.ID];
                 MySQL.Update(string.Format(SQL_INSERT_CLAN_HOSTILE, accepted_clan.ID, declared_clan.ID, time2.ToString("yyyy-MM-dd HH:mm:ss")));
             }
         }
         if (!declared_clan.Hostile.ContainsKey(accepted_clan.ID))
         {
             declared_clan.Hostile.Add(accepted_clan.ID, time);
             Broadcast.MessageClan(declared_clan, Config.GetMessageClan("Command.Clan.Hostile.Declared", accepted_clan, null, null));
             if (Core.DatabaseType.Equals("MYSQL"))
             {
                 DateTime time3 = declared_clan.Hostile[accepted_clan.ID];
                 MySQL.Update(string.Format(SQL_INSERT_CLAN_HOSTILE, declared_clan.ID, accepted_clan.ID, time3.ToString("yyyy-MM-dd HH:mm:ss")));
             }
         }
         return(true);
     }
     return(false);
 }
コード例 #5
0
        public static bool MemberJoin(ClanData clanData, UserData userData)
        {
            bool result;

            if (clanData != null && userData != null && !clanData.Members.ContainsKey(userData))
            {
                ClanMemberFlags clanMemberFlags = (ClanMemberFlags)0;
                if (clanData.LeaderID == userData.SteamID)
                {
                    clanMemberFlags |= (ClanMemberFlags.invite | ClanMemberFlags.dismiss | ClanMemberFlags.management);
                }
                if (Core.DatabaseType.Equals("MYSQL"))
                {
                    MySQL.Update(string.Format(Clans.SQL_INSERT_MEMBER, userData.SteamID, clanData.ID, clanMemberFlags.ToString().Replace(" ", "")));
                }
                clanData.Members.Add(userData, clanMemberFlags);
                userData.Clan = clanData;
                NetUser netUser = NetUser.FindByUserID(userData.SteamID);
                if (netUser != null)
                {
                    Broadcast.Message(netUser, Config.GetMessageClan("Command.Clan.PlayerJoined", clanData, null, userData), null, 0f);
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
コード例 #6
0
        public static ClanData Find(string name)
        {
            ClanData result;

            if (!string.IsNullOrEmpty(name))
            {
                foreach (uint current in Clans.Database.Keys)
                {
                    if (Clans.Database[current].Name.Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        ClanData clanData = Clans.Database[current];
                        result = clanData;
                        return(result);
                    }
                    if (Clans.Database[current].Abbr.Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        ClanData clanData = Clans.Database[current];
                        result = clanData;
                        return(result);
                    }
                }
            }
            result = null;
            return(result);
        }
コード例 #7
0
        public static bool SaveAsDatabaseSQL()
        {
            bool result;

            if (!Core.DatabaseType.Equals("MYSQL"))
            {
                result = false;
            }
            else
            {
                using (Dictionary <uint, ClanData> .ValueCollection.Enumerator enumerator = Clans.Database.Values.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ClanData current = enumerator.Current;
                        Clans.SQL_Update(current, true);
                    }
                    goto IL_68;
                }
IL_5A:
                LibRust.Cycle();
                Thread.Sleep(100);
IL_68:
                if (MySQL.Queued)
                {
                    goto IL_5A;
                }
                result = true;
            }
            return(result);
        }
コード例 #8
0
 public static void MessageClan(ClanData clan, string text, [Optional, DefaultParameterValue(null)] NetUser AsUser)
 {
     try
     {
         if (!text.IsEmpty() && (clan != null))
         {
             string chatClanIcon = Core.ChatClanIcon;
             if (chatClanIcon == "")
             {
                 chatClanIcon = "<" + (clan.Abbr.IsEmpty() ? clan.Name : clan.Abbr) + ">";
             }
             if (AsUser != null)
             {
                 chatClanIcon = AsUser.displayName + Core.ChatDivider + chatClanIcon;
             }
             text = "chat.add " + Helper.QuoteSafe(chatClanIcon) + " " + Helper.QuoteSafe(Helper.GetChatTextColor(Core.ChatClanColor) + text.Trim(new char[] { '"' }));
             foreach (UserData data in clan.Members.Keys)
             {
                 PlayerClient client;
                 if (PlayerClient.FindByUserID(data.SteamID, out client))
                 {
                     ConsoleNetworker.SendClientCommand(client.netPlayer, text);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         Debug.Log("ERROR: " + exception.Message);
     }
 }
コード例 #9
0
        public static bool MemberLeave(ClanData clanData, UserData userData)
        {
            bool result;

            if (clanData != null && userData != null)
            {
                if (userData.Clan == clanData)
                {
                    if (Core.DatabaseType.Equals("MYSQL"))
                    {
                        MySQL.Update(string.Format(Clans.SQL_DELETE_MEMBER, userData.SteamID));
                    }
                    if (!clanData.Members.ContainsKey(userData))
                    {
                        result = false;
                        return(result);
                    }
                    clanData.Members.Remove(userData);
                    userData.Clan = null;
                    NetUser netUser = NetUser.FindByUserID(userData.SteamID);
                    if (netUser != null)
                    {
                        Broadcast.Message(netUser, Config.GetMessageClan("Command.Clan.PlayerLeaved", clanData, null, userData), null, 0f);
                    }
                    result = true;
                    return(result);
                }
            }
            result = false;
            return(result);
        }
コード例 #10
0
 public static void MessageClan(ClanData clan, string text)
 {
     try
     {
         if (!text.IsEmpty())
         {
             if (clan != null)
             {
                 string text2 = Core.ChatClanIcon;
                 if (text2 == "")
                 {
                     text2 = "<" + (clan.Abbr.IsEmpty() ? clan.Name : clan.Abbr) + ">";
                 }
                 text = "chat.add " + Helper.QuoteSafe(text2) + " " + Helper.QuoteSafe(Helper.GetChatTextColor(Core.ChatClanColor) + text.Trim(new char[]
                 {
                     '"'
                 }));
                 foreach (UserData current in clan.Members.Keys)
                 {
                     PlayerClient playerClient;
                     if (PlayerClient.FindByUserID(current.SteamID, out playerClient))
                     {
                         ConsoleNetworker.SendClientCommand(playerClient.netPlayer, text);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Debug.Log("ERROR: " + ex.Message);
     }
 }
コード例 #11
0
 public static bool DeclineWar(ClanData declared_clan, ClanData declined_clan)
 {
     if (((declared_clan != null) && (declined_clan != null)) && (declared_clan != declined_clan))
     {
         string[] strArray  = Config.GetMessagesClan("Command.Clan.Hostile.DeclinedTo", declared_clan, null, null);
         string[] strArray2 = Config.GetMessagesClan("Command.Clan.Hostile.DeclinedFrom", declined_clan, null, null);
         foreach (string str in strArray)
         {
             if (!str.Contains("%CLAN."))
             {
                 Broadcast.MessageClan(declined_clan, str);
             }
         }
         foreach (string str2 in strArray2)
         {
             if (!str2.Contains("%CLAN."))
             {
                 Broadcast.MessageClan(declared_clan, str2);
             }
         }
         ulong num  = (declined_clan.Balance * ClanWarDeclaredGainPercent) / ((ulong)100L);
         ulong num2 = (declined_clan.Balance * ClanWarDeclinedLostPercent) / ((ulong)100L);
         ulong num3 = (declined_clan.Experience * ClanWarDeclaredGainPercent) / ((ulong)100L);
         ulong num4 = (declined_clan.Experience * ClanWarDeclinedLostPercent) / ((ulong)100L);
         declared_clan.Balance    += num;
         declared_clan.Experience += num3;
         declined_clan.Balance    -= num2;
         declined_clan.Experience -= num4;
         declined_clan.Penalty     = Helper.StringToTime(ClanWarDeclinedPenalty, DateTime.Now);
         return(true);
     }
     return(false);
 }
コード例 #12
0
        public static void Remove(string name)
        {
            ClanData clanData = Clans.Find(name);

            if (clanData != null)
            {
                Clans.Remove(clanData);
            }
        }
コード例 #13
0
        public static void TransferDecline(ClanData clanData, UserData userData)
        {
            NetUser netUser = NetUser.FindByUserID(clanData.LeaderID);

            if (netUser != null)
            {
                Broadcast.MessageClan(netUser, clanData, Config.GetMessageClan("Command.Clan.Transfer.QueryAnswerN", clanData, null, userData));
            }
        }
コード例 #14
0
        public static void TransferAccept(ClanData clanData, UserData userData)
        {
            NetUser netUser = NetUser.FindByUserID(clanData.LeaderID);

            if (netUser != null)
            {
                Broadcast.MessageClan(netUser, clanData, Config.GetMessageClan("Command.Clan.Transfer.QueryAnswerY", clanData, null, userData));
            }
            clanData.LeaderID          = userData.SteamID;
            clanData.Members[userData] = (ClanMemberFlags.invite | ClanMemberFlags.dismiss | ClanMemberFlags.management);
            Broadcast.MessageClan(clanData, Config.GetMessageClan("Command.Clan.Transfer.Success", clanData, null, userData));
        }
コード例 #15
0
        public static ClanData Create(string name, ulong leader_id, DateTime created)
        {
            ClanData data = new ClanData(Helper.NewSerial, name, "", leader_id, created);

            if (data == null)
            {
                return(null);
            }
            Database.Add(data.ID, data);
            if (Core.DatabaseType.Equals("MYSQL"))
            {
                SQL_Update(data, false);
            }
            return(data);
        }
コード例 #16
0
        public static bool DeclineWar(ClanData declared_clan, ClanData declined_clan)
        {
            bool result;

            if (declared_clan != null && declined_clan != null)
            {
                if (declared_clan != declined_clan)
                {
                    string[] messagesClan  = Config.GetMessagesClan("Command.Clan.Hostile.DeclinedTo", declared_clan, null, null);
                    string[] messagesClan2 = Config.GetMessagesClan("Command.Clan.Hostile.DeclinedFrom", declined_clan, null, null);
                    string[] array         = messagesClan;
                    for (int i = 0; i < array.Length; i++)
                    {
                        string text = array[i];
                        if (!text.Contains("%CLAN."))
                        {
                            Broadcast.MessageClan(declined_clan, text);
                        }
                    }
                    string[] array2 = messagesClan2;
                    for (int j = 0; j < array2.Length; j++)
                    {
                        string text2 = array2[j];
                        if (!text2.Contains("%CLAN."))
                        {
                            Broadcast.MessageClan(declared_clan, text2);
                        }
                    }
                    ulong num  = declined_clan.Balance * (ulong)Clans.ClanWarDeclaredGainPercent / 100uL;
                    ulong num2 = declined_clan.Balance * (ulong)Clans.ClanWarDeclinedLostPercent / 100uL;
                    ulong num3 = declined_clan.Experience * (ulong)Clans.ClanWarDeclaredGainPercent / 100uL;
                    ulong num4 = declined_clan.Experience * (ulong)Clans.ClanWarDeclinedLostPercent / 100uL;
                    declared_clan.Balance    += num;
                    declared_clan.Experience += num3;
                    declined_clan.Balance    -= num2;
                    declined_clan.Experience -= num4;
                    declined_clan.Penalty     = Helper.StringToTime(Clans.ClanWarDeclinedPenalty, DateTime.Now);
                    result = true;
                    return(result);
                }
            }
            result = false;
            return(result);
        }
コード例 #17
0
 public static void SQL_Update(ClanData clandata, bool updateHostile = false)
 {
     MySQL.Update(string.Format(Clans.SQL_INSERT_CLAN, new object[]
     {
         clandata.ID,
         clandata.Created.ToString("yyyy-MM-dd HH:mm:ss"),
         clandata.Name,
         clandata.Abbr,
         clandata.LeaderID,
         clandata.Flags.ToString().Replace(" ", ""),
         clandata.Balance,
         clandata.Tax,
         clandata.Level.Id,
         clandata.Experience,
         string.Concat(new object[]
         {
             clandata.Location.x,
             ",",
             clandata.Location.y,
             ",",
             clandata.Location.z
         }),
         clandata.MOTD,
         clandata.Penalty.ToString("yyyy-MM-dd HH:mm:ss")
     }));
     foreach (UserData current in clandata.Members.Keys)
     {
         MySQL.Update(string.Format(Clans.SQL_INSERT_MEMBER, current.SteamID, clandata.ID, clandata.Members[current].ToString().Replace(" ", "")));
     }
     if (updateHostile)
     {
         foreach (uint current2 in clandata.Hostile.Keys)
         {
             MySQL.Update(string.Format(Clans.SQL_INSERT_CLAN_HOSTILE, clandata.ID, current2, clandata.Hostile[current2].ToString("yyyy-MM-dd HH:mm:ss")));
         }
     }
     if (!Clans.dictionary_0.ContainsKey(clandata.ID))
     {
         Clans.dictionary_0.Add(clandata.ID, 0uL);
     }
     Clans.dictionary_0[clandata.ID] = Clans.Database[clandata.ID].Hash;
 }
コード例 #18
0
        public static ClanData Create(string name, ulong leader_id, DateTime created)
        {
            ClanData clanData = new ClanData(Helper.NewSerial, name, "", leader_id, created);
            ClanData result;

            if (clanData == null)
            {
                result = null;
            }
            else
            {
                Clans.Database.Add(clanData.ID, clanData);
                if (Core.DatabaseType.Equals("MYSQL"))
                {
                    Clans.SQL_Update(clanData, false);
                }
                result = clanData;
            }
            return(result);
        }
コード例 #19
0
 public static void SQL_Update(ClanData clandata, [Optional, DefaultParameterValue(false)] bool updateHostile)
 {
     MySQL.Update(string.Format(SQL_INSERT_CLAN, new object[] { clandata.ID, clandata.Created.ToString("yyyy-MM-dd HH:mm:ss"), clandata.Name, clandata.Abbr, clandata.LeaderID, clandata.Flags.ToString().Replace(" ", ""), clandata.Balance, clandata.Tax, clandata.Level.Id, clandata.Experience, string.Concat(new object[] { clandata.Location.x, ",", clandata.Location.y, ",", clandata.Location.z }), clandata.MOTD, clandata.Penalty.ToString("yyyy-MM-dd HH:mm:ss") }));
     foreach (UserData data in clandata.Members.Keys)
     {
         MySQL.Update(string.Format(SQL_INSERT_MEMBER, data.SteamID, clandata.ID, clandata.Members[data].ToString().Replace(" ", "")));
     }
     if (updateHostile)
     {
         foreach (uint num in clandata.Hostile.Keys)
         {
             DateTime time = clandata.Hostile[num];
             MySQL.Update(string.Format(SQL_INSERT_CLAN_HOSTILE, clandata.ID, num, time.ToString("yyyy-MM-dd HH:mm:ss")));
         }
     }
     if (!dictionary_0.ContainsKey(clandata.ID))
     {
         dictionary_0.Add(clandata.ID, 0L);
     }
     dictionary_0[clandata.ID] = Database[clandata.ID].Hash;
 }
コード例 #20
0
        public static bool AcceptsWar(ClanData declared_clan, ClanData accepted_clan)
        {
            bool result;

            if (declared_clan != null && accepted_clan != null)
            {
                if (declared_clan != accepted_clan)
                {
                    DateTime dateTime = Helper.StringToTime(Clans.ClanWarAcceptedTime, DateTime.Now);
                    if (dateTime <= DateTime.Now)
                    {
                        dateTime = dateTime.AddDays(14.0);
                    }
                    if (!accepted_clan.Hostile.ContainsKey(declared_clan.ID))
                    {
                        accepted_clan.Hostile.Add(declared_clan.ID, dateTime);
                        Broadcast.MessageClan(accepted_clan, Config.GetMessageClan("Command.Clan.Hostile.Accepted", declared_clan, null, null));
                        if (Core.DatabaseType.Equals("MYSQL"))
                        {
                            MySQL.Update(string.Format(Clans.SQL_INSERT_CLAN_HOSTILE, accepted_clan.ID, declared_clan.ID, accepted_clan.Hostile[declared_clan.ID].ToString("yyyy-MM-dd HH:mm:ss")));
                        }
                    }
                    if (!declared_clan.Hostile.ContainsKey(accepted_clan.ID))
                    {
                        declared_clan.Hostile.Add(accepted_clan.ID, dateTime);
                        Broadcast.MessageClan(declared_clan, Config.GetMessageClan("Command.Clan.Hostile.Declared", accepted_clan, null, null));
                        if (Core.DatabaseType.Equals("MYSQL"))
                        {
                            MySQL.Update(string.Format(Clans.SQL_INSERT_CLAN_HOSTILE, declared_clan.ID, accepted_clan.ID, declared_clan.Hostile[accepted_clan.ID].ToString("yyyy-MM-dd HH:mm:ss")));
                        }
                    }
                    result = true;
                    return(result);
                }
            }
            result = false;
            return(result);
        }
コード例 #21
0
        public static bool MemberLeave(ClanData clanData, UserData userData)
        {
            if (((clanData == null) || (userData == null)) || (userData.Clan != clanData))
            {
                return(false);
            }
            if (Core.DatabaseType.Equals("MYSQL"))
            {
                MySQL.Update(string.Format(SQL_DELETE_MEMBER, userData.SteamID));
            }
            if (!clanData.Members.ContainsKey(userData))
            {
                return(false);
            }
            clanData.Members.Remove(userData);
            userData.Clan = null;
            NetUser player = NetUser.FindByUserID(userData.SteamID);

            if (player != null)
            {
                Broadcast.Message(player, Config.GetMessageClan("Command.Clan.PlayerLeaved", clanData, null, userData), null, 0f);
            }
            return(true);
        }
コード例 #22
0
        public static void HurtKilled(DamageEvent damage)
        {
            ulong        num       = 0uL;
            string       text      = "";
            ulong        num2      = 0uL;
            string       text2     = "";
            PlayerClient client    = damage.victim.client;
            PlayerClient client2   = damage.attacker.client;
            bool         flag      = !(damage.victim.idMain is Character);
            bool         flag2     = !(damage.attacker.idMain is Character);
            UserData     userData  = (client != null) ? Users.GetBySteamID(client.userID) : null;
            UserData     userData2 = (client2 != null) ? Users.GetBySteamID(client2.userID) : null;

            if (userData == null)
            {
            }
            ClanData clanData = (userData2 != null) ? userData2.Clan : null;

            if (!flag2 || !(client2 == null))
            {
                if (client2 != null)
                {
                    text2 = damage.attacker.client.netUser.displayName;
                }
                else
                {
                    text2 = Helper.NiceName(damage.attacker.character.name);
                    Config.Get("NAMES." + ((userData == null) ? Core.Languages[0] : userData.Language), text2, ref text2, true);
                }
                if (flag)
                {
                    if (!(damage.victim.idMain is SleepingAvatar) || !Economy.FeeSleeper)
                    {
                        return;
                    }
                    SleepingAvatar sleepingAvatar = damage.victim.idMain as SleepingAvatar;
                    if (sleepingAvatar == null)
                    {
                        return;
                    }
                    UserData bySteamID = Users.GetBySteamID(sleepingAvatar.ownerID);
                    if (bySteamID == null)
                    {
                        return;
                    }
                    ulong balance = Economy.GetBalance(bySteamID.SteamID);
                    text = bySteamID.Username;
                    if (Economy.FeeMurder)
                    {
                        num = (ulong)Math.Abs(balance * Economy.FeeMurderPercent / 100f);
                    }
                    if (Economy.PayMurder)
                    {
                        num2 = (ulong)Math.Abs(balance * Economy.PayMurderPercent / 100f);
                    }
                    if (num2 > 0uL && Clans.Enabled && clanData != null)
                    {
                        if (clanData.Level.BonusMembersPayMurder > 0u)
                        {
                            num2 += num2 * (ulong)clanData.Level.BonusMembersPayMurder / 100uL;
                        }
                        if (clanData.Tax > 0u)
                        {
                            ulong num3 = num2 * (ulong)clanData.Tax / 100uL;
                            clanData.Balance += num3;
                            num2             -= num3;
                        }
                    }
                    if (num2 > 0uL)
                    {
                        Economy.BalanceAdd(client2.userID, num2);
                    }
                    if (num > 0uL)
                    {
                        Economy.BalanceSub(bySteamID.SteamID, num);
                    }
                }
                else if (client != null)
                {
                    text = damage.victim.client.netUser.displayName;
                    ulong balance2 = Economy.GetBalance(client.userID);
                    if (client2 == null)
                    {
                        if (Economy.FeeDeath)
                        {
                            num = (ulong)Math.Abs(balance2 * Economy.FeeDeathPercent / 100f);
                        }
                    }
                    else if (!(client2 == client) && !flag2)
                    {
                        if (client2 != client && !flag2)
                        {
                            Economy.Get(client2.userID).PlayersKilled++;
                            if (Economy.FeeMurder)
                            {
                                num = (ulong)Math.Abs(balance2 * Economy.FeeMurderPercent / 100f);
                            }
                            if (Economy.PayMurder)
                            {
                                num2 = (ulong)Math.Abs(balance2 * Economy.PayMurderPercent / 100f);
                            }
                        }
                    }
                    else if (Economy.FeeSuicide)
                    {
                        num = (ulong)Math.Abs(balance2 * Economy.FeeSuicidePercent / 100f);
                    }
                    if (num2 > 0uL && Clans.Enabled && clanData != null)
                    {
                        if (clanData.Level.BonusMembersPayMurder > 0u)
                        {
                            num2 += num2 * (ulong)clanData.Level.BonusMembersPayMurder / 100uL;
                        }
                        if (clanData.Tax > 0u)
                        {
                            ulong num4 = num2 * (ulong)clanData.Tax / 100uL;
                            clanData.Balance += num4;
                            num2             -= num4;
                        }
                    }
                    if (num2 > 0uL)
                    {
                        Economy.BalanceAdd(client2.userID, num2);
                    }
                    if (num > 0uL)
                    {
                        Economy.BalanceSub(client.userID, num);
                    }
                    Economy.Get(client.userID).Deaths++;
                }
                else if (client2 != null)
                {
                    text = Helper.NiceName(damage.victim.character.name);
                    if (text.Equals("Chicken", StringComparison.OrdinalIgnoreCase))
                    {
                        if (Economy.CostChicken != 0uL)
                        {
                            num2 = Economy.CostChicken;
                        }
                        Economy.Get(client2.userID).AnimalsKilled++;
                    }
                    else if (text.Equals("Rabbit", StringComparison.OrdinalIgnoreCase))
                    {
                        if (Economy.CostRabbit != 0uL)
                        {
                            num2 = Economy.CostRabbit;
                        }
                        Economy.Get(client2.userID).AnimalsKilled++;
                    }
                    else if (text.Equals("Boar", StringComparison.OrdinalIgnoreCase))
                    {
                        if (Economy.CostBoar != 0uL)
                        {
                            num2 = Economy.CostBoar;
                        }
                        Economy.Get(client2.userID).AnimalsKilled++;
                    }
                    else if (text.Equals("Stag", StringComparison.OrdinalIgnoreCase))
                    {
                        if (Economy.CostStag != 0uL)
                        {
                            num2 = Economy.CostStag;
                        }
                        Economy.Get(client2.userID).AnimalsKilled++;
                    }
                    else if (text.Equals("Wolf", StringComparison.OrdinalIgnoreCase))
                    {
                        if (Economy.CostWolf != 0uL)
                        {
                            num2 = Economy.CostWolf;
                        }
                        Economy.Get(client2.userID).AnimalsKilled++;
                    }
                    else if (text.Equals("Bear", StringComparison.OrdinalIgnoreCase))
                    {
                        if (Economy.CostBear != 0uL)
                        {
                            num2 = Economy.CostBear;
                        }
                        Economy.Get(client2.userID).AnimalsKilled++;
                    }
                    else if (text.Equals("Mutant Wolf", StringComparison.OrdinalIgnoreCase))
                    {
                        if (Economy.CostMutantWolf != 0uL)
                        {
                            num2 = Economy.CostMutantWolf;
                        }
                        Economy.Get(client2.userID).MutantsKilled++;
                    }
                    else if (text.Equals("Mutant Bear", StringComparison.OrdinalIgnoreCase))
                    {
                        if (Economy.CostMutantBear != 0uL)
                        {
                            num2 = Economy.CostMutantBear;
                        }
                        Economy.Get(client2.userID).MutantsKilled++;
                    }
                    else
                    {
                        ConsoleSystem.LogWarning("[WARNING] Economy: Creature '" + text + "' not have cost of death.");
                    }
                    Config.Get("NAMES." + ((userData2 == null) ? Core.Languages[0] : userData2.Language), text, ref text, true);
                    if (num2 > 0uL && Clans.Enabled && clanData != null)
                    {
                        if (clanData.Level.BonusMembersPayMurder > 0u)
                        {
                            num2 += num2 * (ulong)clanData.Level.BonusMembersPayMurder / 100uL;
                        }
                        if (clanData.Tax > 0u)
                        {
                            ulong num5 = num2 * (ulong)clanData.Tax / 100uL;
                            clanData.Balance += num5;
                            num2             -= num5;
                        }
                    }
                    if (num2 > 0uL)
                    {
                        Economy.BalanceAdd(client2.userID, num2);
                    }
                }
                if (client2 != null && num2 > 0uL)
                {
                    string text3 = Config.GetMessage("Economy.PlayerDeath.Pay", client2.netUser, null);
                    if (flag)
                    {
                        text3 = Config.GetMessage("Economy.SleeperDeath.Pay", client2.netUser, null);
                    }
                    text3 = text3.Replace("%DEATHPAY%", num2.ToString("N0") + Economy.CurrencySign);
                    text3 = text3.Replace("%VICTIM%", text);
                    Broadcast.Message(client2.netPlayer, text3, null, 0f);
                }
                if (client != null && num > 0uL)
                {
                    string text4 = Config.GetMessage("Economy.PlayerDeath.Fee", client.netUser, null);
                    if (client2 == client || flag2)
                    {
                        text4 = Config.GetMessage("Economy.PlayerSuicide.Fee", client.netUser, null);
                    }
                    text4 = text4.Replace("%DEATHFEE%", num.ToString("N0") + Economy.CurrencySign);
                    text4 = text4.Replace("%KILLER%", text2);
                    text4 = text4.Replace("%VICTIM%", text);
                    Broadcast.Message(client.netPlayer, text4, null, 0f);
                }
            }
        }
コード例 #23
0
        public static void HurtKilled(DamageEvent damage)
        {
            ulong        amount      = 0L;
            string       key         = "";
            ulong        costChicken = 0L;
            string       displayName = "";
            PlayerClient client      = damage.victim.client;
            PlayerClient client2     = damage.attacker.client;
            bool         flag        = !(damage.victim.idMain is Character);
            bool         flag2       = !(damage.attacker.idMain is Character);
            UserData     data        = (client != null) ? Users.GetBySteamID(client.userID) : null;
            UserData     data2       = (client2 != null) ? Users.GetBySteamID(client2.userID) : null;

            if (data == null)
            {
            }
            ClanData data3 = (data2 != null) ? data2.Clan : null;

            if (!flag2 || (client2 != null))
            {
                if (client2 != null)
                {
                    displayName = damage.attacker.client.netUser.displayName;
                }
                else
                {
                    displayName = Helper.NiceName(damage.attacker.character.name);
                    Config.Get("NAMES." + ((data == null) ? Core.Languages[0] : data.Language), displayName, ref displayName, true);
                }
                if (flag)
                {
                    if (!(damage.victim.idMain is SleepingAvatar) || !FeeSleeper)
                    {
                        return;
                    }
                    SleepingAvatar idMain = damage.victim.idMain as SleepingAvatar;
                    if (idMain == null)
                    {
                        return;
                    }
                    UserData bySteamID = Users.GetBySteamID(idMain.ownerID);
                    if (bySteamID == null)
                    {
                        return;
                    }
                    ulong balance = GetBalance(bySteamID.SteamID);
                    key = bySteamID.Username;
                    if (FeeMurder)
                    {
                        amount = (ulong)Math.Abs((float)((balance * FeeMurderPercent) / 100f));
                    }
                    if (PayMurder)
                    {
                        costChicken = (ulong)Math.Abs((float)((balance * PayMurderPercent) / 100f));
                    }
                    if (((costChicken > 0L) && Clans.Enabled) && (data3 != null))
                    {
                        if (data3.Level.BonusMembersPayMurder > 0)
                        {
                            costChicken += (costChicken * data3.Level.BonusMembersPayMurder) / ((ulong)100L);
                        }
                        if (data3.Tax > 0)
                        {
                            ulong num4 = (costChicken * data3.Tax) / ((ulong)100L);
                            data3.Balance += num4;
                            costChicken   -= num4;
                        }
                    }
                    if (costChicken > 0L)
                    {
                        BalanceAdd(client2.userID, costChicken);
                    }
                    if (amount > 0L)
                    {
                        BalanceSub(bySteamID.SteamID, amount);
                    }
                }
                else if (client != null)
                {
                    key = damage.victim.client.netUser.displayName;
                    ulong num5 = GetBalance(client.userID);
                    if (client2 == null)
                    {
                        if (FeeDeath)
                        {
                            amount = (ulong)Math.Abs((float)((num5 * FeeDeathPercent) / 100f));
                        }
                    }
                    else if ((client2 != client) && !flag2)
                    {
                        if ((client2 != client) && !flag2)
                        {
                            UserEconomy economy1 = Get(client2.userID);
                            economy1.PlayersKilled++;
                            if (FeeMurder)
                            {
                                amount = (ulong)Math.Abs((float)((num5 * FeeMurderPercent) / 100f));
                            }
                            if (PayMurder)
                            {
                                costChicken = (ulong)Math.Abs((float)((num5 * PayMurderPercent) / 100f));
                            }
                        }
                    }
                    else if (FeeSuicide)
                    {
                        amount = (ulong)Math.Abs((float)((num5 * FeeSuicidePercent) / 100f));
                    }
                    if (((costChicken > 0L) && Clans.Enabled) && (data3 != null))
                    {
                        if (data3.Level.BonusMembersPayMurder > 0)
                        {
                            costChicken += (costChicken * data3.Level.BonusMembersPayMurder) / ((ulong)100L);
                        }
                        if (data3.Tax > 0)
                        {
                            ulong num6 = (costChicken * data3.Tax) / ((ulong)100L);
                            data3.Balance += num6;
                            costChicken   -= num6;
                        }
                    }
                    if (costChicken > 0L)
                    {
                        BalanceAdd(client2.userID, costChicken);
                    }
                    if (amount > 0L)
                    {
                        BalanceSub(client.userID, amount);
                    }
                    UserEconomy economy2 = Get(client.userID);
                    economy2.Deaths++;
                }
                else if (client2 != null)
                {
                    key = Helper.NiceName(damage.victim.character.name);
                    if (key.Equals("Chicken", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostChicken != 0L)
                        {
                            costChicken = CostChicken;
                        }
                        UserEconomy economy3 = Get(client2.userID);
                        economy3.AnimalsKilled++;
                    }
                    else if (key.Equals("Rabbit", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostRabbit != 0L)
                        {
                            costChicken = CostRabbit;
                        }
                        UserEconomy economy4 = Get(client2.userID);
                        economy4.AnimalsKilled++;
                    }
                    else if (key.Equals("Boar", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostBoar != 0L)
                        {
                            costChicken = CostBoar;
                        }
                        UserEconomy economy5 = Get(client2.userID);
                        economy5.AnimalsKilled++;
                    }
                    else if (key.Equals("Stag", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostStag != 0L)
                        {
                            costChicken = CostStag;
                        }
                        UserEconomy economy6 = Get(client2.userID);
                        economy6.AnimalsKilled++;
                    }
                    else if (key.Equals("Wolf", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostWolf != 0L)
                        {
                            costChicken = CostWolf;
                        }
                        UserEconomy economy7 = Get(client2.userID);
                        economy7.AnimalsKilled++;
                    }
                    else if (key.Equals("Bear", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostBear != 0L)
                        {
                            costChicken = CostBear;
                        }
                        UserEconomy economy8 = Get(client2.userID);
                        economy8.AnimalsKilled++;
                    }
                    else if (key.Equals("Mutant Wolf", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostMutantWolf != 0L)
                        {
                            costChicken = CostMutantWolf;
                        }
                        UserEconomy economy9 = Get(client2.userID);
                        economy9.MutantsKilled++;
                    }
                    else if (key.Equals("Mutant Bear", StringComparison.OrdinalIgnoreCase))
                    {
                        if (CostMutantBear != 0L)
                        {
                            costChicken = CostMutantBear;
                        }
                        UserEconomy economy10 = Get(client2.userID);
                        economy10.MutantsKilled++;
                    }
                    else
                    {
                        ConsoleSystem.LogWarning("[WARNING] Economy: Creature '" + key + "' not have cost of death.");
                    }
                    Config.Get("NAMES." + ((data2 == null) ? Core.Languages[0] : data2.Language), key, ref key, true);
                    if (((costChicken > 0L) && Clans.Enabled) && (data3 != null))
                    {
                        if (data3.Level.BonusMembersPayMurder > 0)
                        {
                            costChicken += (costChicken * data3.Level.BonusMembersPayMurder) / ((ulong)100L);
                        }
                        if (data3.Tax > 0)
                        {
                            ulong num7 = (costChicken * data3.Tax) / ((ulong)100L);
                            data3.Balance += num7;
                            costChicken   -= num7;
                        }
                    }
                    if (costChicken > 0L)
                    {
                        BalanceAdd(client2.userID, costChicken);
                    }
                }
                if ((client2 != null) && (costChicken > 0L))
                {
                    string text = Config.GetMessage("Economy.PlayerDeath.Pay", client2.netUser, null);
                    if (flag)
                    {
                        text = Config.GetMessage("Economy.SleeperDeath.Pay", client2.netUser, null);
                    }
                    text = text.Replace("%DEATHPAY%", costChicken.ToString("N0") + CurrencySign).Replace("%VICTIM%", key);
                    Broadcast.Message(client2.netPlayer, text, null, 0f);
                }
                if ((client != null) && (amount > 0L))
                {
                    string str4;
                    str4 = str4 = Config.GetMessage("Economy.PlayerDeath.Fee", client.netUser, null);
                    if ((client2 == client) || flag2)
                    {
                        str4 = Config.GetMessage("Economy.PlayerSuicide.Fee", client.netUser, null);
                    }
                    str4 = str4.Replace("%DEATHFEE%", amount.ToString("N0") + CurrencySign).Replace("%KILLER%", displayName).Replace("%VICTIM%", key);
                    Broadcast.Message(client.netPlayer, str4, null, 0f);
                }
            }
        }
コード例 #24
0
 public static void Teleport_ClanWarp(object obj, NetUser netUser, string command, ClanData clan)
 {
     if (obj != null && obj is EventTimer)
     {
         (obj as EventTimer).Dispose();
     }
     Helper.TeleportTo(netUser, clan.Location);
     if (clan.Level.WarpCountdown > 0u)
     {
         Users.CountdownAdd(netUser.userID, new Countdown(command, clan.Level.WarpCountdown));
     }
     Broadcast.Notice(netUser, "☢", Config.GetMessage("Command.Clan.Warp.Warped", netUser, null), 5f);
 }
コード例 #25
0
        public static EventTimer TimeEvent_ClanWarp(NetUser netUser, string Command, double time, ClanData clan)
        {
            Events.Class37 @class = new Events.Class37();
            @class.netUser_0  = netUser;
            @class.string_0   = Command;
            @class.clanData_0 = clan;
            EventTimer result;

            if (time <= 0.0)
            {
                Events.Teleport_ClanWarp(null, @class.netUser_0, @class.string_0, @class.clanData_0);
                result = null;
            }
            else
            {
                EventTimer eventTimer = new EventTimer
                {
                    Interval  = time * 1000.0,
                    AutoReset = false
                };
                eventTimer.Elapsed += new ElapsedEventHandler(@class.method_0);
                eventTimer.Sender   = @class.netUser_0;
                eventTimer.Command  = @class.string_0;
                eventTimer.Start();
                result = eventTimer;
            }
            return(result);
        }
コード例 #26
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;
     }
 }
コード例 #27
0
        public static EventTimer TimeEvent_ClanWarp(NetUser netUser, string Command, double time, ClanData clan)
        {
            Class37 class2 = new Class37 {
                netUser_0  = netUser,
                string_0   = Command,
                clanData_0 = clan
            };

            if (time <= 0.0)
            {
                Teleport_ClanWarp(null, class2.netUser_0, class2.string_0, class2.clanData_0);
                return(null);
            }
            EventTimer timer = new EventTimer {
                Interval  = time * 1000.0,
                AutoReset = false
            };

            timer.Elapsed += new ElapsedEventHandler(class2.method_0);
            timer.Sender   = class2.netUser_0;
            timer.Command  = class2.string_0;
            timer.Start();
            return(timer);
        }
コード例 #28
0
        public static bool LoadAsTextFile()
        {
            Clans.Loaded = 0;
            bool result;

            if (!File.Exists(Clans.SaveFilePath))
            {
                result = false;
            }
            else
            {
                string text = File.ReadAllText(Clans.SaveFilePath);
                if (string.IsNullOrEmpty(text))
                {
                    result = false;
                }
                else
                {
                    string[] array = text.Split(new string[]
                    {
                        "\r\n",
                        "\n"
                    }, StringSplitOptions.RemoveEmptyEntries);
                    string   text2    = null;
                    Version  v        = null;
                    ClanData clanData = null;
                    string[] array2   = array;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        string text3 = array2[i];
                        Predicate <ClanLevel> predicate = null;
                        Clans.Class0          @class    = new Clans.Class0();
                        if (text3.StartsWith("[") && text3.EndsWith("]"))
                        {
                            clanData = null;
                            if (!(v == null) && text2 != null)
                            {
                                uint num = text3.Substring(1, text3.Length - 2).ToUInt32();
                                if (num != 0u)
                                {
                                    if (Clans.Database.ContainsKey(num))
                                    {
                                        clanData = Clans.Database[num];
                                    }
                                    else
                                    {
                                        num      = Helper.NewSerial;
                                        clanData = new ClanData(num, null, null, 0uL, default(DateTime));
                                        Clans.Database.Add(num, clanData);
                                        Clans.Loaded++;
                                    }
                                }
                            }
                        }
                        else
                        {
                            @class.string_0 = text3.Split(new char[]
                            {
                                '='
                            });
                            if (@class.string_0.Length >= 2)
                            {
                                if (clanData == null)
                                {
                                    if (@class.string_0[0].Equals("VERSION", StringComparison.OrdinalIgnoreCase))
                                    {
                                        v = new Version(@class.string_0[1]);
                                    }
                                    if (@class.string_0[0].Equals("TITLE", StringComparison.OrdinalIgnoreCase))
                                    {
                                        text2 = @class.string_0[1];
                                    }
                                    if (@class.string_0[0].Equals("TIME", StringComparison.OrdinalIgnoreCase))
                                    {
                                        Convert.ToUInt32(@class.string_0[1]);
                                    }
                                }
                                else
                                {
                                    string text4 = @class.string_0[0].ToUpper();
                                    switch (text4)
                                    {
                                    case "NAME":
                                        clanData.Name = @class.string_0[1].Trim();
                                        break;

                                    case "ABBREV":
                                        clanData.Abbr = @class.string_0[1].Trim();
                                        break;

                                    case "LEADER":
                                        clanData.LeaderID = ulong.Parse(@class.string_0[1]);
                                        break;

                                    case "CREATED":
                                        clanData.Created = DateTime.Parse(@class.string_0[1]);
                                        break;

                                    case "FLAGS":
                                        clanData.Flags = @class.string_0[1].ToEnum <ClanFlags>();
                                        break;

                                    case "BALANCE":
                                        clanData.Balance = ulong.Parse(@class.string_0[1]);
                                        break;

                                    case "TAX":
                                        clanData.Tax = uint.Parse(@class.string_0[1]);
                                        break;

                                    case "LEVEL":
                                    {
                                        ClanData         clanData2 = clanData;
                                        List <ClanLevel> levels    = Clans.Levels;
                                        if (predicate == null)
                                        {
                                            predicate = new Predicate <ClanLevel>(@class.method_0);
                                        }
                                        clanData2.SetLevel(levels.Find(predicate));
                                        break;
                                    }

                                    case "EXPERIENCE":
                                        clanData.Experience = ulong.Parse(@class.string_0[1]);
                                        break;

                                    case "LOCATION":
                                        @class.string_0 = @class.string_0[1].Split(new char[]
                                        {
                                            ','
                                        });
                                        if (@class.string_0.Length > 0)
                                        {
                                            float.TryParse(@class.string_0[0].Trim(), out clanData.Location.x);
                                        }
                                        if (@class.string_0.Length > 1)
                                        {
                                            float.TryParse(@class.string_0[1].Trim(), out clanData.Location.y);
                                        }
                                        if (@class.string_0.Length > 2)
                                        {
                                            float.TryParse(@class.string_0[2].Trim(), out clanData.Location.z);
                                        }
                                        break;

                                    case "MOTD":
                                        clanData.MOTD = @class.string_0[1].Trim();
                                        break;

                                    case "PENALTY":
                                        clanData.Penalty = DateTime.Parse(@class.string_0[1]);
                                        break;

                                    case "HOSTILE":
                                        @class.string_0 = @class.string_0[1].Split(new char[]
                                        {
                                            ','
                                        });
                                        if (@class.string_0.Length >= 2)
                                        {
                                            clanData.Hostile.Add(@class.string_0[0].ToUInt32(), DateTime.Parse(@class.string_0[1]));
                                        }
                                        break;

                                    case "MEMBER":
                                    {
                                        @class.string_0 = @class.string_0[1].Split(new char[]
                                            {
                                                ','
                                            });
                                        ulong    steam_id  = ulong.Parse(@class.string_0[0]);
                                        UserData bySteamID = Users.GetBySteamID(steam_id);
                                        if (bySteamID != null)
                                        {
                                            for (int j = 1; j < @class.string_0.Length; j++)
                                            {
                                                @class.string_0[j - 1] = @class.string_0[j];
                                            }
                                            Array.Resize <string>(ref @class.string_0, @class.string_0.Length - 1);
                                            ClanMemberFlags value = string.Join(",", @class.string_0).ToEnum <ClanMemberFlags>();
                                            bySteamID.Clan = clanData;
                                            clanData.Members.Add(bySteamID, value);
                                        }
                                        break;
                                    }
                                    }
                                }
                            }
                        }
                    }
                    result = true;
                }
            }
            return(result);
        }
コード例 #29
0
        public static bool LoadAsDatabaseSQL()
        {
            Predicate <ClanLevel> predicate = null;

            Clans.Class1 @class = new Clans.Class1();
            Clans.Loaded = 0;
            ClanData clanData = null;
            UserData userData = null;

            @class.row_0 = null;
            MySQL.Result result  = MySQL.Query("SELECT * FROM `db_clans`;", false);
            MySQL.Result result2 = MySQL.Query("SELECT * FROM `db_clans_members`;", false);
            MySQL.Result result3 = MySQL.Query("SELECT * FROM `db_clans_hostile`;", false);
            if (result2 != null && result != null)
            {
                foreach (MySQL.Row current in result2.Row)
                {
                    Clans.Class2 class2 = new Clans.Class2();
                    class2.class1_0 = @class;
                    ulong asUInt = current.Get("user_id").AsUInt64;
                    class2.uint_0 = current.Get("clan_id").AsUInt;
                    userData      = Users.GetBySteamID(asUInt);
                    if (userData != null && class2.uint_0 != 0u)
                    {
                        if (@class.row_0 == null || @class.row_0.Get("id").AsUInt != class2.uint_0)
                        {
                            @class.row_0 = result.Row.Find(new Predicate <MySQL.Row>(class2.method_0));
                        }
                        if (@class.row_0 == null)
                        {
                            MySQL.Query(string.Format(Clans.SQL_DELETE_MEMBER, asUInt), false);
                        }
                        else
                        {
                            ClanMemberFlags value = current.Get("privileges").AsEnum <ClanMemberFlags>();
                            if (clanData == null || clanData.ID != class2.uint_0)
                            {
                                clanData = Clans.Get(class2.uint_0);
                            }
                            if (clanData == null)
                            {
                                clanData          = new ClanData(class2.uint_0, null, null, 0uL, default(DateTime));
                                clanData.Name     = @class.row_0.Get("name").AsString;
                                clanData.Abbr     = @class.row_0.Get("abbrev").AsString;
                                clanData.LeaderID = @class.row_0.Get("leader_id").AsUInt64;
                                clanData.Created  = @class.row_0.Get("created").AsDateTime;
                                clanData.Flags    = @class.row_0.Get("flags").AsEnum <ClanFlags>();
                                clanData.Balance  = @class.row_0.Get("balance").AsUInt64;
                                clanData.Tax      = @class.row_0.Get("tax").AsUInt;
                                ClanData         clanData2 = clanData;
                                List <ClanLevel> levels    = Clans.Levels;
                                if (predicate == null)
                                {
                                    predicate = new Predicate <ClanLevel>(@class.method_0);
                                }
                                clanData2.SetLevel(levels.Find(predicate));
                                clanData.Experience = @class.row_0.Get("experience").AsUInt64;
                                string[] array = @class.row_0.Get("location").AsString.Split(new char[]
                                {
                                    ','
                                });
                                if (array.Length > 0)
                                {
                                    float.TryParse(array[0], out clanData.Location.x);
                                }
                                if (array.Length > 1)
                                {
                                    float.TryParse(array[1], out clanData.Location.y);
                                }
                                if (array.Length > 2)
                                {
                                    float.TryParse(array[2], out clanData.Location.z);
                                }
                                clanData.MOTD    = @class.row_0.Get("motd").AsString;
                                clanData.Penalty = @class.row_0.Get("penalty").AsDateTime;
                                if (result3 != null)
                                {
                                    foreach (MySQL.Row current2 in result3.Row)
                                    {
                                        if (current2.Get("clan_id").AsUInt == class2.uint_0)
                                        {
                                            clanData.Hostile.Add(current2.Get("hostile_id").AsUInt, current2.Get("ending").AsDateTime);
                                        }
                                    }
                                }
                                Clans.Database.Add(clanData.ID, clanData);
                                Clans.Loaded++;
                            }
                            clanData.Members.Add(userData, value);
                            userData.Clan = clanData;
                        }
                    }
                    else
                    {
                        MySQL.Query(string.Format(Clans.SQL_DELETE_MEMBER, asUInt), false);
                    }
                }
            }
            Clans.dictionary_0.Clear();
            foreach (uint current3 in Clans.Database.Keys)
            {
                Clans.dictionary_0.Add(current3, Clans.Database[current3].Hash);
            }
            return(true);
        }
コード例 #30
0
 public static void SQL_SynchronizeClans()
 {
     if (Core.DatabaseType.Equals("MYSQL"))
     {
         MySQL.Result result = MySQL.Query("SELECT * FROM `db_clans`;", true);
         if (result != null)
         {
             using (List <MySQL.Row> .Enumerator enumerator = result.Row.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     Predicate <ClanLevel> predicate = null;
                     Clans.Class3          @class    = new Clans.Class3();
                     @class.row_0 = enumerator.Current;
                     uint     asUInt = @class.row_0.Get("id").AsUInt;
                     ClanData clanData;
                     if (Clans.Database.ContainsKey(asUInt))
                     {
                         clanData = Clans.Get(asUInt);
                     }
                     else
                     {
                         Clans.Database.Add(asUInt, clanData = new ClanData(asUInt, null, null, 0uL, default(DateTime)));
                     }
                     if (!Clans.dictionary_0.ContainsKey(asUInt))
                     {
                         Clans.dictionary_0.Add(asUInt, 0uL);
                     }
                     if (Clans.Database[clanData.ID].Hash == Clans.dictionary_0[clanData.ID])
                     {
                         clanData.Name     = @class.row_0.Get("name").AsString;
                         clanData.Abbr     = @class.row_0.Get("abbrev").AsString;
                         clanData.LeaderID = @class.row_0.Get("leader_id").AsUInt64;
                         clanData.Created  = @class.row_0.Get("created").AsDateTime;
                         clanData.Flags    = @class.row_0.Get("flags").AsEnum <ClanFlags>();
                         clanData.Balance  = @class.row_0.Get("balance").AsUInt64;
                         clanData.Tax      = @class.row_0.Get("tax").AsUInt;
                         ClanData         clanData2 = clanData;
                         List <ClanLevel> levels    = Clans.Levels;
                         if (predicate == null)
                         {
                             predicate = new Predicate <ClanLevel>(@class.method_0);
                         }
                         clanData2.SetLevel(levels.Find(predicate));
                         clanData.Experience = @class.row_0.Get("experience").AsUInt64;
                         string[] array = @class.row_0.Get("location").AsString.Replace(", ", ",").Split(new char[]
                         {
                             ','
                         });
                         if (array.Length > 0)
                         {
                             float.TryParse(array[0].Trim(), out clanData.Location.x);
                         }
                         if (array.Length > 1)
                         {
                             float.TryParse(array[1].Trim(), out clanData.Location.y);
                         }
                         if (array.Length > 2)
                         {
                             float.TryParse(array[2].Trim(), out clanData.Location.z);
                         }
                         clanData.MOTD    = @class.row_0.Get("motd").AsString;
                         clanData.Penalty = @class.row_0.Get("penalty").AsDateTime;
                     }
                     else
                     {
                         Clans.SQL_Update(clanData, false);
                     }
                     Clans.dictionary_0[asUInt] = Clans.Database[asUInt].Hash;
                 }
             }
         }
     }
 }