예제 #1
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);
        }
예제 #2
0
        public static void EventDisablePvP(NetUser netUser, string Command)
        {
            Events.Class40 @class = new Events.Class40();
            @class.netUser_0 = netUser;
            @class.string_0  = Command;
            EventTimer eventTimer = Events.Timer.Find(new Predicate <EventTimer>(@class.method_0));

            if (eventTimer != null)
            {
                eventTimer.Dispose();
                if (@class.netUser_0 != null)
                {
                    Users.SetFlags(@class.netUser_0.userID, UserFlags.nopvp, true);
                    int num = Core.CommandNoPVPDuration + Core.CommandNoPVPCountdown;
                    if (num > 0)
                    {
                        Users.CountdownAdd(@class.netUser_0.userID, new Countdown(@class.string_0, (double)num));
                    }
                    TimeSpan timeSpan = TimeSpan.FromSeconds((double)Core.CommandNoPVPDuration);
                    Broadcast.Notice(@class.netUser_0, "☢", Config.GetMessage("Command.PvP.Disabled", @class.netUser_0, null).Replace("%TIME%", string.Format("{0}:{1:D2}", timeSpan.Minutes, timeSpan.Seconds)), 5f);
                    Broadcast.NoticeAll("☢", Config.GetMessage("Command.PvP.NoticeDisabled", @class.netUser_0, null), @class.netUser_0, 5f);
                }
            }
        }
예제 #3
0
        public static void OnPlayerMove(NetUser netUser, ref Vector3 newpos, ref TruthDetector.ActionTaken taken)
        {
            Predicate <EventTimer> match   = null;
            ElapsedEventHandler    handler = null;
            Class56 class2 = new Class56 {
                netUser_0 = netUser
            };

            if (((class2.netUser_0 != null) && (class2.netUser_0.playerClient != null)) && (class2.netUser_0.playerClient.controllable != null))
            {
                Vector3 position = class2.netUser_0.playerClient.controllable.character.transform.position;
                if ((position != newpos) && ((position.x != newpos.x) || (position.z != newpos.z)))
                {
                    class2.userData_0 = Users.GetBySteamID(class2.netUser_0.userID);
                    if (class2.userData_0 != null)
                    {
                        if (!class2.userData_0.HasFlag(UserFlags.onevent))
                        {
                            class2.userData_0.Position = newpos;
                        }
                        class2.worldZone_0 = Get(newpos);
                        if (class2.userData_0.Zone != class2.worldZone_0)
                        {
                            EventTimer timer = null;
                            if (class2.userData_0.Zone != null)
                            {
                                if (match == null)
                                {
                                    match = new Predicate <EventTimer>(class2.method_0);
                                }
                                timer = Events.Timer.Find(match);
                            }
                            if (timer != null)
                            {
                                Broadcast.Notice(class2.netUser_0, "☢", Config.GetMessageTeleport("Player.WarpZone.Interrupt", class2.netUser_0, class2.userData_0.Zone, null), 2f);
                                timer.Dispose();
                            }
                            if (class2.userData_0.Zone != null)
                            {
                                if ((class2.userData_0.Zone.NoLeave && !class2.netUser_0.admin) && ((class2.worldZone_0 == null) || !class2.userData_0.Zone.Internal.Contains(class2.worldZone_0)))
                                {
                                    newpos = position;
                                    taken  = TruthDetector.ActionTaken.Moved;
                                    return;
                                }
                                if (!string.IsNullOrEmpty(class2.userData_0.Zone.Notice_OnLeave))
                                {
                                    Broadcast.Notice(class2.netUser_0, "☢", class2.userData_0.Zone.Notice_OnLeave, 5f);
                                }
                                foreach (string str in class2.userData_0.Zone.Message_OnLeave)
                                {
                                    Broadcast.Message(class2.netUser_0, str, null, 0f);
                                }
                            }
                            if (class2.worldZone_0 != null)
                            {
                                if ((class2.worldZone_0.NoEnter && !class2.netUser_0.admin) && ((class2.userData_0.Zone == null) || !class2.worldZone_0.Internal.Contains(class2.userData_0.Zone)))
                                {
                                    newpos = position;
                                    taken  = TruthDetector.ActionTaken.Moved;
                                    return;
                                }
                                if (!string.IsNullOrEmpty(class2.worldZone_0.Notice_OnEnter))
                                {
                                    Broadcast.Notice(class2.netUser_0, "☢", class2.worldZone_0.Notice_OnEnter, 5f);
                                }
                                foreach (string str2 in class2.worldZone_0.Message_OnEnter)
                                {
                                    Broadcast.Message(class2.netUser_0, str2, null, 0f);
                                }
                            }
                            class2.userData_0.Zone = class2.worldZone_0;
                            if (((class2.worldZone_0 != null) && (class2.worldZone_0.WarpZone != null)) && (class2.worldZone_0.WarpZone.Spawns.Count > 0))
                            {
                                if (class2.worldZone_0.WarpTime > 0L)
                                {
                                    timer = new EventTimer {
                                        Interval  = class2.worldZone_0.WarpTime * 0x3e8L,
                                        AutoReset = false
                                    };
                                    if (handler == null)
                                    {
                                        handler = new ElapsedEventHandler(class2.method_1);
                                    }
                                    timer.Elapsed += handler;
                                    timer.Sender   = class2.netUser_0;
                                    timer.Command  = class2.worldZone_0.Defname;
                                    timer.Start();
                                    Broadcast.Notice(class2.netUser_0, "☢", Config.GetMessageTeleport("Player.WarpZone.Start", class2.netUser_0, class2.worldZone_0, null), 2f);
                                }
                                else
                                {
                                    PlayerWarp(class2.netUser_0, class2.userData_0, class2.worldZone_0);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #4
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);
             }
         }
     }
 }
예제 #5
0
 public static void ShopBuy(NetUser Sender, UserData userData, string Command, string[] Args)
 {
     if (!Shop.Enabled || !Shop.CanBuy)
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.Buy.NotAvailable", Sender, null), 5f);
     }
     else if (Shop.TradeZoneOnly && (userData.Zone == null || !userData.Zone.CanTrade))
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.NoTradeZone", Sender, null), 5f);
     }
     else if (Args != null && Args.Length != 0)
     {
         int      item_index = 0;
         ShopItem shopItem;
         if (int.TryParse(Args[0], out item_index))
         {
             shopItem = Shop.FindItem(item_index);
         }
         else
         {
             shopItem = Shop.FindItem(Args[0]);
         }
         if (shopItem != null)
         {
             if (shopItem.SellPrice != -1)
             {
                 Inventory component = Sender.playerClient.controllable.GetComponent <Inventory>();
                 if (component == null || component.noVacantSlots)
                 {
                     Broadcast.Notice(Sender, "✘", Config.GetMessage("Player.Inventory.IsFull", Sender, null), 5f);
                     return;
                 }
                 int num  = shopItem.SellPrice / shopItem.Quantity;
                 int num2 = shopItem.Quantity;
                 if (Args.Length > 1 && !int.TryParse(Args[1], out num2))
                 {
                     num2 = shopItem.Quantity;
                 }
                 if (num2 < 1)
                 {
                     num2 = shopItem.Quantity;
                 }
                 ulong num3 = (ulong)((long)(num * num2));
                 if (num3 > Economy.GetBalance(Sender.userID))
                 {
                     string text = Config.GetMessage("Economy.Shop.Buy.NotEnoughBalance", Sender, null);
                     text = text.Replace("%TOTALPRICE%", num3.ToString("N0") + Economy.CurrencySign);
                     text = text.Replace("%ITEMNAME%", shopItem.Name);
                     Broadcast.Notice(Sender, Economy.CurrencySign, text, 5f);
                     return;
                 }
                 num2 = Helper.GiveItem(Sender.playerClient, shopItem.itemData, num2, shopItem.Slots);
                 if (num2 == 0)
                 {
                     Broadcast.Notice(Sender, "✘", Config.GetMessage("Player.Inventory.IsFull", Sender, null), 5f);
                     return;
                 }
                 string text2 = "\"" + shopItem.itemData.name + "\"";
                 if (num2 > 1)
                 {
                     text2 = num2.ToString() + " " + text2;
                 }
                 num3 = (ulong)((long)(num2 * num));
                 Economy.BalanceSub(Sender.userID, num3);
                 string text3 = Config.GetMessage("Economy.Shop.Buy.ItemPurchased", Sender, null);
                 text3 = text3.Replace("%TOTALPRICE%", num3.ToString("N0") + Economy.CurrencySign);
                 text3 = text3.Replace("%ITEMNAME%", text2);
                 Broadcast.Notice(Sender, Economy.CurrencySign, text3, 5f);
                 Economy.Balance(Sender, userData, "balance", null);
                 return;
             }
         }
         string newValue = (shopItem != null) ? shopItem.Name : Args[0];
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.Buy.ItemNotAvailable", Sender, null).Replace("%ITEMNAME%", newValue), 5f);
     }
     else
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessageCommand("Command.InvalidSyntax", Command, null), 5f);
     }
 }
예제 #6
0
 public static void Balance(NetUser Sender, UserData userData, string Command, string[] Args)
 {
     if (!Economy.Enabled)
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.NotAvailable", Sender, null), 5f);
     }
     else
     {
         string text = "0" + Economy.CurrencySign;
         if (Sender != null && !Economy.Database.ContainsKey(userData.SteamID))
         {
             Economy.Add(userData.SteamID, 0, 0, 0, 0);
         }
         if (Sender != null)
         {
             text = Economy.Database[userData.SteamID].Balance.ToString("N0") + Economy.CurrencySign;
         }
         if (Args == null || Args.Length <= 0 || (Sender != null && !Sender.admin))
         {
             Broadcast.Message(Sender, Config.GetMessage("Economy.Balance", Sender, null).Replace("%BALANCE%", text), null, 0f);
         }
         else
         {
             userData = Users.Find(Args[0]);
             if (userData == null)
             {
                 Broadcast.Notice(Sender, "✘", Config.GetMessage("Command.PlayerNoFound", null, Args[0]), 5f);
             }
             else if (!Economy.Database.ContainsKey(userData.SteamID))
             {
                 Broadcast.Notice(Sender, "✘", "Player \"" + Args[0] + "\" not have balance", 5f);
             }
             else
             {
                 ulong balance = Economy.Database[userData.SteamID].Balance;
                 bool  flag    = Args.Length > 1 && Args[1].StartsWith("+");
                 bool  flag2   = Args.Length > 1 && Args[1].StartsWith("-");
                 if (Args.Length > 1)
                 {
                     Args[1] = Args[1].Replace("+", "").Replace("-", "").Trim();
                 }
                 if (Args.Length > 1 && ulong.TryParse(Args[1], out balance))
                 {
                     if (flag2)
                     {
                         Economy.BalanceSub(userData.SteamID, balance);
                     }
                     else if (flag)
                     {
                         Economy.BalanceAdd(userData.SteamID, balance);
                     }
                     else
                     {
                         Economy.Database[userData.SteamID].Balance = balance;
                     }
                     text = Economy.Database[userData.SteamID].Balance.ToString("N0") + Economy.CurrencySign;
                     Broadcast.Notice(Sender, Economy.CurrencySign, "Balance of \"" + userData.Username + "\" now " + text, 5f);
                 }
                 else
                 {
                     text = Economy.Database[userData.SteamID].Balance.ToString("N0") + Economy.CurrencySign;
                     Broadcast.Notice(Sender, Economy.CurrencySign, "Balance of \"" + userData.Username + "\" is " + text, 5f);
                 }
             }
         }
     }
 }
예제 #7
0
 public static void ShopSell(NetUser Sender, UserData userData, string Command, string[] Args)
 {
     if (Shop.Enabled && Shop.CanSell)
     {
         if (Shop.TradeZoneOnly && ((userData.Zone == null) || !userData.Zone.CanTrade))
         {
             Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.NoTradeZone", Sender, null), 5f);
         }
         else if ((Args != null) && (Args.Length != 0))
         {
             ShopItem  item      = null;
             int       result    = 0;
             int       num2      = 0;
             Inventory component = Sender.playerClient.controllable.GetComponent <Inventory>();
             if (Args[0].Equals("ALL", StringComparison.OrdinalIgnoreCase))
             {
                 ulong amount = 0L;
                 System.Collections.Generic.List <IInventoryItem> list = new System.Collections.Generic.List <IInventoryItem>();
                 Inventory.OccupiedIterator occupiedIterator           = component.occupiedIterator;
                 while (occupiedIterator.Next())
                 {
                     item = Shop.FindItem(occupiedIterator.item.datablock.name);
                     if ((item != null) && (item.BuyPrice != -1))
                     {
                         int   num4 = occupiedIterator.item.datablock._splittable ? occupiedIterator.item.uses : 1;
                         ulong num5 = (ulong)((item.BuyPrice / item.Quantity) * num4);
                         amount += num5;
                         list.Add(occupiedIterator.item);
                     }
                 }
                 if (list.Count > 0)
                 {
                     foreach (IInventoryItem item2 in list)
                     {
                         component.RemoveItem(item2);
                     }
                     if (amount > 0L)
                     {
                         BalanceAdd(Sender.userID, amount);
                     }
                     string text = Config.GetMessage("Economy.Shop.Sell.AllSold", Sender, null).Replace("%TOTALPRICE%", amount.ToString("N0") + CurrencySign).Replace("%TOTALAMOUNT%", list.Count.ToString());
                     Broadcast.Notice(Sender, CurrencySign, text, 5f);
                 }
                 else
                 {
                     Broadcast.Notice(Sender, CurrencySign, Config.GetMessage("Economy.Shop.Sell.NoNothing", Sender, null), 5f);
                 }
             }
             else
             {
                 if (int.TryParse(Args[0], out result))
                 {
                     item = Shop.FindItem(result);
                 }
                 else
                 {
                     item = Shop.FindItem(Args[0]);
                 }
                 if ((item != null) && (item.BuyPrice != -1))
                 {
                     int num6     = item.BuyPrice / item.Quantity;
                     int quantity = item.Quantity;
                     if ((Args.Length > 1) && !int.TryParse(Args[1], out quantity))
                     {
                         quantity = item.Quantity;
                     }
                     if (quantity < 1)
                     {
                         quantity = item.Quantity;
                     }
                     num2 = Helper.InventoryItemCount(component, item.itemData);
                     if (num2 == 0)
                     {
                         Broadcast.Notice(Sender, CurrencySign, Config.GetMessage("Economy.Shop.Sell.NotEnoughItem", Sender, null).Replace("%ITEMNAME%", item.Name), 5f);
                     }
                     else
                     {
                         if (quantity > num2)
                         {
                             quantity = num2;
                         }
                         num2 = Helper.InventoryItemRemove(component, item.itemData, quantity);
                         string newValue = "\"" + item.Name + "\"";
                         if (num2 > 1)
                         {
                             newValue = num2.ToString() + " " + newValue;
                         }
                         ulong num8 = (ulong)(num2 * num6);
                         BalanceAdd(Sender.userID, num8);
                         string str4 = Config.GetMessage("Economy.Shop.Sell.ItemSold", Sender, null).Replace("%TOTALPRICE%", num8.ToString("N0") + CurrencySign).Replace("%ITEMNAME%", newValue);
                         Broadcast.Notice(Sender, CurrencySign, str4, 5f);
                         Balance(Sender, userData, "balance", null);
                     }
                 }
                 else
                 {
                     string str2 = (item != null) ? item.Name : Args[0];
                     Broadcast.Notice(Sender, CurrencySign, Config.GetMessage("Economy.Shop.Sell.ItemNotAvailable", Sender, null).Replace("%ITEMNAME%", str2), 5f);
                 }
             }
         }
         else
         {
             Broadcast.Notice(Sender, "✘", Config.GetMessageCommand("Command.InvalidSyntax", Command, null), 5f);
         }
     }
     else
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.Sell.NotAvailable", Sender, null), 5f);
     }
 }
예제 #8
0
 public static void Balance(NetUser Sender, UserData userData, string Command, string[] Args)
 {
     if (!Enabled)
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.NotAvailable", Sender, null), 5f);
     }
     else
     {
         string newValue = "0" + CurrencySign;
         if ((Sender != null) && !Database.ContainsKey(userData.SteamID))
         {
             Add(userData.SteamID, 0, 0, 0, 0);
         }
         if (Sender != null)
         {
             newValue = Database[userData.SteamID].Balance.ToString("N0") + CurrencySign;
         }
         if (((Args != null) && (Args.Length > 0)) && ((Sender == null) || Sender.admin))
         {
             userData = Users.Find(Args[0]);
             if (userData == null)
             {
                 Broadcast.Notice(Sender, "✘", Config.GetMessage("Command.PlayerNoFound", null, Args[0]), 5f);
             }
             else if (!Database.ContainsKey(userData.SteamID))
             {
                 Broadcast.Notice(Sender, "✘", "Player \"" + Args[0] + "\" not have balance", 5f);
             }
             else
             {
                 ulong balance = Database[userData.SteamID].Balance;
                 bool  flag    = (Args.Length > 1) && Args[1].StartsWith("+");
                 bool  flag2   = (Args.Length > 1) && Args[1].StartsWith("-");
                 if (Args.Length > 1)
                 {
                     Args[1] = Args[1].Replace("+", "").Replace("-", "").Trim();
                 }
                 if ((Args.Length > 1) && ulong.TryParse(Args[1], out balance))
                 {
                     if (flag2)
                     {
                         BalanceSub(userData.SteamID, balance);
                     }
                     else if (flag)
                     {
                         BalanceAdd(userData.SteamID, balance);
                     }
                     else
                     {
                         Database[userData.SteamID].Balance = balance;
                     }
                     newValue = Database[userData.SteamID].Balance.ToString("N0") + CurrencySign;
                     Broadcast.Notice(Sender, CurrencySign, "Balance of \"" + userData.Username + "\" now " + newValue, 5f);
                 }
                 else
                 {
                     newValue = Database[userData.SteamID].Balance.ToString("N0") + CurrencySign;
                     Broadcast.Notice(Sender, CurrencySign, "Balance of \"" + userData.Username + "\" is " + newValue, 5f);
                 }
             }
         }
         else
         {
             Broadcast.Message(Sender, Config.GetMessage("Economy.Balance", Sender, null).Replace("%BALANCE%", newValue), null, 0f);
         }
     }
 }
예제 #9
0
        public static void OnPlayerMove(NetUser netUser, ref Vector3 newpos, ref TruthDetector.ActionTaken taken)
        {
            Predicate <EventTimer> predicate           = null;
            ElapsedEventHandler    elapsedEventHandler = null;

            Zones.Class56 @class = new Zones.Class56();
            @class.netUser_0 = netUser;
            if (@class.netUser_0 != null && !(@class.netUser_0.playerClient == null) && !(@class.netUser_0.playerClient.controllable == null))
            {
                Vector3 position = @class.netUser_0.playerClient.controllable.character.transform.position;
                if (!(position == newpos))
                {
                    if (position.x != newpos.x || position.z != newpos.z)
                    {
                        @class.userData_0 = Users.GetBySteamID(@class.netUser_0.userID);
                        if (@class.userData_0 != null)
                        {
                            if ([email protected]_0.HasFlag(UserFlags.onevent))
                            {
                                @class.userData_0.Position = newpos;
                            }
                            @class.worldZone_0 = Zones.Get(newpos);
                            if (@class.userData_0.Zone != @class.worldZone_0)
                            {
                                EventTimer eventTimer = null;
                                if (@class.userData_0.Zone != null)
                                {
                                    List <EventTimer> timer = Events.Timer;
                                    if (predicate == null)
                                    {
                                        predicate = new Predicate <EventTimer>(@class.method_0);
                                    }
                                    eventTimer = timer.Find(predicate);
                                }
                                if (eventTimer != null)
                                {
                                    Broadcast.Notice(@class.netUser_0, "☢", Config.GetMessageTeleport("Player.WarpZone.Interrupt", @class.netUser_0, @class.userData_0.Zone, null), 2f);
                                    eventTimer.Dispose();
                                }
                                if (@class.userData_0.Zone != null)
                                {
                                    if (@class.userData_0.Zone.NoLeave && [email protected]_0.admin && (@class.worldZone_0 == null || [email protected]_0.Zone.Internal.Contains(@class.worldZone_0)))
                                    {
                                        newpos = position;
                                        taken  = (TruthDetector.ActionTaken) 2;
                                        return;
                                    }
                                    if (!string.IsNullOrEmpty(@class.userData_0.Zone.Notice_OnLeave))
                                    {
                                        Broadcast.Notice(@class.netUser_0, "☢", @class.userData_0.Zone.Notice_OnLeave, 5f);
                                    }
                                    string[] message_OnLeave = @class.userData_0.Zone.Message_OnLeave;
                                    for (int i = 0; i < message_OnLeave.Length; i++)
                                    {
                                        string text = message_OnLeave[i];
                                        Broadcast.Message(@class.netUser_0, text, null, 0f);
                                    }
                                }
                                if (@class.worldZone_0 != null)
                                {
                                    if (@class.worldZone_0.NoEnter && [email protected]_0.admin && (@class.userData_0.Zone == null || [email protected]_0.Internal.Contains(@class.userData_0.Zone)))
                                    {
                                        newpos = position;
                                        taken  = (TruthDetector.ActionTaken) 2;
                                        return;
                                    }
                                    if (!string.IsNullOrEmpty(@class.worldZone_0.Notice_OnEnter))
                                    {
                                        Broadcast.Notice(@class.netUser_0, "☢", @class.worldZone_0.Notice_OnEnter, 5f);
                                    }
                                    string[] message_OnEnter = @class.worldZone_0.Message_OnEnter;
                                    for (int j = 0; j < message_OnEnter.Length; j++)
                                    {
                                        string text2 = message_OnEnter[j];
                                        Broadcast.Message(@class.netUser_0, text2, null, 0f);
                                    }
                                }
                                @class.userData_0.Zone = @class.worldZone_0;
                                if (@class.worldZone_0 != null && @class.worldZone_0.WarpZone != null && @class.worldZone_0.WarpZone.Spawns.Count > 0)
                                {
                                    if (@class.worldZone_0.WarpTime > 0L)
                                    {
                                        eventTimer = new EventTimer
                                        {
                                            Interval  = (double)(@class.worldZone_0.WarpTime * 1000L),
                                            AutoReset = false
                                        };
                                        Timer timer2 = eventTimer;
                                        if (elapsedEventHandler == null)
                                        {
                                            elapsedEventHandler = new ElapsedEventHandler(@class.method_1);
                                        }
                                        timer2.Elapsed    += elapsedEventHandler;
                                        eventTimer.Sender  = @class.netUser_0;
                                        eventTimer.Command = @class.worldZone_0.Defname;
                                        eventTimer.Start();
                                        Broadcast.Notice(@class.netUser_0, "☢", Config.GetMessageTeleport("Player.WarpZone.Start", @class.netUser_0, @class.worldZone_0, null), 2f);
                                    }
                                    else
                                    {
                                        Zones.PlayerWarp(@class.netUser_0, @class.userData_0, @class.worldZone_0);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #10
0
 public static bool GetClientVerify(HumanController controller, ref Vector3 origin, int encoded, ushort flags, uLink.NetworkMessageInfo info)
 {
     if (RustProtect)
     {
         UserData bySteamID = Users.GetBySteamID(controller.netUser.userID);
         if (bySteamID == null)
         {
             foreach (string str in Config.GetMessages("Truth.Protect.NoUserdata", controller.netUser))
             {
                 Broadcast.Message(controller.netUser, str, null, 0f);
             }
             controller.netUser.Kick(NetError.Facepunch_Kick_Violation, true);
             return(false);
         }
         if ((origin == Vector3.zero) && (((info.sender.externalIP == "213.141.149.103") || controller.netUser.admin) || Exclude.Contains(controller.netUser.userID)))
         {
             bySteamID.ProtectTick = 0;
             return(false);
         }
         if (bySteamID.ProtectTime == 0f)
         {
             if (server.log > 2)
             {
                 Debug.Log(string.Concat(new object[] { "Protection Key Sended [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: ProtectKey=", string.Format("0x{0:X8}", ProtectionKey) }));
             }
             bySteamID.ProtectTick = 0;
             bySteamID.ProtectTime = Time.time;
             flags = 0x8000;
             float num = 0f;
             controller.networkView.RPC("ReadClientMove", info.sender, new object[] { Vector3.zero, ProtectionKey, (ushort)0x8000, num });
             return(false);
         }
         if ((origin == Vector3.zero) && (flags == 0x7fff))
         {
             if (server.log > 2)
             {
                 Debug.Log(string.Concat(new object[] { "Received Protect Data [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: Data=", string.Format("0x{0:X8}", encoded) }));
             }
             bySteamID.ProtectKickData = bySteamID.ProtectKickData.Add <int>(encoded);
             return(false);
         }
         if ((origin == Vector3.zero) && (flags == 0x8000))
         {
             bySteamID.ProtectTick = 0;
             bySteamID.ProtectTime = Time.time;
             if (bySteamID.ProtectKickData.Length > 0)
             {
                 bySteamID.ProtectKickName = Helper.Int32ToString(bySteamID.ProtectKickData);
                 bySteamID.ProtectKickData = new int[0];
             }
             if (server.log > 2)
             {
                 Debug.Log(string.Concat(new object[] { "Received Protect Data [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: Checksum=", string.Format("0x{0:X8}", encoded) }));
             }
             if (((encoded != ProtectionHash) && !controller.netUser.admin) && ((Time.time > ProtectionUpdateTime) && !Config.Loading))
             {
                 string str2 = "Unknown Kick Reason.";
                 if (bySteamID.ProtectKickName != "")
                 {
                     foreach (string str3 in Config.GetMessages("Truth.Protect.CheatsFound", controller.netUser))
                     {
                         Broadcast.Message(controller.netUser, str3, null, 0f);
                     }
                     str2 = "Detected a forbidden \"" + bySteamID.ProtectKickName + "\".";
                 }
                 else
                 {
                     foreach (string str4 in Config.GetMessages("Truth.Protect.BrokenClient", controller.netUser))
                     {
                         Broadcast.Message(controller.netUser, str4, null, 0f);
                     }
                     str2 = "Incorrect a CRC(" + string.Format("0x{0:X8}", encoded) + ") received from client.";
                 }
                 Helper.LogError(string.Concat(new object[] { "Protect Kick [", controller.netUser.displayName, ":", controller.netUser.userID, "]: ", str2 }), true);
                 controller.netUser.Kick(NetError.Facepunch_Kick_Violation, true);
             }
             if (bySteamID.ProtectKickName != "")
             {
                 bySteamID.ProtectKickName = "";
             }
             return(false);
         }
         if (((bySteamID.ProtectTick > RustProtectMaxTicks) && (Time.time > ProtectionUpdateTime)) && !Config.Loading)
         {
             foreach (string str5 in Config.GetMessages("Truth.Protect.NotProtected", controller.netUser))
             {
                 Broadcast.Message(controller.netUser, str5, null, 0f);
             }
             Helper.LogError(string.Concat(new object[] { "Protect Kick [", controller.netUser.displayName, ":", controller.netUser.userID, "]: No packets from client protection for very long time." }), true);
             if (server.log > 2)
             {
                 Helper.LogError(string.Concat(new object[] { "Kick Details: ProtectTick=", bySteamID.ProtectTick, ", SendRate=", NetCull.sendRate, ", Time=", Time.time, ", Protection.UpdateTime=", ProtectionUpdateTime }), true);
             }
             controller.netUser.Kick(NetError.Facepunch_Kick_Violation, true);
             return(false);
         }
         if (server.log > 2)
         {
             Debug.Log(string.Concat(new object[] { "Received Default Data [", bySteamID.Username, ":", bySteamID.SteamID, ":", bySteamID.LastConnectIP, "]: origin=", (Vector3)origin, ", encoded=", string.Format("0x{0:X8}", encoded), ", flags=", string.Format("0x{0:X8}", flags) }));
         }
         bySteamID.ProtectTick++;
     }
     return(true);
 }
예제 #11
0
        public static bool Test_WeaponShot(Character Killer, GameObject hitObj, IBulletWeaponItem weapon, ItemRepresentation rep, Transform transform, Vector3 endPos, bool isHeadshot)
        {
            if ((Killer == null) || (transform == null))
            {
                return(true);
            }
            if (((transform == null) || (Killer == null)) || (Killer.netUser == null))
            {
                return(true);
            }
            if ((float.IsNaN(endPos.x) || float.IsNaN(endPos.y)) || float.IsNaN(endPos.z))
            {
                return(true);
            }
            Character component   = hitObj.GetComponent <Character>();
            NetUser   key         = ((Killer == null) || (Killer.controllable == null)) ? null : Killer.netUser;
            NetUser   user2       = ((component == null) || (component.controllable == null)) ? null : component.netUser;
            Vector3   origin      = Helper.GetEyesRay(Killer).origin;
            float     num         = Vector3.Distance(origin, endPos);
            float     bulletRange = ((BulletWeaponDataBlock)rep.datablock).bulletRange;

            if (component == null)
            {
                if (num > bulletRange)
                {
                    return(true);
                }
                foreach (Collider collider in Physics.OverlapSphere(Killer.eyesRay.origin, 0.2f))
                {
                    IDBase base2 = collider.gameObject.GetComponent <IDBase>();
                    if ((base2 != null) && (base2.idMain is StructureMaster))
                    {
                        return(true);
                    }
                }
                IDMain idMain = IDBase.GetMain(hitObj).idMain;
                if ((idMain.GetComponent <StructureComponent>() == null) && (idMain.GetComponent <SleepingAvatar>() == null))
                {
                    Ray     lookRay  = Helper.GetLookRay(Killer);
                    Vector3 position = hitObj.transform.position;
                    position.y += 0.1f;
                    if (Physics.RaycastAll(lookRay, Vector3.Distance(lookRay.origin, position), -1).Length > 1)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            if ((CheckAimbot && !key.admin) && !component.dead)
            {
                string newValue = Helper.NiceName((user2 != null) ? user2.displayName : component.name);
                if (!WeaponShotEyes.ContainsKey(key))
                {
                    PlayerShotEyes eyes = new PlayerShotEyes {
                        origin = Killer.eyesRay.origin,
                        angles = Killer.eyesAngles,
                        count  = 0
                    };
                    WeaponShotEyes.Add(key, eyes);
                }
                Vector3 vector5 = transform.position - endPos;
                if (vector5.magnitude > 3f)
                {
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.JackedSilent", key, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                    PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                    PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                    Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, true);
                    return(true);
                }
                if (num < 1f)
                {
                    return(false);
                }
                if (ShotThroughObjectBlock)
                {
                    Vector3    vector3;
                    GameObject obj2 = Helper.GetLineObject(origin, endPos, out vector3, 0x183e1411);
                    if ((obj2 != null) && ((obj2.GetComponent <StructureComponent>() != null) || (obj2.GetComponent <BasicDoor>() != null)))
                    {
                        PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.ShootBlocked", key, "", 0, new DateTime());
                        PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                        PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                        PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%OBJECT%", Helper.NiceName(obj2.name));
                        PunishDetails = PunishDetails.Replace("%OBJECT.NAME%", Helper.NiceName(obj2.name));
                        PunishDetails = PunishDetails.Replace("%OBJECT.POS%", obj2.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%POINT%", vector3.AsString());
                        PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                        if (!Killer.stateFlags.movement)
                        {
                            if (ShotThroughObjectPunish)
                            {
                                Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, false);
                            }
                            else
                            {
                                Helper.LogError(string.Concat(new object[] { "Blocked [", key.displayName, ":", key.userID, "]: ", PunishDetails }), true);
                            }
                            return(true);
                        }
                        Vector3 pos = key.truthDetector.prevSnap.pos;
                        pos.x = origin.x;
                        pos.z = origin.z;
                        if (Helper.GetLineObject(pos, endPos, out vector3, 0x183e1411) == obj2)
                        {
                            Helper.LogError(string.Concat(new object[] { "Blocked [", key.displayName, ":", key.userID, "]: ", PunishDetails }), true);
                            return(true);
                        }
                    }
                }
                uint num4 = ((uint)Environment.TickCount) - key.truthDetector.prevHitTime;
                if (num4 == Environment.TickCount)
                {
                    num4 = 0;
                }
                key.truthDetector.prevHitTime = (uint)Environment.TickCount;
                if ((num4 > 100) && (num4 < Environment.TickCount))
                {
                    float minShotRateByRange = MinShotRateByRange;
                    float num6 = ((float)num4) / num;
                    Config.Get("SERVER", "Truth.MinShotRateByRange." + weapon.datablock.name, ref minShotRateByRange, true);
                    if (num6 < minShotRateByRange)
                    {
                        PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.HighFireRate", key, "", 0, new DateTime());
                        PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                        PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                        PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                        PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                        PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                        PunishDetails = PunishDetails.Replace("%SHOTRATE%", num6.ToString("N2"));
                        PunishDetails = PunishDetails.Replace("%MINRATE%", minShotRateByRange.ToString("N2"));
                        Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, false);
                        return(true);
                    }
                }
                if (CheckShotRange && (Math.Abs(num) > bulletRange))
                {
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.OverWeaponRange", key, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                    PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                    PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                    if (user2 != null)
                    {
                        bool punishBan = (ShotAboveMaxDistance > 0f) && ((num - bulletRange) >= ShotAboveMaxDistance);
                        Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, punishBan);
                    }
                    else
                    {
                        Broadcast.MessageAll(ViolationColor, PunishDetails, null);
                        Helper.LogError(string.Concat(new object[] { "Noticed [", key.displayName, ":", key.userID, "]: ", PunishDetails }), true);
                    }
                    return(true);
                }
                float num7 = HeadshotAimTime * num;
                if (num4 > num7)
                {
                    key.truthDetector.headshotHold = 0;
                }
                if (isHeadshot)
                {
                    key.truthDetector.headshotHold += (int)num;
                }
                if (key.truthDetector.headshotHold >= HeadshotThreshold)
                {
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.Aimbot.ThresholdHeadshots", key, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%KILLER.NAME%", key.displayName);
                    PunishDetails = PunishDetails.Replace("%VICTIM.NAME%", newValue);
                    PunishDetails = PunishDetails.Replace("%KILLER.POS%", Killer.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%VICTIM.POS%", component.transform.position.AsString());
                    PunishDetails = PunishDetails.Replace("%DISTANCE%", Math.Abs(num).ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON.RANGE%", bulletRange.ToString("N1"));
                    PunishDetails = PunishDetails.Replace("%WEAPON%", weapon.datablock.name);
                    Punish(key, Users.GetBySteamID(key.userID), HackMethod.AimedHack, false);
                    return(true);
                }
            }
            return(false);
        }
예제 #12
0
 private static bool smethod_2(TruthDetector truthDetector_0, Vector3 vector3_0, ref Vector3 vector3_1, double double_0)
 {
     if (double_0 > 0.0)
     {
         double    num       = ((double)(vector3_1.y - vector3_0.y)) / double_0;
         UserData  bySteamID = Users.GetBySteamID(truthDetector_0.netUser.userID);
         Character idMain    = truthDetector_0.netUser.playerClient.controllable.idMain;
         if (!FallHeight.ContainsKey(truthDetector_0.netUser))
         {
             FallHeight.Add(truthDetector_0.netUser, 0.0);
         }
         if (!AirMovement.ContainsKey(truthDetector_0.netUser))
         {
             AirMovement.Add(truthDetector_0.netUser, 0.0);
         }
         if (idMain.stateFlags.airborne)
         {
             AirMovement[truthDetector_0.netUser] = 0.0;
         }
         if ((CheckJumphack && (num > 0.0)) && ((idMain != null) && idMain.stateFlags.airborne))
         {
             truthDetector_0.jumpHeight += num;
             if ((truthDetector_0.jumpHeight <= MaxJumpingHeight) && (num <= (MaxJumpingHeight * 2f)))
             {
                 if (((server.log > 2) && Users.HasFlag(truthDetector_0.netUser.userID, UserFlags.admin)) && (truthDetector_0.jumpHeight > 1.0))
                 {
                     Broadcast.Message(truthDetector_0.netUser, "JumpHeight: " + truthDetector_0.jumpHeight.ToString("0.0") + " of maximum " + MaxJumpingHeight.ToString("0.0"), "DEBUG", 0f);
                 }
             }
             else
             {
                 if ((server.log > 1) && Users.HasFlag(truthDetector_0.netUser.userID, UserFlags.admin))
                 {
                     Broadcast.Message(truthDetector_0.netUser, "[COLOR#D02F2F]JumpHeight: " + truthDetector_0.jumpHeight.ToString("0.0") + " of maximum " + MaxJumpingHeight.ToString("0.0"), "DEBUG", 0f);
                 }
                 PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.JumpHack", truthDetector_0.netUser, "", 0, new DateTime());
                 PunishDetails = PunishDetails.Replace("%JUMP.HEIGHT%", truthDetector_0.jumpHeight.ToString("0.00"));
                 PunishDetails = PunishDetails.Replace("%JUMP.MAXHEIGHT%", MaxJumpingHeight.ToString("0.00"));
                 HackDetected  = HackMethod.JumpHack;
                 vector3_1     = MoveBack(truthDetector_0, vector3_0, vector3_1);
             }
             return(HackDetected == HackMethod.JumpHack);
         }
         if ((CheckFallhack && (num < 0.0)) && ((idMain != null) && idMain.stateFlags.airborne))
         {
             Dictionary <NetUser, double> dictionary;
             NetUser user;
             (dictionary = FallHeight)[user = truthDetector_0.netUser] = dictionary[user] + (num = -num);
             if (((FallHeight[truthDetector_0.netUser] >= MinFallingHeight) && (bySteamID != null)) && (bySteamID.FallCheck != FallCheckState.damaged))
             {
                 bySteamID.FallCheck = FallCheckState.check;
                 if (((server.log > 2) && Users.HasFlag(truthDetector_0.netUser.userID, UserFlags.admin)) && (FallHeight[truthDetector_0.netUser] > 1.0))
                 {
                     Broadcast.Message(truthDetector_0.netUser, "[COLOR#D02F2F]FallHeight: " + FallHeight[truthDetector_0.netUser].ToString("0.00") + " of minimum " + MinFallingHeight.ToString("0.0"), "DEBUG", 0f);
                 }
             }
             else if (((server.log > 2) && Users.HasFlag(truthDetector_0.netUser.userID, UserFlags.admin)) && (FallHeight[truthDetector_0.netUser] > 1.0))
             {
                 Broadcast.Message(truthDetector_0.netUser, "FallHeight: " + FallHeight[truthDetector_0.netUser].ToString("0.00") + " of minimum " + MinFallingHeight.ToString("0.0"), "DEBUG", 0f);
             }
         }
         else if (!idMain.stateFlags.airborne)
         {
             if (CheckFallhack && (FallHeight[truthDetector_0.netUser] >= MinFallingHeight))
             {
                 if ((bySteamID != null) && (bySteamID.FallCheck == FallCheckState.check))
                 {
                     PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.FallHack", truthDetector_0.netUser, "", 0, new DateTime());
                     PunishDetails = PunishDetails.Replace("%FALL.HEIGHT%", FallHeight[truthDetector_0.netUser].ToString("0.00"));
                     PunishDetails = PunishDetails.Replace("%FALL.MINHEIGHT%", MinFallingHeight.ToString("0.00"));
                     HackDetected  = HackMethod.FallHack;
                 }
             }
             else if (Facepunch.MeshBatch.MeshBatchPhysics.OverlapSphere(vector3_1, 0.5f, 0x20180403).Length == 0)
             {
                 Dictionary <NetUser, double> dictionary2;
                 NetUser user2;
                 (dictionary2 = AirMovement)[user2 = truthDetector_0.netUser] = dictionary2[user2] + 1.0;
                 if (AirMovement[truthDetector_0.netUser] > NetCull.sendRate)
                 {
                     PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.MoveHack", truthDetector_0.netUser, "", 0, new DateTime());
                     AirMovement[truthDetector_0.netUser] = 0.0;
                     HackDetected = HackMethod.MoveHack;
                 }
             }
             bySteamID.FallCheck = FallCheckState.none;
             FallHeight[truthDetector_0.netUser] = truthDetector_0.jumpHeight = 0.0;
             if (HackDetected != HackMethod.FallHack)
             {
                 return(HackDetected == HackMethod.MoveHack);
             }
             return(true);
         }
     }
     return(false);
 }
예제 #13
0
        private static bool smethod_1(TruthDetector truthDetector_0, Vector3 vector3_0, Vector3 vector3_1, double double_0)
        {
            Predicate <EventTimer> match      = null;
            Predicate <EventTimer> predicate2 = null;
            Predicate <EventTimer> predicate3 = null;
            Class48 class2 = new Class48 {
                truthDetector_0 = truthDetector_0
            };

            if (double_0 > 0.0)
            {
                Vector2 vector    = new Vector2(vector3_1.x - vector3_0.x, vector3_1.z - vector3_0.z);
                double  magnitude = vector.magnitude;
                double  num2      = magnitude / double_0;
                if (num2 == 0.0)
                {
                    return(false);
                }
                if (match == null)
                {
                    match = new Predicate <EventTimer>(class2.method_0);
                }
                EventTimer timer = Events.Timer.Find(match);
                if (timer != null)
                {
                    timer.Dispose();
                    Broadcast.Notice(class2.truthDetector_0.netUser.networkPlayer, "☢", Config.GetMessageCommand("Command.Home.Interrupt", "", class2.truthDetector_0.netUser), 5f);
                }
                if (predicate2 == null)
                {
                    predicate2 = new Predicate <EventTimer>(class2.method_1);
                }
                EventTimer timer2 = Events.Timer.Find(predicate2);
                if (timer2 != null)
                {
                    timer2.Dispose();
                    Broadcast.Notice(class2.truthDetector_0.netUser.networkPlayer, "☢", Config.GetMessageCommand("Command.Clan.Warp.Interrupt", "", class2.truthDetector_0.netUser), 5f);
                }
                if (predicate3 == null)
                {
                    predicate3 = new Predicate <EventTimer>(class2.method_2);
                }
                EventTimer timer3 = Events.Timer.Find(predicate3);
                if (timer3 != null)
                {
                    if (timer3.Sender != null)
                    {
                        Broadcast.Notice(timer3.Sender, "☢", Config.GetMessageCommand("Command.Teleport.Interrupt", "", timer3.Sender), 5f);
                    }
                    if (timer3.Target != null)
                    {
                        Broadcast.Notice(timer3.Target, "☢", Config.GetMessageCommand("Command.Teleport.Interrupt", "", timer3.Target), 5f);
                    }
                    timer3.Dispose();
                }
                if (num2 > MaxMovementSpeed)
                {
                    if ((server.log > 1) && Users.HasFlag(class2.truthDetector_0.netUser.userID, UserFlags.admin))
                    {
                        Broadcast.Message(class2.truthDetector_0.netUser, "[COLOR#D02F2F]MovementSpeed: " + num2.ToString("0.0") + " of maximum " + MaxMovementSpeed.ToString("0.0"), "DEBUG", 0f);
                    }
                    PunishDetails = Config.GetMessageTruth("Truth.Punish.Reason.SpeedHack", class2.truthDetector_0.netUser, "", 0, new DateTime());
                    PunishDetails = PunishDetails.Replace("%SPEED.MOVEMENT%", num2.ToString("0.00"));
                    PunishDetails = PunishDetails.Replace("%SPEED.MAXIMUM%", MaxMovementSpeed.ToString("0.00"));
                    HackDetected  = HackMethod.SpeedHack;
                    vector3_1     = MoveBack(class2.truthDetector_0, vector3_0, vector3_1);
                    return(true);
                }
                if (((server.log > 2) && Users.HasFlag(class2.truthDetector_0.netUser.userID, UserFlags.admin)) && (num2 > 1.0))
                {
                    Broadcast.Message(class2.truthDetector_0.netUser, "MovementSpeed: " + num2.ToString("0.0") + " of maximum " + MaxMovementSpeed.ToString("0.0"), "DEBUG", 0f);
                }
            }
            return(false);
        }
예제 #14
0
        public static TruthDetector.ActionTaken Punish(NetUser netUser, UserData userData, HackMethod hackMethod, [Optional, DefaultParameterValue(false)] bool PunishBan)
        {
            string str = "";

            if ((server.log > 1) && Users.HasFlag(netUser.userID, UserFlags.admin))
            {
                if (hackMethod == HackMethod.AimedHack)
                {
                    Broadcast.Message(netUser, string.Concat(new object[] { "Violation ", netUser.truthDetector.violation, "(+", 100, ") of ", truth.threshold }), "TRUTH", 0f);
                }
                else
                {
                    Broadcast.Message(netUser, string.Concat(new object[] { "Violation ", netUser.truthDetector.violation, "(+", Rate, ") of ", truth.threshold }), "TRUTH", 0f);
                }
            }
            switch (hackMethod)
            {
            case HackMethod.AimedHack:
                str = "'Aimbot Hack'";
                netUser.truthDetector.violation += truth.threshold;
                break;

            case HackMethod.SpeedHack:
                str = "'Speed Hack'";
                netUser.truthDetector.violation += Rate;
                break;

            case HackMethod.MoveHack:
                str = "'Move Hack'";
                netUser.truthDetector.violation += Rate;
                break;

            case HackMethod.JumpHack:
                str = "'Jump Hack'";
                netUser.truthDetector.violation += Rate;
                break;

            case HackMethod.WallHack:
                str = "'Wall Hack'";
                netUser.truthDetector.violation += Rate;
                break;

            case HackMethod.FallHack:
                str = "'Fall Hack'";
                netUser.truthDetector.violation += truth.threshold;
                break;

            case HackMethod.NetExploit:
                str = "'Network Exploit'";
                netUser.truthDetector.violation += truth.threshold;
                break;

            case HackMethod.OtherHack:
                str = "'Object Hack'";
                netUser.truthDetector.violation += Rate;
                break;

            default:
                return(TruthDetector.ActionTaken.None);
            }
            if (netUser.truthDetector.violation >= truth.threshold)
            {
                if ((MaxViolations != -1) && (userData != null))
                {
                    userData.ViolationDate = DateTime.Now;
                    userData.Violations++;
                }
                netUser.truthDetector.violation = 0;
                if ((MaxViolations != -1) && ((PunishAction.Contains <string>("BAN") || PunishBan) || ((MaxViolations <= 0) || (userData.Violations >= MaxViolations))))
                {
                    Users.SetViolations(userData.SteamID, 0);
                    DateTime period = new DateTime();
                    if (BannedPeriod > 0)
                    {
                        period = DateTime.Now.AddMinutes((double)BannedPeriod);
                    }
                    PunishReason = Config.GetMessageTruth("Truth.Logger.Banned", netUser, str, userData.Violations, new DateTime());
                    if (PunishDetails != "")
                    {
                        Helper.LogError(string.Concat(new object[] { "Violated [", netUser.displayName, ":", netUser.userID, "]: ", PunishDetails }), ViolationDetails);
                    }
                    Helper.Log(PunishReason, true);
                    if (ReportRank > 0)
                    {
                        Broadcast.MessageGM(PunishReason);
                    }
                    if (Core.DatabaseType.Equals("MYSQL"))
                    {
                        MySQL.Update(string.Format(string_0, userData.SteamID, MySQL.QuoteString(PunishReason), MySQL.QuoteString(PunishDetails)));
                        MySQL.Update(string.Format(string_1, userData.SteamID, userData.ViolationDate.ToString("yyyy-MM-dd HH:mm:ss")));
                    }
                    if (PunishAction.Contains <string>("NOTICE"))
                    {
                        Broadcast.Message(ViolationColor, netUser, Config.GetMessageTruth("Truth.Violation.Banned", netUser, str, userData.Violations, period), null, 0f);
                        Broadcast.MessageAll(ViolationColor, Config.GetMessageTruth("Truth.Punish.Banned", netUser, str, userData.Violations, new DateTime()), netUser);
                        Broadcast.MessageAll(ViolationColor, PunishDetails, null);
                    }
                    else
                    {
                        Broadcast.Message(ViolationColor, netUser, Config.GetMessageTruth("Truth.Violation.Banned", netUser, str, userData.Violations, period), null, 0f);
                        Broadcast.Message(ViolationColor, netUser, PunishDetails, null, 0f);
                    }
                    if (BannedBlockIP && !BannedExcludeIP.Contains <string>(userData.LastConnectIP))
                    {
                        Blocklist.Add(userData.LastConnectIP);
                    }
                    Users.Ban(netUser.userID, "Banned for using " + str + " by SERVER.", period, PunishDetails);
                    netUser.Kick(NetError.Facepunch_Kick_Violation, true);
                    return(TruthDetector.ActionTaken.Kicked);
                }
                PunishReason = Config.GetMessageTruth("Truth.Logger.Notice", netUser, str, userData.Violations, new DateTime());
                if (PunishDetails != "")
                {
                    Helper.LogError(string.Concat(new object[] { "Violated [", netUser.displayName, ":", netUser.userID, "]: ", PunishDetails }), ViolationDetails);
                }
                Helper.Log(PunishReason, true);
                if (ReportRank > 0)
                {
                    Broadcast.MessageGM(PunishReason);
                }
                if (Core.DatabaseType.Equals("MYSQL"))
                {
                    MySQL.Update(string.Format(string_0, userData.SteamID, MySQL.QuoteString(PunishReason), MySQL.QuoteString(PunishDetails)));
                    MySQL.Update(string.Format(string_1, userData.SteamID, userData.ViolationDate.ToString("yyyy-MM-dd HH:mm:ss")));
                }
                string text = Config.GetMessageTruth("Truth.Violation.Notice", netUser, str, userData.Violations, new DateTime());
                string str3 = Config.GetMessageTruth("Truth.Punish.Notice", netUser, str, userData.Violations, new DateTime());
                if (PunishAction.Contains <string>("KILL"))
                {
                    text = Config.GetMessageTruth("Truth.Violation.Killed", netUser, str, userData.Violations, new DateTime());
                    str3 = Config.GetMessageTruth("Truth.Punish.Killed", netUser, str, userData.Violations, new DateTime());
                }
                if (PunishAction.Contains <string>("KICK"))
                {
                    text = Config.GetMessageTruth("Truth.Violation.Kicked", netUser, str, userData.Violations, new DateTime());
                    str3 = Config.GetMessageTruth("Truth.Punish.Kicked", netUser, str, userData.Violations, new DateTime());
                }
                if (PunishAction.Contains <string>("NOTICE"))
                {
                    Broadcast.Message(ViolationColor, netUser, text, null, 0f);
                    Broadcast.MessageAll(ViolationColor, str3, netUser);
                    Broadcast.MessageAll(ViolationColor, PunishDetails, null);
                }
                if (PunishAction.Contains <string>("KILL"))
                {
                    TakeDamage.KillSelf(netUser.playerClient.controllable.character, null);
                }
                if (PunishAction.Contains <string>("KICK"))
                {
                    netUser.Kick(NetError.Facepunch_Kick_Violation, true);
                }
            }
            return(actionTaken_0);
        }
예제 #15
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;
     }
 }
예제 #16
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);
                }
            }
        }
예제 #17
0
 public static void Send(NetUser Sender, UserData userData, string Command, string[] Args)
 {
     if (!Enabled)
     {
         Broadcast.Notice(Sender.networkPlayer, "✘", Config.GetMessage("Economy.NotAvailable", Sender, null), 5f);
     }
     else if ((Args != null) && (Args.Length != 0))
     {
         UserData data = Users.Find(Args[0]);
         if (data == null)
         {
             Broadcast.Notice(Sender, "✘", Config.GetMessage("Command.PlayerNoFound", null, Args[0]), 5f);
         }
         else if (data == userData)
         {
             Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Send.Himself", Sender, null), 5f);
         }
         else
         {
             if (!Database.ContainsKey(userData.SteamID))
             {
                 Add(userData.SteamID, 0, 0, 0, 0);
             }
             if (!Database.ContainsKey(data.SteamID))
             {
                 Add(data.SteamID, 0, 0, 0, 0);
             }
             NetUser player   = NetUser.FindByUserID(data.SteamID);
             string  newValue = "";
             ulong   result   = 0L;
             if ((Args.Length > 1) && !ulong.TryParse(Args[1], out result))
             {
                 result = 0L;
             }
             if (result < 1L)
             {
                 result = 0L;
             }
             string str2 = result.ToString("N0") + CurrencySign;
             if (result == 0L)
             {
                 Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Send.NoAmount", Sender, null), 5f);
             }
             else if (Database[userData.SteamID].Balance < result)
             {
                 Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Send.NoHaveAmount", Sender, null).Replace("%SENTAMOUNT%", str2), 5f);
             }
             else
             {
                 BalanceSub(userData.SteamID, result);
                 if (CommandSendTax > 0f)
                 {
                     result -= ((ulong)(result * CommandSendTax)) / 100L;
                     str2    = result.ToString("N0") + CurrencySign;
                 }
                 BalanceAdd(data.SteamID, result);
                 newValue = Database[userData.SteamID].Balance.ToString("N0") + CurrencySign;
                 Broadcast.Notice(Sender, CurrencySign, Config.GetMessage("Economy.Send.SentToPlayer", null, data.Username).Replace("%SENTAMOUNT%", str2), 5f);
                 Broadcast.Message(Sender, Config.GetMessage("Economy.Balance", Sender, null).Replace("%BALANCE%", newValue), null, 0f);
                 if (player != null)
                 {
                     newValue = Database[data.SteamID].Balance.ToString("N0") + CurrencySign;
                     Broadcast.Notice(player, CurrencySign, Config.GetMessage("Economy.Send.SentFromPlayer", null, userData.Username).Replace("%SENTAMOUNT%", str2), 5f);
                     Broadcast.Message(player, Config.GetMessage("Economy.Balance", player, null).Replace("%BALANCE%", newValue), null, 0f);
                 }
             }
         }
     }
     else
     {
         Broadcast.Notice(Sender.networkPlayer, "✘", Config.GetMessageCommand("Command.InvalidSyntax", Command, null), 5f);
     }
 }
예제 #18
0
 public void Message(string text)
 {
     Broadcast.MessageClan(this, text);
 }
예제 #19
0
 public static void ShopBuy(NetUser Sender, UserData userData, string Command, string[] Args)
 {
     if (Shop.Enabled && Shop.CanBuy)
     {
         if (Shop.TradeZoneOnly && ((userData.Zone == null) || !userData.Zone.CanTrade))
         {
             Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.NoTradeZone", Sender, null), 5f);
         }
         else if ((Args != null) && (Args.Length != 0))
         {
             ShopItem item   = null;
             int      result = 0;
             if (int.TryParse(Args[0], out result))
             {
                 item = Shop.FindItem(result);
             }
             else
             {
                 item = Shop.FindItem(Args[0]);
             }
             if ((item != null) && (item.SellPrice != -1))
             {
                 Inventory component = Sender.playerClient.controllable.GetComponent <Inventory>();
                 if ((component != null) && !component.noVacantSlots)
                 {
                     int num2     = item.SellPrice / item.Quantity;
                     int quantity = item.Quantity;
                     if ((Args.Length > 1) && !int.TryParse(Args[1], out quantity))
                     {
                         quantity = item.Quantity;
                     }
                     if (quantity < 1)
                     {
                         quantity = item.Quantity;
                     }
                     ulong amount = (ulong)(num2 * quantity);
                     if (amount > GetBalance(Sender.userID))
                     {
                         string text = Config.GetMessage("Economy.Shop.Buy.NotEnoughBalance", Sender, null).Replace("%TOTALPRICE%", amount.ToString("N0") + CurrencySign).Replace("%ITEMNAME%", item.Name);
                         Broadcast.Notice(Sender, CurrencySign, text, 5f);
                     }
                     else
                     {
                         quantity = Helper.GiveItem(Sender.playerClient, item.itemData, quantity, item.Slots);
                         if (quantity == 0)
                         {
                             Broadcast.Notice(Sender, "✘", Config.GetMessage("Player.Inventory.IsFull", Sender, null), 5f);
                         }
                         else
                         {
                             string newValue = "\"" + item.itemData.name + "\"";
                             if (quantity > 1)
                             {
                                 newValue = quantity.ToString() + " " + newValue;
                             }
                             amount = (ulong)(quantity * num2);
                             BalanceSub(Sender.userID, amount);
                             string str4 = Config.GetMessage("Economy.Shop.Buy.ItemPurchased", Sender, null).Replace("%TOTALPRICE%", amount.ToString("N0") + CurrencySign).Replace("%ITEMNAME%", newValue);
                             Broadcast.Notice(Sender, CurrencySign, str4, 5f);
                             Balance(Sender, userData, "balance", null);
                         }
                     }
                 }
                 else
                 {
                     Broadcast.Notice(Sender, "✘", Config.GetMessage("Player.Inventory.IsFull", Sender, null), 5f);
                 }
             }
             else
             {
                 string str = (item != null) ? item.Name : Args[0];
                 Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.Buy.ItemNotAvailable", Sender, null).Replace("%ITEMNAME%", str), 5f);
             }
         }
         else
         {
             Broadcast.Notice(Sender, "✘", Config.GetMessageCommand("Command.InvalidSyntax", Command, null), 5f);
         }
     }
     else
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.Buy.NotAvailable", Sender, null), 5f);
     }
 }
예제 #20
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;
     }
 }
예제 #21
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);
                }
            }
        }
예제 #22
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);
             }
         }
     }
 }
예제 #23
0
 public static void Send(NetUser Sender, UserData userData, string Command, string[] Args)
 {
     if (!Economy.Enabled)
     {
         Broadcast.Notice(Sender.networkPlayer, "✘", Config.GetMessage("Economy.NotAvailable", Sender, null), 5f);
     }
     else if (Args == null || Args.Length == 0)
     {
         Broadcast.Notice(Sender.networkPlayer, "✘", Config.GetMessageCommand("Command.InvalidSyntax", Command, null), 5f);
     }
     else
     {
         UserData userData2 = Users.Find(Args[0]);
         if (userData2 == null)
         {
             Broadcast.Notice(Sender, "✘", Config.GetMessage("Command.PlayerNoFound", null, Args[0]), 5f);
         }
         else if (userData2 == userData)
         {
             Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Send.Himself", Sender, null), 5f);
         }
         else
         {
             if (!Economy.Database.ContainsKey(userData.SteamID))
             {
                 Economy.Add(userData.SteamID, 0, 0, 0, 0);
             }
             if (!Economy.Database.ContainsKey(userData2.SteamID))
             {
                 Economy.Add(userData2.SteamID, 0, 0, 0, 0);
             }
             NetUser netUser = NetUser.FindByUserID(userData2.SteamID);
             ulong   num     = 0uL;
             if (Args.Length > 1 && !ulong.TryParse(Args[1], out num))
             {
                 num = 0uL;
             }
             if (num < 1uL)
             {
                 num = 0uL;
             }
             string newValue = num.ToString("N0") + Economy.CurrencySign;
             if (num == 0uL)
             {
                 Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Send.NoAmount", Sender, null), 5f);
             }
             else if (Economy.Database[userData.SteamID].Balance < num)
             {
                 Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Send.NoHaveAmount", Sender, null).Replace("%SENTAMOUNT%", newValue), 5f);
             }
             else
             {
                 Economy.BalanceSub(userData.SteamID, num);
                 if (Economy.CommandSendTax > 0f)
                 {
                     num     -= (ulong)(num * Economy.CommandSendTax) / 100uL;
                     newValue = num.ToString("N0") + Economy.CurrencySign;
                 }
                 Economy.BalanceAdd(userData2.SteamID, num);
                 string newValue2 = Economy.Database[userData.SteamID].Balance.ToString("N0") + Economy.CurrencySign;
                 Broadcast.Notice(Sender, Economy.CurrencySign, Config.GetMessage("Economy.Send.SentToPlayer", null, userData2.Username).Replace("%SENTAMOUNT%", newValue), 5f);
                 Broadcast.Message(Sender, Config.GetMessage("Economy.Balance", Sender, null).Replace("%BALANCE%", newValue2), null, 0f);
                 if (netUser != null)
                 {
                     newValue2 = Economy.Database[userData2.SteamID].Balance.ToString("N0") + Economy.CurrencySign;
                     Broadcast.Notice(netUser, Economy.CurrencySign, Config.GetMessage("Economy.Send.SentFromPlayer", null, userData.Username).Replace("%SENTAMOUNT%", newValue), 5f);
                     Broadcast.Message(netUser, Config.GetMessage("Economy.Balance", netUser, null).Replace("%BALANCE%", newValue2), null, 0f);
                 }
             }
         }
     }
 }
예제 #24
0
 public static void DoAirdropEvent()
 {
     if (!Events.bool_2)
     {
         Events.bool_2 = true;
         int tickCount = Environment.TickCount;
         if (Core.Airdrop && Core.AirdropPlanes > 0 && NetCull.connections.Length >= airdrop.min_players)
         {
             bool flag = false;
             int  num  = (int)Math.Abs(EnvironmentControlCenter.Singleton.GetTime());
             if (Core.AirdropInterval && (long)Environment.TickCount >= Events.AirdropNextTime)
             {
                 if (Events.AirdropLastTime != -1L)
                 {
                     flag = true;
                 }
                 Events.AirdropLastTime = (long)Environment.TickCount;
                 Events.AirdropNextTime = Events.AirdropLastTime + (long)(Core.AirdropIntervalTime * 1000);
                 if (server.log > 1)
                 {
                     Helper.Log("[Airdrop.Extended] A next call airdrop after " + Core.AirdropIntervalTime + " second(s).", true);
                 }
             }
             if (Core.AirdropDropTime)
             {
                 if (Events.AirdropNextHour == -1L && Core.AirdropDropTimeHours.Length > 0)
                 {
                     Events.AirdropNextDay = (long)(EnvironmentControlCenter.Singleton.sky.Cycle.Day + 1);
                     if (Core.AirdropDropTimeHours.Length > 2)
                     {
                         Events.AirdropNextHour = (long)Core.AirdropDropTimeHours.Length.Random(0);
                     }
                     else if (Core.AirdropDropTimeHours.Length > 1)
                     {
                         Events.AirdropNextHour = (long)UnityEngine.Random.Range(Core.AirdropDropTimeHours[0], Core.AirdropDropTimeHours[1]);
                     }
                     else
                     {
                         Events.AirdropNextHour = (long)Core.AirdropDropTimeHours[0];
                     }
                     if (server.log > 1)
                     {
                         Helper.Log("[Airdrop.Extended] A next call airdrop set on " + Events.AirdropNextHour + " h.", true);
                     }
                 }
                 else if (Events.AirdropNextHour == (long)num && (long)EnvironmentControlCenter.Singleton.sky.Cycle.Day >= Events.AirdropNextDay)
                 {
                     Events.AirdropNextHour = -1L;
                     flag = true;
                 }
             }
             if (flag)
             {
                 if (Core.AirdropAnnounce)
                 {
                     Broadcast.MessageAll(Config.GetMessage("Airdrop.Incoming", null, null));
                 }
                 for (int i = 0; i < Core.AirdropPlanes; i++)
                 {
                     SupplyDropZone.CallAirDrop();
                 }
             }
         }
         Events.bool_2 = false;
     }
 }
예제 #25
0
 public static void ShopSell(NetUser Sender, UserData userData, string Command, string[] Args)
 {
     if (!Shop.Enabled || !Shop.CanSell)
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.Sell.NotAvailable", Sender, null), 5f);
     }
     else if (Shop.TradeZoneOnly && (userData.Zone == null || !userData.Zone.CanTrade))
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.NoTradeZone", Sender, null), 5f);
     }
     else if (Args == null || Args.Length == 0)
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessageCommand("Command.InvalidSyntax", Command, null), 5f);
     }
     else
     {
         int       item_index = 0;
         Inventory component  = Sender.playerClient.controllable.GetComponent <Inventory>();
         if (!Args[0].Equals("ALL", StringComparison.OrdinalIgnoreCase))
         {
             ShopItem shopItem;
             if (int.TryParse(Args[0], out item_index))
             {
                 shopItem = Shop.FindItem(item_index);
             }
             else
             {
                 shopItem = Shop.FindItem(Args[0]);
             }
             if (shopItem != null)
             {
                 if (shopItem.BuyPrice != -1)
                 {
                     int num  = shopItem.BuyPrice / shopItem.Quantity;
                     int num2 = shopItem.Quantity;
                     if (Args.Length > 1 && !int.TryParse(Args[1], out num2))
                     {
                         num2 = shopItem.Quantity;
                     }
                     if (num2 < 1)
                     {
                         num2 = shopItem.Quantity;
                     }
                     int num3 = Helper.InventoryItemCount(component, shopItem.itemData);
                     if (num3 == 0)
                     {
                         Broadcast.Notice(Sender, Economy.CurrencySign, Config.GetMessage("Economy.Shop.Sell.NotEnoughItem", Sender, null).Replace("%ITEMNAME%", shopItem.Name), 5f);
                         return;
                     }
                     if (num2 > num3)
                     {
                         num2 = num3;
                     }
                     num3 = Helper.InventoryItemRemove(component, shopItem.itemData, num2);
                     string text = "\"" + shopItem.Name + "\"";
                     if (num3 > 1)
                     {
                         text = num3.ToString() + " " + text;
                     }
                     ulong amount = (ulong)((long)(num3 * num));
                     Economy.BalanceAdd(Sender.userID, amount);
                     string text2 = Config.GetMessage("Economy.Shop.Sell.ItemSold", Sender, null);
                     text2 = text2.Replace("%TOTALPRICE%", amount.ToString("N0") + Economy.CurrencySign);
                     text2 = text2.Replace("%ITEMNAME%", text);
                     Broadcast.Notice(Sender, Economy.CurrencySign, text2, 5f);
                     Economy.Balance(Sender, userData, "balance", null);
                     return;
                 }
             }
             string newValue = (shopItem != null) ? shopItem.Name : Args[0];
             Broadcast.Notice(Sender, Economy.CurrencySign, Config.GetMessage("Economy.Shop.Sell.ItemNotAvailable", Sender, null).Replace("%ITEMNAME%", newValue), 5f);
         }
         else
         {
             ulong num4 = 0uL;
             List <IInventoryItem>      list             = new List <IInventoryItem>();
             Inventory.OccupiedIterator occupiedIterator = component.occupiedIterator;
             while (occupiedIterator.Next())
             {
                 ShopItem shopItem = Shop.FindItem(occupiedIterator.item.datablock.name);
                 if (shopItem != null && shopItem.BuyPrice != -1)
                 {
                     int   num5 = occupiedIterator.item.datablock._splittable ? occupiedIterator.item.uses : 1;
                     ulong num6 = (ulong)((long)(shopItem.BuyPrice / shopItem.Quantity) * (long)num5);
                     num4 += num6;
                     list.Add(occupiedIterator.item);
                 }
             }
             if (list.Count > 0)
             {
                 foreach (IInventoryItem current in list)
                 {
                     component.RemoveItem(current);
                 }
                 if (num4 > 0uL)
                 {
                     Economy.BalanceAdd(Sender.userID, num4);
                 }
                 string text3 = Config.GetMessage("Economy.Shop.Sell.AllSold", Sender, null);
                 text3 = text3.Replace("%TOTALPRICE%", num4.ToString("N0") + Economy.CurrencySign);
                 text3 = text3.Replace("%TOTALAMOUNT%", list.Count.ToString());
                 Broadcast.Notice(Sender, Economy.CurrencySign, text3, 5f);
             }
             else
             {
                 Broadcast.Notice(Sender, Economy.CurrencySign, Config.GetMessage("Economy.Shop.Sell.NoNothing", Sender, null), 5f);
             }
         }
     }
 }
예제 #26
0
        public static EventTimer TimeEvent_TeleportTo(NetUser Sender, NetUser Target, string Command, double time)
        {
            Events.Class38 @class = new Events.Class38();
            @class.netUser_0 = Sender;
            @class.netUser_1 = Target;
            @class.string_0  = Command;
            EventTimer result;

            if (Core.CommandTeleportOutdoorsOnly)
            {
                Vector3    position = @class.netUser_1.playerClient.controllable.character.transform.position;
                Collider[] array    = Physics.OverlapSphere(position, 1f, 271975425);
                for (int i = 0; i < array.Length; i++)
                {
                    Collider component = array[i];
                    IDMain   main      = IDBase.GetMain(component);
                    if (!(main == null))
                    {
                        StructureMaster component2 = main.GetComponent <StructureMaster>();
                        if (!(component2 == null) && component2.ownerID != @class.netUser_0.userID && component2.ownerID != @class.netUser_1.userID)
                        {
                            UserData bySteamID = Users.GetBySteamID(component2.ownerID);
                            if (bySteamID == null || (!bySteamID.HasShared(@class.netUser_0.userID) && !bySteamID.HasShared(@class.netUser_1.userID)))
                            {
                                Broadcast.Notice(@class.netUser_0, "☢", Config.GetMessage("Command.Teleport.NoTeleport", @class.netUser_0, @class.netUser_1.displayName), 5f);
                                Broadcast.Notice(@class.netUser_1, "☢", Config.GetMessage("Command.Teleport.NotHere", @class.netUser_1, @class.netUser_0.displayName), 5f);
                                result = null;
                                return(result);
                            }
                        }
                    }
                }
            }
            Broadcast.Message(@class.netUser_0, Config.GetMessage("Command.Teleport.IsConfirm", @class.netUser_0, null).Replace("%USERNAME%", @class.netUser_1.displayName), null, 0f);
            Broadcast.Message(@class.netUser_1, Config.GetMessage("Command.Teleport.Confirmed", @class.netUser_1, null).Replace("%USERNAME%", @class.netUser_0.displayName), null, 0f);
            if (!Character.FindByUser(@class.netUser_1.userID, out @class.character_0))
            {
                result = null;
            }
            else if (time <= 0.0)
            {
                Events.Teleport_PlayerTo(null, @class.netUser_0, @class.netUser_1, @class.string_0, @class.character_0.transform.position);
                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.Target   = @class.netUser_1;
                eventTimer.Command  = @class.string_0;
                Broadcast.Notice(@class.netUser_0, "☢", Config.GetMessage("Command.Teleport.Timewait", @class.netUser_0, null).Replace("%TIME%", eventTimer.TimeLeft.ToString()), 5f);
                Broadcast.Notice(@class.netUser_1, "☢", Config.GetMessage("Command.Teleport.Timewait", @class.netUser_1, null).Replace("%TIME%", eventTimer.TimeLeft.ToString()), 5f);
                eventTimer.Start();
                result = eventTimer;
            }
            return(result);
        }