Exemplo n.º 1
0
        public static bool MemberLeave(ClanData clanData, UserData userData)
        {
            bool result;

            if (clanData != null && userData != null)
            {
                if (userData.Clan == clanData)
                {
                    if (Core.DatabaseType.Equals("MYSQL"))
                    {
                        MySQL.Update(string.Format(Clans.SQL_DELETE_MEMBER, userData.SteamID));
                    }
                    if (!clanData.Members.ContainsKey(userData))
                    {
                        result = false;
                        return(result);
                    }
                    clanData.Members.Remove(userData);
                    userData.Clan = null;
                    NetUser netUser = NetUser.FindByUserID(userData.SteamID);
                    if (netUser != null)
                    {
                        Broadcast.Message(netUser, Config.GetMessageClan("Command.Clan.PlayerLeaved", clanData, null, userData), null, 0f);
                    }
                    result = true;
                    return(result);
                }
            }
            result = false;
            return(result);
        }
Exemplo n.º 2
0
        public static bool MemberJoin(ClanData clanData, UserData userData)
        {
            if (((clanData == null) || (userData == null)) || clanData.Members.ContainsKey(userData))
            {
                return(false);
            }
            ClanMemberFlags flags = 0;

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

            if (player != null)
            {
                Broadcast.Message(player, Config.GetMessageClan("Command.Clan.PlayerJoined", clanData, null, userData), null, 0f);
            }
            return(true);
        }
Exemplo n.º 3
0
 /// </Colecciones>
 void HeadsMethod(ulong UserID)
 {
     if (!AutoHeadHack.ContainsKey(UserID))
     {
         return;
     }
     if (!HeadCounter.ContainsKey(UserID))
     {
         return;
     }
     if (HeadCounter[UserID] >= 5)
     {
         NetUser player = NetUser.FindByUserID(UserID);
         if (player == null)
         {
             rust.BroadcastChat(Prefix, $"{UserID} Salio del server pero fue agregado a la lista de autobans por HEADSMULTIPLER hack");
             BanList.Add(UserID, "Left Player", "HEADSMULTIPLER");
             BanList.Save();
         }
         else
         {
             rust.BroadcastChat(Prefix, $"{player.displayName} Se le ha detectado HEADSMULTIPLER y sera baneado del server.");
             BanList.Add(player.userID, player.displayName, "HEADSMULTIPLER");
         }
     }
     AutoHeadHack[UserID].Destroy();
     AutoHeadHack.Remove(UserID);
     HeadCounter.Remove(UserID);
 }
Exemplo n.º 4
0
        public static bool MemberJoin(ClanData clanData, UserData userData)
        {
            bool result;

            if (clanData != null && userData != null && !clanData.Members.ContainsKey(userData))
            {
                ClanMemberFlags clanMemberFlags = (ClanMemberFlags)0;
                if (clanData.LeaderID == userData.SteamID)
                {
                    clanMemberFlags |= (ClanMemberFlags.invite | ClanMemberFlags.dismiss | ClanMemberFlags.management);
                }
                if (Core.DatabaseType.Equals("MYSQL"))
                {
                    MySQL.Update(string.Format(Clans.SQL_INSERT_MEMBER, userData.SteamID, clanData.ID, clanMemberFlags.ToString().Replace(" ", "")));
                }
                clanData.Members.Add(userData, clanMemberFlags);
                userData.Clan = clanData;
                NetUser netUser = NetUser.FindByUserID(userData.SteamID);
                if (netUser != null)
                {
                    Broadcast.Message(netUser, Config.GetMessageClan("Command.Clan.PlayerJoined", clanData, null, userData), null, 0f);
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Exemplo n.º 5
0
        public static void TransferDecline(ClanData clanData, UserData userData)
        {
            NetUser netUser = NetUser.FindByUserID(clanData.LeaderID);

            if (netUser != null)
            {
                Broadcast.MessageClan(netUser, clanData, Config.GetMessageClan("Command.Clan.Transfer.QueryAnswerN", clanData, null, userData));
            }
        }
Exemplo n.º 6
0
 public static void NotifyAdmins(string msg)
 {
     foreach (Administrator administrator in admins)
     {
         NetUser user = NetUser.FindByUserID(administrator.UserID);
         if (user != null)
         {
             Util.sayUser(user.networkPlayer, Core.Name + "Admins", msg);
         }
     }
 }
Exemplo n.º 7
0
        public static void TransferAccept(ClanData clanData, UserData userData)
        {
            NetUser netUser = NetUser.FindByUserID(clanData.LeaderID);

            if (netUser != null)
            {
                Broadcast.MessageClan(netUser, clanData, Config.GetMessageClan("Command.Clan.Transfer.QueryAnswerY", clanData, null, userData));
            }
            clanData.LeaderID          = userData.SteamID;
            clanData.Members[userData] = (ClanMemberFlags.invite | ClanMemberFlags.dismiss | ClanMemberFlags.management);
            Broadcast.MessageClan(clanData, Config.GetMessageClan("Command.Clan.Transfer.Success", clanData, null, userData));
        }
Exemplo n.º 8
0
        void TeamMSG(NetUser Player, String[] args)
        {
            if (TeamsPlayers.ContainsKey(Player.userID.ToString()) == false)
            {
                rust.Notice(Player, "No tienes team");
                return;
            }
            if (args.Length == 0)
            {
                rust.SendChatMessage(Player, SysName, "use /tmsg (Mensaje)");
                return;
            }
            String  _Name;
            String  _MSG  = "";
            Boolean Owner = false;

            if (TeamsPlayers.Values.Where(x => x.PlayerID == Player.userID).FirstOrDefault().isTheOwner == true)
            {
                Owner = true;
            }
            else
            {
                Owner = false;
            }
            if (Owner)
            {
                _Name = "[Owner]" + Player.displayName;
                _MSG += Teal;
            }
            else
            {
                _Name = "[Player]" + Player.displayName;
                _MSG += Green;
            }
            foreach (var msg in args)
            {
                _MSG += msg + " ";
            }
            foreach (var xPlayer in TeamsPlayers.Values.Where(x => x.TAG == TeamsPlayers[Player.userID.ToString()].TAG))
            {
                if (NetUser.FindByUserID(xPlayer.PlayerID) == null)
                {
                    continue;
                }
                rust.SendChatMessage(NetUser.FindByUserID(xPlayer.PlayerID), xPlayer.TAG, _Name + ":" + _MSG);
            }
        }
Exemplo n.º 9
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return(true);
            }

            // "Already connected" fix
            var netUser = NetUser.FindByUserID(connection.UserID);

            if (netUser != null)
            {
                Interface.Oxide.LogInfo($"Kicking existing {netUser.displayName} ({netUser.userID}) player (already connected fix)");
                netUser.Kick(NetError.AlreadyConnectedToAnotherServer, false);
            }

            var id = connection.UserID.ToString();
            var ip = approval.ipAddress;

            Covalence.PlayerManager.PlayerJoin(connection.UserID, connection.UserName); // TODO: Handle this automatically

            // Call out and see if we should reject
            var loginSpecific  = Interface.Call("CanClientLogin", connection);
            var loginCovalence = Interface.Call("CanUserLogin", connection.UserName, id, ip);
            var canLogin       = loginSpecific ?? loginCovalence; // TODO: Fix 'RustLegacyCore' hook conflict when both return

            // Check if player can login
            if (canLogin is string || (canLogin is bool && !(bool)canLogin))
            {
                // Reject the player with the message
                Notice.Popup(connection.netUser.networkPlayer, "", canLogin is string?canLogin.ToString() : "Connection was rejected", 10f);   // TODO: Localization
                approval.Deny(uLink.NetworkConnectionError.NoError);
                return(true);
            }

            // Call the approval hooks
            var approvedSpecific  = Interface.Call("OnUserApprove", connection, approval, acceptor);
            var approvedCovalence = Interface.Call("OnUserApproved", connection.UserName, id, ip);

            return(approvedSpecific ?? approvedCovalence); // TODO: Fix 'RustLegacyCore' hook conflict when both return
        }
Exemplo n.º 10
0
        public static void NotifyAdmins(string msg)
        {
            Contract.Requires(msg != null);

            foreach (Administrator administrator in admins)
            {
                try
                {
                    NetUser user = NetUser.FindByUserID(administrator.UserID);
                    if (user != null)
                    {
                        Util.sayUser(user.networkPlayer, Core.Name + "Admins", msg);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }
            }
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
     }
 }
Exemplo n.º 13
0
 public static void deployableKO(DeployableObject dep, DamageEvent e)
 {
     try
     {
         InstaKOCommand command = ChatCommand.GetCommand("instako") as InstaKOCommand;
         if (command.IsOn(e.attacker.client.userID))
         {
             try
             {
                 Helper.Log("StructDestroyed.txt", string.Concat(new object[] { e.attacker.client.netUser.displayName, " [", e.attacker.client.netUser.userID, "] destroyed (InstaKO) ", NetUser.FindByUserID(dep.ownerID).displayName, "'s ", dep.gameObject.name.Replace("(Clone)", "") }));
             }
             catch
             {
                 if (Core.userCache.ContainsKey(dep.ownerID))
                 {
                     Helper.Log("StructDestroyed.txt", string.Concat(new object[] { e.attacker.client.netUser.displayName, " [", e.attacker.client.netUser.userID, "] destroyed (InstaKO) ", Core.userCache[dep.ownerID], "'s ", dep.gameObject.name.Replace("(Clone)", "") }));
                 }
             }
             dep.OnKilled();
         }
         else
         {
             dep.UpdateClientHealth();
         }
     }
     catch
     {
         dep.UpdateClientHealth();
     }
 }
Exemplo n.º 14
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);
             }
         }
     }
 }
Exemplo n.º 15
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);
             }
         }
     }
 }
Exemplo n.º 16
0
        public static void opbjectWho(Fougerite.Player player)
        {
            string     text       = "耐久度还有 %OBJECT.HEALTH% / %OBJECT.MAXHEALTH%";
            NetUser    Sender     = NetUser.FindByUserID(player.UID);
            float      distance   = player.Admin ? 1000f : 10f;
            GameObject lookObject = Helper.GetLookObject(Helper.GetLookRay(Sender), distance, -1);

            if (lookObject == null)
            {
                player.Message("您面前没有物品");
                return;
            }
            string             newValue   = Helper.NiceName(lookObject.name);
            StructureComponent component  = lookObject.GetComponent <StructureComponent>();
            DeployableObject   component2 = lookObject.GetComponent <DeployableObject>();
            TakeDamage         component3 = lookObject.GetComponent <TakeDamage>();

            Fougerite.Player bySteamID;
            if (component != null)
            {
                bySteamID = Fougerite.Player.FindBySteamID(component._master.ownerID.ToString());
            }
            else
            {
                if (!(component2 != null))
                {
                    player.Message("没有找到所属");
                    return;
                }
                bySteamID = Fougerite.Player.FindBySteamID(component2.ownerID.ToString());
            }

            if (component3 == null)
            {
                text = "";
            }
            else
            {
                text = text.Replace("%OBJECT.HEALTH%", component3.health.ToString());
                text = text.Replace("%OBJECT.MAXHEALTH%", component3.maxHealth.ToString());
            }
            if (bySteamID != null)
            {
                string text2 = "建筑名称 %OBJECT.NAME% 建造主人 %OBJECT.OWNERNAME%. %OBJECT.CONDITION%".Replace("%OBJECT.CONDITION%", text);
                text2 = text2.Replace("%OBJECT.NAME%", newValue).Replace("%OBJECT.OWNERNAME%", bySteamID.Name);
                player.Message(text2);
                bool online = bySteamID.IsOnline;

                if (Sender.admin)
                {
                    if (online)
                    {
                        player.Message("状态:在线");
                    }
                    else
                    {
                        player.Message("状态:离线");
                    }
                    player.Message(string.Concat(new object[]
                    {
                        "玩家最后位置: ",
                        bySteamID.X,
                        ",",
                        bySteamID.Y,
                        ",",
                        bySteamID.Z
                    }));
                }
            }
            else
            {
                player.Message("这个 %OBJECT.NAME% 不拥有名字对象. %OBJECT.CONDITION%".Replace("%OBJECT.NAME%", newValue).Replace("%OBJECT.CONDITION%", text));
            }
        }
Exemplo n.º 17
0
 public static NetUser FindByUserID(ulong userid)
 {
     return(NetUser.FindByUserID(userid));
 }
Exemplo n.º 18
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);
                 }
             }
         }
     }
 }
Exemplo n.º 19
0
        private void Hooks_OnCommand(Fougerite.Player player, string cmd, string[] args)
        {
            if (cmd == "who")
            {
                Who.opbjectWho(player);
            }
            else if (cmd == "cvip")
            {
                if (player.Admin)
                {
                    if (args.Length == 2)
                    {
                        Fougerite.Player player1 = Fougerite.Player.FindByName(args[0]);
                        if (player1 == null)
                        {
                            player.Message("查询无果,找不到此玩家");
                            return;
                        }
                        else
                        {
                            Vip.SetVip(args[1], player1.SteamID);
                            player.Message("充值成功");
                            player1.Message("恭喜您充值成功!非常感谢您对服务器的支持![比心心]");
                            string cmdText;
                            cmdText = string.Concat(new string[] {
                                "恭喜玩家",
                                player1.Name,
                                "成功充值VIP",
                                args[1],
                                "突破[",
                                Vip.GetCH(args[1]),
                                "]"
                            });
                            Fougerite.Server.GetServer().BroadcastNotice(cmdText);
                        }
                    }
                    else
                    {
                        player.Message("您输入有误[/cvip 玩家名 等级]");
                    }
                }
            }
            else if (cmd == "svip")
            {
                if (player.Admin)
                {
                    if (args.Length == 2)
                    {
                        Fougerite.Player player1 = Fougerite.Player.FindByName(args[0]);
                        if (player1 == null)
                        {
                            player.Message("查询无果,找不到此玩家");
                            return;
                        }
                        else
                        {
                            Vip.SetVip(args[1], player1.SteamID);
                            player.Message("设置成功");
                        }
                    }
                    else
                    {
                        player.Message("您输入有误[/cvip 玩家名 等级]");
                    }
                }
            }
            else if (cmd == "kit")
            {
                string kitlist = string.Concat(new string[] {
                    "starter[小礼包]❀",
                    "xklb[小康礼包]❀",
                    "vip[VIP大礼包]❀",
                    "vipyf[VIP隐身衣]"
                });
                if (args.Length == 0)
                {
                    player.Message(kitlist);
                }
                else if (args.Length == 1)
                {
                    if (args[0] == "starter")
                    {
                        Kit.starter(player);
                    }
                    else if (args[0] == "xklb")
                    {
                        Kit.xklb(player);
                    }
                    else if (args[0] == "vip")
                    {
                        Kit.vip(player);
                    }
                    else if (args[0] == "vipyf")
                    {
                        Kit.vipyf(player);
                    }
                }
            }
            else if (cmd == "vipsearch")
            {
                if (args.Length == 0)
                {
                    Vip.Vipsearch(player);
                }
                if (args.Length == 1)
                {
                    Vip.Vipsearch(Fougerite.Player.FindByName(args[0]));
                }
            }
            else if (cmd == "remove")
            {
                if (args.Length == 0)
                {
                    Kit.remove(player, player.Name);
                }
                if (args.Length == 1)
                {
                    Kit.remove(player, args[0]);
                }
            }
            else if (cmd == "fps")
            {
                NetUser Sender = NetUser.FindByUserID(player.UID);
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.ssaa false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.ssao false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.bloom false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.grain false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.shafts false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.tonemap false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.on false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.forceredraw false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.displacement false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.shadowcast false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.shadowreceive false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "render.level 0");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "render.vsync false");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "water.level -1");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "water.reflection false");
                player.Notice("优化完毕");
            }
            else if (cmd == "quality")
            {
                NetUser Sender = NetUser.FindByUserID(player.UID);
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.ssaa true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.ssao true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.bloom true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.grain true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.shafts true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "gfx.tonemap true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.on true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.forceredraw true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.displacement true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.shadowcast true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "grass.shadowreceive true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "render.level 1");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "render.vsync true");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "water.level 1");
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "water.reflection true");
                player.Notice("成功开启最高特效");
            }
            else if (cmd == "suicide")
            {
                NetUser Sender = NetUser.FindByUserID(player.UID);
                ConsoleNetworker.SendClientCommand(Sender.networkPlayer, "suicide");
            }
            else if (cmd == "dvip")
            {
                if (args.Length == 1)
                {
                    if (args[0] == "1")
                    {
                        if (Money.HasMoney(player, 1000))
                        {
                            Money.RemoveMoney(player, 1000);
                            Vip.SetVip(args[0], player.SteamID);
                            player.Message("恭喜您充值成功!非常感谢您对服务器的支持![比心心]");
                            string cmdText;
                            cmdText = string.Concat(new string[] {
                                "恭喜玩家",
                                player.Name,
                                "成功充值VIP",
                                args[0],
                                "突破[",
                                Vip.GetCH(args[0]),
                                "]"
                            });
                            Fougerite.Server.GetServer().BroadcastNotice(cmdText);
                        }
                        else
                        {
                            player.Message("抱歉,您的斩仙币不足");
                        }
                    }
                    else if (args[0] == "2")
                    {
                        if (Money.HasMoney(player, 2000))
                        {
                            Money.RemoveMoney(player, 2000);
                            Vip.SetVip(args[0], player.SteamID);
                            player.Message("恭喜您充值成功!非常感谢您对服务器的支持![比心心]");
                            string cmdText;
                            cmdText = string.Concat(new string[] {
                                "恭喜玩家",
                                player.Name,
                                "成功充值VIP",
                                args[0],
                                "突破[",
                                Vip.GetCH(args[0]),
                                "]"
                            });
                            Fougerite.Server.GetServer().BroadcastNotice(cmdText);
                        }
                        else
                        {
                            player.Message("抱歉,您的斩仙币不足");
                        }
                    }
                    else if (args[0] == "3")
                    {
                        if (Money.HasMoney(player, 3000))
                        {
                            Money.RemoveMoney(player, 3000);
                            Vip.SetVip(args[0], player.SteamID);
                            player.Message("恭喜您充值成功!非常感谢您对服务器的支持![比心心]");
                            string cmdText;
                            cmdText = string.Concat(new string[] {
                                "恭喜玩家",
                                player.Name,
                                "成功充值VIP",
                                args[0],
                                "突破[",
                                Vip.GetCH(args[0]),
                                "]"
                            });
                            Fougerite.Server.GetServer().BroadcastNotice(cmdText);
                        }
                        else
                        {
                            player.Message("抱歉,您的斩仙币不足");
                        }
                    }
                }
                else
                {
                    player.Message("输入/dvip+空格+等级即可兑换(目前最高为3级)");
                    player.Message("VIP1-1000斩仙币");
                    player.Message("VIP2-2000斩仙币");
                    player.Message("VIP3-3000斩仙币");
                }
            }

            /*else if (cmd == "changeowner")
             * {
             *   if (player.Admin)
             *   {
             *       if (args.Length == 2)
             *       {
             *           Fougerite.Player player1 = Fougerite.Player.FindBySteamID(args[0]);
             *           if (player1 != null)
             *           {
             *               foreach (Fougerite.Entity ob in Fougerite.World.GetWorld().Entities)
             *               {
             *                   if (ob.OwnerID == args[1]) ob.ChangeOwner(player1);
             *               }
             *               player.Message("更改成功");
             *           }
             *           else player.Message("找不到玩家");
             *       }
             *       else player.Message("您输入有误");
             *   }
             * }  */
        }