当前位置: 首页>>代码示例>>C#>>正文


C# Client.GetAccount方法代码示例

本文整理汇总了C#中Client.GetAccount方法的典型用法代码示例。如果您正苦于以下问题:C# Client.GetAccount方法的具体用法?C# Client.GetAccount怎么用?C# Client.GetAccount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client.GetAccount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnPlayerConnect

        public override bool OnPlayerConnect(Client player)
        {
            if(player.IsBanned() || player.IsIPBanned())
            {
                Program.ServerInstance.KickPlayer(player, "You are banned: " + player.GetBan().Reason);

                return false;
            }

            if (player.GetAccount(false) == null)
            {
                Program.ServerInstance.SendChatMessageToPlayer(player, "ACCOUNT", "You can register an account using /register [password]");
            }
            else
            {
                Program.ServerInstance.SendChatMessageToPlayer(player, "ACCOUNT", "Please authenticate to your account using /login [password]");
            }

            Program.ServerInstance.SendNativeCallToPlayer(player, 0x29B487C359E19889, _weatherNames[ServerWeather]);

            Program.ServerInstance.SendNativeCallToPlayer(player, 0x47C3B5848C3E45D8, ServerTime.Hours, ServerTime.Minutes, ServerTime.Seconds);
            Program.ServerInstance.SendNativeCallToPlayer(player, 0x4055E40BD2DBEC1D, true);

            return true;
        }
开发者ID:butich,项目名称:GTACoop,代码行数:25,代码来源:MainFilterscript.cs

示例2: OnPlayerConnect


//.........这里部分代码省略.........
                if (player.DisplayName.StartsWith("RLD!") || player.DisplayName.StartsWith("Player") || player.DisplayName.StartsWith("nosTEAM"))
                {
                    //Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("Kicking {0} for default nickname.", player.DisplayName.ToString()));
                    Program.ServerInstance.KickPlayer(player, "Change your nickname to a proper one. (F9 -> Settings -> Nickname)"); return false;
                }
            }
            if (Properties.Settings.Default.SocialClubOnly) {
                Console.WriteLine(player.Name);
                if (player.Name.ToString() == "RLD!" || player.Name.ToString() == "nosTEAM" || player.Name.ToString() == "Player")
                {
                    Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("Kicking {0} for cracked game.", player.DisplayName.ToString()));
                    Program.ServerInstance.KickPlayer(player, "Buy the game and sign in through social club!"); return false; }
            }
            if (Properties.Settings.Default.KickOnNameDifference)
            {
                if (!player.DisplayName.Equals(player.Name))
                {
                    Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("Kicking {0} for nickname differs from account name.", player.DisplayName.ToString()));
                    Program.ServerInstance.KickPlayer(player, string.Format("Change your nickname to {0}", player.Name)); return false; }
            }
            if (Properties.Settings.Default.KickOnOutdatedScript == true)
            {
                Console.WriteLine(string.Format("[Script Version Check] Got: {0} | Expected: {1}", player.RemoteScriptVersion.ToString(), Properties.Settings.Default.ScriptVersion));
                if (!player.RemoteScriptVersion.ToString().Equals(Properties.Settings.Default.ScriptVersion))
                {
                    Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("Kicking {0} for outdated mod.", player.DisplayName.ToString()));
                    Program.ServerInstance.KickPlayer(player, string.Format("Update your GTACoop mod to version {0}", Properties.Settings.Default.ScriptVersion)); return false;
                }
            }
            if (Properties.Settings.Default.KickOnOutdatedGame)
            {
                Console.WriteLine(string.Format("[Game Version Check] Got: {0} | Expected: {1}", player.GameVersion.ToString(), Properties.Settings.Default.GameVersion.ToString()));
                if (!player.GameVersion.ToString().Equals(Properties.Settings.Default.GameVersion.ToString()))
                {
                    Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("Kicking {0} for outdated game.", player.DisplayName.ToString()));
                    Program.ServerInstance.KickPlayer(player, "Update your GTA V to the newest version!"); return false;
                }
            }
            if (player.IsBanned() || player.IsIPBanned())
            {
                Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("{0} is banned for {1}", player.DisplayName.ToString(), player.GetBan().Reason));
                Program.ServerInstance.KickPlayer(player, "You are banned: " + player.GetBan().Reason); return false;
            }
            if (Properties.Settings.Default.OnlyAsciiNickName)
            {
                if(Encoding.UTF8.GetByteCount(player.DisplayName) != player.DisplayName.Length)
                {
                    //Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("{0} was kicked for non-ascii chars in his nickname.", player.DisplayName.ToString()));
                    Program.ServerInstance.KickPlayer(player, "Remove all non-ascii characters from your nickname."); return false;
                }
            }
            if (Properties.Settings.Default.OnlyAsciiUserName)
            {
                if (Encoding.UTF8.GetByteCount(player.Name) != player.Name.Length)
                {
                    //Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("{0} was kicked for non-ascii chars in his username.", player.DisplayName.ToString()));
                    Program.ServerInstance.KickPlayer(player, "Remove all non-ascii characters from your Social Club username.");return false;
                }
            }
            if (Properties.Settings.Default.LimitNickNames)
            {
                if (player.DisplayName.Length < 3 || player.DisplayName.Length > 33)
                {
                    Program.ServerInstance.KickPlayer(player, "Your nickname has to be between 3 and 33 chars long."); return false;
                }
            }
            /*if (Properties.Settings.Default.AntiClones) // TODO: FixIt
            {
                for (var i = 0; i < Program.ServerInstance.Clients.Count; i++)
                {
                    if (player.DisplayName.Contains(Program.ServerInstance.Clients[i].DisplayName))
                    {
                        player.DisplayName = Program.ServerInstance.Clients[i].DisplayName;
                        Program.ServerInstance.SendChatMessageToAll("SERVER", string.Format("Kicking {0} for clone detected!", Program.ServerInstance.Clients[i].DisplayName.ToString()));
                        Program.ServerInstance.KickPlayer(Program.ServerInstance.Clients[i], "Clone detected!");
                    }
                }
            }*/

            //Program.ServerInstance.SendChatMessageToPlayer(player, "INFO", "Current Server Flags: ");

            Program.ServerInstance.SendChatMessageToPlayer(player, "SERVER", Properties.Settings.Default.MOTD);
            //Program.ServerInstance.SendChatMessageToPlayer(player, "SERVER", string.Format("Welcome to {0}", GTAServer.ServerSettings));
            //var settings = ReadSettings(Program.Location + "Settings.xml");

            if (player.GetAccount(false) == null)
            {
                Program.ServerInstance.SendChatMessageToPlayer(player, "SERVER", "You can register an account using /register [password]");
            }
            else
            {
                Program.ServerInstance.SendChatMessageToPlayer(player, "SERVER", "Please authenticate to your account using /login [password]");
            }

            Program.ServerInstance.SendNativeCallToPlayer(player, 0x29B487C359E19889, _weatherNames[ServerWeather]);

            Program.ServerInstance.SendNativeCallToPlayer(player, 0x47C3B5848C3E45D8, ServerTime.Hours, ServerTime.Minutes, ServerTime.Seconds);
            Program.ServerInstance.SendNativeCallToPlayer(player, 0x4055E40BD2DBEC1D, true);
            return true;
        }
开发者ID:Guad,项目名称:GTACoop,代码行数:101,代码来源:MainFilterscript.cs

示例3: OnChatMessage

        public override bool OnChatMessage(Client sender, string message)
        {
            Account account = sender.GetAccount();
            if (message == "/q")
            {
                Program.ServerInstance.KickPlayer(sender, "You left the server.");
            }
            if (message == "/help")
            {
                Program.ServerInstance.SendChatMessageToPlayer(sender, "SERVER", "Available commands: /help, /info, /stop, /restart, /tp, /godmode, /weather, /time, /kill, /kick, /ban, /register, /login, /logout"); return false;
            }
            if (message == "/afk")
            {
                if (account == null || (int)account.Level < 1)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "SERVER", "Register to use this command."); return false;
                }
                if (sender.afk) { Program.ServerInstance.SendChatMessageToPlayer(sender, "SERVER", "You are already AFK."); return false; }
                sender.afk = true;
                Program.ServerInstance.SendChatMessageToAll(sender.DisplayName, "has gone AFK.");return false;
            }
            if (message == "/back")
            {
                if (account == null || (int)account.Level < 1)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "SERVER", "Register to use this command."); return false;
                }
                if (!sender.afk) { Program.ServerInstance.SendChatMessageToPlayer(sender, "SERVER", "You are not AFK."); return false; }
                Program.ServerInstance.SendChatMessageToAll(sender.DisplayName, "is now back.");sender.afk = false; return false;

            }
            if (message == "/l")
            {
                if (account == null || (int)account.Level < 3)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "SERVER", "Insufficent privileges."); return false;
                }
                for (var i = 0; i < Program.ServerInstance.Clients.Count; i++)
                {
                    try {
                        Client target = Program.ServerInstance.Clients[i];
                        Console.WriteLine(string.Format("" +
                        "Nickname: {0} | " +
                        "Realname: {1} |" +
                        "Ping: {2}ms | " +
                        "IP: {3} | " +
                        "Game Version: {4} | " +
                        "Script Version: {5} | " +
                        "Vehicle Health: {6} | " +
                        "Last Position: {7} | ",
                        target.DisplayName.ToString(),
                        target.Name.ToString(),
                        Math.Round(target.Latency * 1000, MidpointRounding.AwayFromZero).ToString(),
                        target.NetConnection.RemoteEndPoint.Address.ToString(),
                        target.GameVersion.ToString(),
                        target.RemoteScriptVersion.ToString(),
                        target.VehicleHealth.ToString(),
                        target.LastKnownPosition.ToString()));
                    }catch {}
                }
                Program.ServerInstance.SendChatMessageToPlayer(sender, "SERVER", "Printed playerlist to console."); return false; return false;
            }
            if (message.StartsWith("/info"))
            {
                if (account == null || (int)account.Level < 2)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "SERVER", "Insufficent privileges."); return false;
                }
                var args = message.Split();
                if (args.Length <= 1)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "USAGE", "/info [Player Name]"); return false;
                }
                Client target = null;
                lock (Program.ServerInstance.Clients) target = Program.ServerInstance.Clients.FirstOrDefault(c => c.DisplayName.ToLower().StartsWith(args[1].ToLower()));

                if (target == null)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "ERROR", "No such player found: " + args[1]);
                    return false;
                }
                Program.ServerInstance.SendChatMessageToPlayer(sender, "1/2", string.Format("" +
                    "Nickname: {0}\n" +
                    "Realname: {1}\n" +
                    "Ping: {2}ms\n" +
                    "IP: {3}",
                    target.DisplayName.ToString(),
                    target.Name.ToString(),
                    Math.Round(target.Latency * 1000, MidpointRounding.AwayFromZero).ToString(),
                    target.NetConnection.RemoteEndPoint.Address.ToString()));
                Program.ServerInstance.SendChatMessageToPlayer(sender, "2/2", string.Format("" +
                    "Game Version: {0}\n" +
                    "Script Version: {1}\n" +
                    "Vehicle Health: {2}\n" +
                    "Last Position: {3}\n",
                    target.GameVersion.ToString(),
                    target.RemoteScriptVersion.ToString(),
                    target.VehicleHealth.ToString(),
                    target.LastKnownPosition.ToString()));
                return false;
//.........这里部分代码省略.........
开发者ID:Guad,项目名称:GTACoop,代码行数:101,代码来源:MainFilterscript.cs

示例4: OnChatMessage

        public override bool OnChatMessage(Client sender, string message)
        {
            Account account = sender.GetAccount();

            if (message.StartsWith("/tp"))
            {
                if (account == null || (int)account.Level < 1)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "ACCESS DENIED", "Insufficent privileges.");
                    return false;
                }

                var args = message.Split();
                if (args.Length <= 1)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "USAGE", "/tp [Player Name]");
                    return false;
                }

                Client target = null;
                lock (Program.ServerInstance.Clients) target = Program.ServerInstance.Clients.FirstOrDefault(c => c.DisplayName.ToLower().StartsWith(args[1].ToLower()));

                if (target == null)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "ERROR", "No such player found: " + args[1]);
                    return false;
                }

                Program.ServerInstance.GetPlayerPosition(target, o =>
                {
                    var newPos = (Vector3)o;
                    Program.ServerInstance.SetPlayerPosition(sender, newPos);
                });

                Console.WriteLine(string.Format("ADMINTOOLS: {0} has teleported to player {1}", account.Name + " (" + sender.DisplayName + ")", target.Name + " (" + target.DisplayName + ")"));

                return false;
            }

            if (message.StartsWith("/godmode"))
            {
                var args = message.Split();
                if (args.Length <= 1)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "USAGE", "/godmode [Player Name]");
                    return false;
                }

                Client target = null;
                lock (Program.ServerInstance.Clients) target = Program.ServerInstance.Clients.FirstOrDefault(c => c.DisplayName.ToLower().StartsWith(args[1].ToLower()));

                if (target == null)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "ERROR", "No such player found: " + args[1]);
                    return false;
                }

                string salt = "inv+" + target.NetConnection.RemoteUniqueIdentifier;

                Program.ServerInstance.GetNativeCallFromPlayer(target, salt, 0xB721981B2B939E07, new BooleanArgument(),
                    (o) =>
                    {
                        bool isInvincible = (bool) o;
                        Program.ServerInstance.SendChatMessageToPlayer(sender, string.Format("Player {0} is {1}", target.DisplayName, isInvincible ? "~g~invincible." : "~r~mortal."));
                    }, new LocalGamePlayerArgument());

                return false;
            }

            if (message.StartsWith("/weather"))
            {
                if (account == null || (int)account.Level < 1)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "ACCESS DENIED", "Insufficent privileges.");
                    return false;
                }

                var args = message.Split();
                if (args.Length <= 1)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "USAGE", "/weather [Weather ID]");
                    return false;
                }

                int newWeather;
                if (!int.TryParse(args[1], out newWeather))
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "USAGE", "/weather [Weather ID]");
                    return false;
                }

                if (newWeather < 0 || newWeather >= _weatherNames.Length)
                {
                    Program.ServerInstance.SendChatMessageToPlayer(sender, "USAGE", "Weather ID must be between 0 and " + (_weatherNames.Length-1));
                    return false;
                }

                ServerWeather = newWeather;
                Program.ServerInstance.SendNativeCallToAllPlayers(0x29B487C359E19889, _weatherNames[ServerWeather]);

//.........这里部分代码省略.........
开发者ID:butich,项目名称:GTACoop,代码行数:101,代码来源:MainFilterscript.cs

示例5: Run

        public static int Run(ExportOptions options, Client client, AuthManager authManager)
        {
            string exportDir = options.Path ?? Directory.GetCurrentDirectory();

            if (string.IsNullOrEmpty(options.Container))
            {
                var accountData = client.GetAccount().Result;
                if (accountData.IsSuccess)
                {
                    if (accountData.Containers != null && accountData.Containers.Count > 0)
                    {
                        var exporter = new Exporter(client, authManager.Credentials());

                        if (string.IsNullOrEmpty(options.Prefix))
                        {
                            exporter.GetObjects(accountData.Containers, exportDir);
                        }
                        else
                        {
                            exporter.GetObjectsWithPrefix(options.Prefix, accountData.Containers, exportDir);
                        }
                    }
                    else
                    {
                        Console.WriteLine("No containers found");
                    }
                }
                else
                {
                    Logger.LogError(accountData.Reason);
                }
            }

            return 0;
        }
开发者ID:vtfuture,项目名称:SwiftClient,代码行数:35,代码来源:ExportCommand.cs

示例6: Run

        public static int Run(ListOptions options, Client client)
        {
            if (string.IsNullOrEmpty(options.Container))
            {
                var accountData = client.GetAccount().Result;
                if (accountData.IsSuccess)
                {
                    if (accountData.Containers != null && accountData.Containers.Count > 0)
                    {
                        var list = new List<SwiftContainer>();
                        foreach (var c in accountData.Containers)
                        {
                            list.Add(new SwiftContainer
                            {
                                Bytes = c.Bytes,
                                Container = c.Container,
                                Objects = c.Objects
                            });
                        }

                        var table = list.ToStringTable(
                            u => u.Container,
                            u => u.Objects,
                            u => u.Size
                        );
                        Console.WriteLine(table);
                    }
                    else
                    {
                        Console.WriteLine("No containers found");
                    }
                }
                else
                {
                    Logger.LogError(accountData.Reason);
                }
            }
            else
            {
                var queryParams = new Dictionary<string, string>();

                if (!string.IsNullOrEmpty(options.Delimiter))
                {
                    queryParams.Add("delimiter", options.Delimiter);
                }

                if (!string.IsNullOrEmpty(options.Prefix))
                {
                    queryParams.Add("prefix", options.Prefix);
                }

                var containerData = client.GetContainer(options.Container, null, queryParams).Result;
                if (containerData.IsSuccess)
                {
                    if (containerData.Objects != null && containerData.Objects.Count > 0)
                    {
                        var list = new List<SwiftObject>();
                        foreach (var c in containerData.Objects)
                        {
                            list.Add(new SwiftObject
                            {
                                Bytes = c.Bytes,
                                ContentType = c.ContentType,
                                Hash = c.Hash,
                                LastModified = c.LastModified,
                                Object = c.Object
                            });
                        }

                        var table = list.ToStringTable(
                            u => u.Object,
                            u => u.Size,
                            u => u.LastModified,
                            u => u.ContentType
                        );
                        Console.WriteLine(table);
                    }
                    else
                    {
                        Console.WriteLine($"Container is empty");
                    }
                }
                else
                {
                    Logger.LogError(containerData.Reason);
                }
            }
            return 0;
        }
开发者ID:vtfuture,项目名称:SwiftClient,代码行数:89,代码来源:ListCommand.cs


注:本文中的Client.GetAccount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。