Пример #1
0
        private void OnClientEventTrigger(Client sender, string eventName, params object[] arguments)
        {
            if (eventName == "ScoreboardPopulate")
            {
                PopulateScoreboard(sender);
            }
            else if (eventName == "SettingsSetPerformance")
            {
                Player p = Player.PlayerData[sender];

                p.MasterAccount.PerformanceSetting = (int)arguments[0];
                API.SendInfoNotification(sender, "Performance Setting Changed", 5);

                MasterRepository.UpdateAsync(p.MasterAccount);
            }
            else if (eventName == "KickPlayer")
            {
                Player p = Player.GetPlayerData(arguments[0].ToString());
                if (p == null)
                {
                    PopulateScoreboard(sender); return;
                }
                Player.PlayerData[sender].ScoreboardActionPlayer = p;
                API.ShowInputPrompt(sender, "KickPlayerConfirm", "Kick Player: " + p.Username.Roleplay(),
                                    "Please provide the reason for kicking " + p.Username.Roleplay() + "?", "Kick", "Cancel");
            }
            else if (eventName == "KickPlayerConfirm")
            {
                if ((int)arguments[0] == 1)
                {
                    Player.PlayerData[sender].ScoreboardActionPlayer.Client.kick(arguments[1].ToString());
                }
            }

            else if (eventName == "SpecPlayer")
            {
                new PlayerAdminCommands().SpectatePlayer(sender, arguments[0].ToString());
            }
            else if (eventName == "TeleportToPlayer")
            {
                new PlayerAdminCommands().GoToPlayer(sender, arguments[0].ToString());
            }
        }
Пример #2
0
        public async void Login(Client sender, string username, string password)
        {
            Master masterAccount;

            if (username.Contains("@"))
            {
                masterAccount = await MasterRepository.GetMasterDataByEmail(username);
            }
            else
            {
                masterAccount = await MasterRepository.GetMasterDataByName(username);
            }

            if (masterAccount != null)
            {
                if (Crypter.CheckPassword(password, masterAccount.Password))
                {
                    string[]      charNames = new string[5];
                    List <string> charImgs  = new List <string>()
                    {
                        "", "", "", "", ""
                    };
                    string[] factions = new string[5];
                    masterAccount.Players = await PlayerRepository.GetAllPlayerDataByMasterAccount(masterAccount);

                    masterAccount.Client = sender;
                    int count = 0;
                    foreach (Player p in masterAccount.Players)
                    {
                        charNames[count] = p.Username.Roleplay();
                        charImgs[count]  = p.Skin == 797459875 ?  Images.SkinBlobs[p.Skin] : "";
                        if (p.FactionId != 0)
                        {
                            factions[count] =
                                $"{FactionRepository.GetFactionById(p.FactionId).Name}<br/>{RankRepository.GetRankByFactionAndId(p.FactionId, p.FactionRank).Title}";
                        }
                        else
                        {
                            factions[count] = "Civilian";
                        }
                        count++;
                    }

                    Master.MasterData.Add(masterAccount);
                    API.triggerClientEvent(sender, "playerLogResult", "success", masterAccount.Players.Count,
                                           string.Join(",", charNames), string.Join(",", factions), string.Join(".", charImgs));

                    masterAccount.LatestLogin = Server.Date;
                    masterAccount.LatestIP    = sender.address;

                    masterAccount.ActiveConnectionLog = new ConnectionLog(masterAccount.Id, -1, API.getPlayerAddress(sender));
                    ConnectionLogRepository.AddNew(masterAccount.ActiveConnectionLog);
                    MasterRepository.UpdateAsync(masterAccount);
                    masterAccount.AdminLevel = 6;
                }
                else
                {
                    API.triggerClientEvent(sender, "playerLogResult", "incorrect-pass");
                    API.SendErrorNotification(sender, "You have entered an incorrect password");
                }
            }
            else
            {
                API.triggerClientEvent(sender, "playerLogResult", "invalid-user");
                API.SendErrorNotification(sender, "You have entered an invalid username");
            }
        }