예제 #1
0
        public static void EventDisablePvP(NetUser netUser, string Command)
        {
            Class40 class2 = new Class40 {
                netUser_0 = netUser,
                string_0  = Command
            };
            EventTimer timer = Timer.Find(new Predicate <EventTimer>(class2.method_0));

            if (timer != null)
            {
                timer.Dispose();
                if (class2.netUser_0 != null)
                {
                    Users.SetFlags(class2.netUser_0.userID, UserFlags.nopvp, true);
                    int num = Core.CommandNoPVPDuration + Core.CommandNoPVPCountdown;
                    if (num > 0)
                    {
                        Users.CountdownAdd(class2.netUser_0.userID, new Countdown(class2.string_0, (double)num));
                    }
                    TimeSpan span = TimeSpan.FromSeconds((double)Core.CommandNoPVPDuration);
                    Broadcast.Notice(class2.netUser_0, "☢", Config.GetMessage("Command.PvP.Disabled", class2.netUser_0, null).Replace("%TIME%", string.Format("{0}:{1:D2}", span.Minutes, span.Seconds)), 5f);
                    Broadcast.NoticeAll("☢", Config.GetMessage("Command.PvP.NoticeDisabled", class2.netUser_0, null), class2.netUser_0, 5f);
                }
            }
        }
예제 #2
0
 public static void Teleport_HomeWarp(object obj, NetUser Sender, string command, Vector3 pos)
 {
     if ((obj != null) && (obj is EventTimer))
     {
         (obj as EventTimer).Dispose();
     }
     if (Economy.Enabled && (Core.CommandHomePayment > 0L))
     {
         UserEconomy economy  = Economy.Get(Sender.userID);
         string      newValue = Core.CommandHomePayment.ToString("N0") + Economy.CurrencySign;
         if (economy.Balance < Core.CommandHomePayment)
         {
             Broadcast.Notice(Sender, "☢", Config.GetMessage("Command.Home.NoEnoughCurrency", Sender, null).Replace("%PRICE%", newValue), 5f);
             return;
         }
         economy.Balance -= Core.CommandHomePayment;
         string str2 = economy.Balance.ToString("N0") + Economy.CurrencySign;
         Broadcast.Message(Sender, Config.GetMessage("Economy.Balance", Sender, null).Replace("%BALANCE%", str2), null, 0f);
     }
     if (Core.CommandHomeCountdown > 0)
     {
         Users.CountdownAdd(Sender.userID, new Countdown(command, (double)Core.CommandHomeCountdown));
     }
     Broadcast.Notice(Sender, "☢", Config.GetMessage("Command.Home.Return", Sender, null), 5f);
     Helper.TeleportTo(Sender, pos);
 }
예제 #3
0
 public static void Teleport_PlayerTo(object obj, NetUser Sender, NetUser Target, string command, Vector3 pos)
 {
     if (obj != null && obj is EventTimer)
     {
         (obj as EventTimer).Dispose();
     }
     if (Economy.Enabled && Core.CommandTeleportPayment > 0uL)
     {
         UserEconomy userEconomy = Economy.Get(Sender.userID);
         string      newValue    = Core.CommandTeleportPayment.ToString("N0") + Economy.CurrencySign;
         if (userEconomy.Balance < Core.CommandTeleportPayment)
         {
             Broadcast.Notice(Sender, "☢", Config.GetMessage("Command.Teleport.NoEnoughCurrency", Sender, null).Replace("%PRICE%", newValue), 5f);
             return;
         }
         userEconomy.Balance -= Core.CommandTeleportPayment;
         string newValue2 = userEconomy.Balance.ToString("N0") + Economy.CurrencySign;
         Broadcast.Message(Sender, Config.GetMessage("Economy.Balance", Sender, null).Replace("%BALANCE%", newValue2), null, 0f);
     }
     Broadcast.Notice(Sender, "☢", Config.GetMessage("Command.Teleport.TeleportOnPlayer", Sender, null).Replace("%USERNAME%", Target.displayName), 5f);
     Broadcast.Notice(Target, "☢", Config.GetMessage("Command.Teleport.TeleportedPlayer", Target, null).Replace("%USERNAME%", Sender.displayName), 5f);
     if (Core.CommandTeleportCountdown > 0)
     {
         Users.CountdownAdd(Sender.userID, new Countdown(command, (double)Core.CommandTeleportCountdown));
     }
     Helper.TeleportTo(Sender, pos);
 }
예제 #4
0
 public static void ShopList(NetUser Sender, UserData userData, string Command, string[] Args)
 {
     if (!Shop.Enabled)
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.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
     {
         int             num  = 0;
         string          text = null;
         List <ShopItem> list = null;
         if (Args != null && Args.Length > 0)
         {
             if (int.TryParse(Args[0], out num))
             {
                 list = Shop.GetItems(num, out text);
             }
             if (list == null)
             {
                 list = Shop.GetItems(Args[0], out num);
             }
         }
         if (list == null)
         {
             list = Shop.dictionary_0[Shop.shopGroup_0];
         }
         foreach (ShopItem current in list)
         {
             string newValue  = (current.BuyPrice > 0) ? (current.BuyPrice + Economy.CurrencySign) : "None";
             string newValue2 = (current.SellPrice > 0) ? (current.SellPrice + Economy.CurrencySign) : "None";
             string text2     = Config.GetMessage("Economy.Shop.ListItem", Sender, null);
             text2 = text2.Replace("%INDEX%", current.Index.ToString());
             text2 = text2.Replace("%ITEMNAME%", current.Name);
             text2 = text2.Replace("%SELLPRICE%", newValue2);
             text2 = text2.Replace("%BUYPRICE%", newValue);
             text2 = text2.Replace("%QUANTITY%", current.Quantity.ToString());
             Broadcast.Message(Sender, text2, null, 0f);
         }
         if (num == 0)
         {
             foreach (ShopGroup current2 in Shop.dictionary_0.Keys)
             {
                 if (current2.Name != null && current2.Index != 0)
                 {
                     string text3 = Config.GetMessage("Economy.Shop.ListGroup", Sender, null);
                     text3 = text3.Replace("%INDEX%", current2.Index.ToString());
                     text3 = text3.Replace("%GROUPNAME%", current2.Name);
                     Broadcast.Message(Sender, text3, null, 0f);
                 }
             }
         }
         Broadcast.Message(Sender, Config.GetMessage("Economy.Shop.Help", Sender, null), null, 0f);
     }
 }
예제 #5
0
        public static EventTimer TimeEvent_TeleportTo(NetUser Sender, NetUser Target, string Command, double time)
        {
            Class38 class2 = new Class38 {
                netUser_0 = Sender,
                netUser_1 = Target,
                string_0  = Command
            };

            if (Core.CommandTeleportOutdoorsOnly)
            {
                foreach (Collider collider in Physics.OverlapSphere(class2.netUser_1.playerClient.controllable.character.transform.position, 1f, 0x10360401))
                {
                    IDMain main = IDBase.GetMain(collider);
                    if (main != null)
                    {
                        StructureMaster component = main.GetComponent <StructureMaster>();
                        if (((component != null) && (component.ownerID != class2.netUser_0.userID)) && (component.ownerID != class2.netUser_1.userID))
                        {
                            UserData bySteamID = Users.GetBySteamID(component.ownerID);
                            if ((bySteamID == null) || (!bySteamID.HasShared(class2.netUser_0.userID) && !bySteamID.HasShared(class2.netUser_1.userID)))
                            {
                                Broadcast.Notice(class2.netUser_0, "☢", Config.GetMessage("Command.Teleport.NoTeleport", class2.netUser_0, class2.netUser_1.displayName), 5f);
                                Broadcast.Notice(class2.netUser_1, "☢", Config.GetMessage("Command.Teleport.NotHere", class2.netUser_1, class2.netUser_0.displayName), 5f);
                                return(null);
                            }
                        }
                    }
                }
            }
            Broadcast.Message(class2.netUser_0, Config.GetMessage("Command.Teleport.IsConfirm", class2.netUser_0, null).Replace("%USERNAME%", class2.netUser_1.displayName), null, 0f);
            Broadcast.Message(class2.netUser_1, Config.GetMessage("Command.Teleport.Confirmed", class2.netUser_1, null).Replace("%USERNAME%", class2.netUser_0.displayName), null, 0f);
            if (!Character.FindByUser(class2.netUser_1.userID, out class2.character_0))
            {
                return(null);
            }
            if (time <= 0.0)
            {
                Teleport_PlayerTo(null, class2.netUser_0, class2.netUser_1, class2.string_0, class2.character_0.transform.position);
                return(null);
            }
            EventTimer timer = new EventTimer {
                Interval  = time * 1000.0,
                AutoReset = false
            };

            timer.Elapsed += new ElapsedEventHandler(class2.method_0);
            timer.Sender   = class2.netUser_0;
            timer.Target   = class2.netUser_1;
            timer.Command  = class2.string_0;
            Broadcast.Notice(class2.netUser_0, "☢", Config.GetMessage("Command.Teleport.Timewait", class2.netUser_0, null).Replace("%TIME%", timer.TimeLeft.ToString()), 5f);
            Broadcast.Notice(class2.netUser_1, "☢", Config.GetMessage("Command.Teleport.Timewait", class2.netUser_1, null).Replace("%TIME%", timer.TimeLeft.ToString()), 5f);
            timer.Start();
            return(timer);
        }
예제 #6
0
 public static void Teleport_ClanWarp(object obj, NetUser netUser, string command, ClanData clan)
 {
     if (obj != null && obj is EventTimer)
     {
         (obj as EventTimer).Dispose();
     }
     Helper.TeleportTo(netUser, clan.Location);
     if (clan.Level.WarpCountdown > 0u)
     {
         Users.CountdownAdd(netUser.userID, new Countdown(command, clan.Level.WarpCountdown));
     }
     Broadcast.Notice(netUser, "☢", Config.GetMessage("Command.Clan.Warp.Warped", netUser, null), 5f);
 }
예제 #7
0
 public static void ShopList(NetUser Sender, UserData userData, string Command, string[] Args)
 {
     if (!Shop.Enabled)
     {
         Broadcast.Notice(Sender, "✘", Config.GetMessage("Economy.Shop.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
     {
         int    result = 0;
         string str    = null;
         System.Collections.Generic.List <ShopItem> items = null;
         if ((Args != null) && (Args.Length > 0))
         {
             if (int.TryParse(Args[0], out result))
             {
                 items = Shop.GetItems(result, out str);
             }
             if (items == null)
             {
                 items = Shop.GetItems(Args[0], out result);
             }
         }
         if (items == null)
         {
             items = Shop.dictionary_0[Shop.shopGroup_0];
         }
         foreach (ShopItem item in items)
         {
             string newValue = (item.BuyPrice > 0) ? (item.BuyPrice + CurrencySign) : "None";
             string str3     = (item.SellPrice > 0) ? (item.SellPrice + CurrencySign) : "None";
             string text     = Config.GetMessage("Economy.Shop.ListItem", Sender, null).Replace("%INDEX%", item.Index.ToString()).Replace("%ITEMNAME%", item.Name).Replace("%SELLPRICE%", str3).Replace("%BUYPRICE%", newValue).Replace("%QUANTITY%", item.Quantity.ToString());
             Broadcast.Message(Sender, text, null, 0f);
         }
         if (result == 0)
         {
             foreach (ShopGroup group in Shop.dictionary_0.Keys)
             {
                 if ((group.Name != null) && (group.Index != 0))
                 {
                     string str5 = Config.GetMessage("Economy.Shop.ListGroup", Sender, null).Replace("%INDEX%", group.Index.ToString()).Replace("%GROUPNAME%", group.Name);
                     Broadcast.Message(Sender, str5, null, 0f);
                 }
             }
         }
         Broadcast.Message(Sender, Config.GetMessage("Economy.Shop.Help", Sender, null), null, 0f);
     }
 }
예제 #8
0
        public static void PlayerWarp(NetUser netUser, UserData user, WorldZone moveZone)
        {
            Zones.Class57 @class = new Zones.Class57();
            @class.netUser_0   = netUser;
            @class.worldZone_0 = moveZone;
            EventTimer eventTimer = Events.Timer.Find(new Predicate <EventTimer>(@class.method_0));

            if (eventTimer != null)
            {
                eventTimer.Dispose();
            }
            if (@class.netUser_0 != null)
            {
                int index = UnityEngine.Random.Range(0, @class.worldZone_0.WarpZone.Spawns.Count);
                Helper.TeleportTo(@class.netUser_0, @class.worldZone_0.WarpZone.Spawns[index]);
                Broadcast.Notice(@class.netUser_0, "☢", Config.GetMessageTeleport("Player.WarpZone.Teleported", @class.netUser_0, @class.worldZone_0, null), 2f);
            }
        }
예제 #9
0
        public static void PlayerWarp(NetUser netUser, UserData user, WorldZone moveZone)
        {
            Class57 class2 = new Class57 {
                netUser_0   = netUser,
                worldZone_0 = moveZone
            };
            EventTimer timer = Events.Timer.Find(new Predicate <EventTimer>(class2.method_0));

            if (timer != null)
            {
                timer.Dispose();
            }
            if (class2.netUser_0 != null)
            {
                int num = UnityEngine.Random.Range(0, class2.worldZone_0.WarpZone.Spawns.Count);
                Helper.TeleportTo(class2.netUser_0, class2.worldZone_0.WarpZone.Spawns[num]);
                Broadcast.Notice(class2.netUser_0, "☢", Config.GetMessageTeleport("Player.WarpZone.Teleported", class2.netUser_0, class2.worldZone_0, null), 2f);
            }
        }
예제 #10
0
 public static void Notice(NetUser player, string icon, string text, float duration = 5f)
 {
     try
     {
         if (!text.IsEmpty())
         {
             if (player == null)
             {
                 ConsoleSystem.Print(text, false);
             }
             else
             {
                 Broadcast.Notice(player.networkPlayer, icon, text, duration);
             }
         }
     }
     catch (Exception ex)
     {
         Debug.Log("ERROR: " + ex.Message);
     }
 }
예제 #11
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);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #12
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);
                 }
             }
         }
     }
 }
예제 #13
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);
                 }
             }
         }
     }
 }
예제 #14
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);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #15
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);
     }
 }
예제 #16
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);
         }
     }
 }
예제 #17
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);
     }
 }
예제 #18
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);
     }
 }
예제 #19
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);
        }
예제 #20
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);
             }
         }
     }
 }
예제 #21
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);
     }
 }
예제 #22
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);
        }
예제 #23
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);
             }
         }
     }
 }
예제 #24
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);
             }
         }
     }
 }