public (Dialog, bool) GetObjectListDialog(int page, string leftButtonText,
                                                  EventHandler <DialogResponseEventArgs> action)
        {
            if (page < 0)
            {
                return(null, false);
            }

            var objects       = DynamicObject.All.Skip(50 * page).Take(50);
            var tablistDialog = new TablistDialog($"Obiekty - strona {page.ToString()}",
                                                  new[] { "ID", "Model", "Nazwa", "X", "Y", "Z", "VW", "INT" },
                                                  leftButtonText, "Następny");
            bool ok = false;

            foreach (var o in objects)
            {
                ok = true;
                tablistDialog.Add(o.Id.ToString(), o.ModelId.ToString(), o.ToString(),
                                  o.Position.X.ToString(CultureInfo.CurrentCulture),
                                  o.Position.Y.ToString(CultureInfo.CurrentCulture),
                                  o.Position.Z.ToString(CultureInfo.CurrentCulture),
                                  o.World.ToString(), o.Interior.ToString());
            }

            return(tablistDialog, ok);
        }
Esempio n. 2
0
    public static bool ShowBans(Player player)
    {
        long rows = 0;

        using var con    = CreateConnection();
        cmd.CommandText  = $"SELECT * FROM banned_players;";
        using var reader = cmd.ExecuteReader();
        if (reader.HasRows)
        {
            var dialog = new TablistDialog($" ", new[] { "Name", "Start Date", "Expiry Date", "Days Left" }, "Cerrar");
            while (reader.Read())
            {
                var expiryDate = reader.GetDateTime("expiryDate");
                var diff       = (expiryDate.Date - DateTime.Now.Date).Days;
                dialog.Add(
                    new[]
                {
                    reader.GetString("bannedPlayer"),
                    ParseData.ToStringDateTime(reader.GetDateTime("startDate")),
                    ParseData.ToStringDateTime(expiryDate),
                    (diff <= 0 ? "0" : diff.ToString())
                }
                    );
                ++rows;
            }
            dialog.Caption = $"Banned Accounts: {rows}";
            dialog.Show(player);
            return(true);
        }
        return(false);
    }
Esempio n. 3
0
            private static void ModelsDialogCreate(Player player)
            {
                var action = new EventHandler <DialogResponseEventArgs>((o, args) =>
                {
                    if (args.DialogButton == DialogButton.Left)
                    {
                        player.SendClientMessage($"Stworzyłeś obiekt o modelu {args.InputText}.");
                        player.ObjectEditor.CreateObjectMode(new MruDynamicObject(Int32.Parse(args.InputText), player.Position));
                    }
                    else
                    {
                        ModelsDialogCreate(player);
                    }
                });

                var categoriesDialog = new ListDialog("Kategorie modeli", "Wyjdź", "Wybierz");

                categoriesDialog.AddItems(Objects.Objects.ObjectModelsCategory.Keys);
                categoriesDialog.Response += (sender, args) =>
                {
                    var tablistDialog = new TablistDialog($"Modele - Kategoria {args.InputText}",
                                                          new[] { "Model", "Nazwa", "Rozmiar", "Tagi" },
                                                          "Stwórz", "Wróć");
                    foreach (var objectModel in Objects.Objects.ObjectModelsCategory[args.InputText])
                    {
                        var o = objectModel.Value;
                        tablistDialog.Add(o.Model.ToString(), o.Name,
                                          o.Size.ToString(CultureInfo.CurrentCulture), String.Join(", ", o.Tags));
                    }

                    tablistDialog.Response += action;
                    tablistDialog.Show(player);
                };
                categoriesDialog.Show(player);
            }
Esempio n. 4
0
    public static void UsersList(Player player)
    {
        var users = new TablistDialog(
            $"{TeamAlpha.OtherColor}Alpha: {TeamAlpha.Members} {TeamBeta.OtherColor}Beta: {TeamBeta.Members}",
            new[] {
            "Id",
            "Name",
            "Kills",
            "Deaths"
        }, "Cerrar", "");

        TeamAlpha.Players.Sort((a, b) => b.Kills - a.Kills);
        TeamBeta.Players.Sort((a, b) => b.Kills - a.Kills);
        foreach (Player player1 in TeamAlpha.Players)
        {
            users.Add(player1.ToString());
        }
        if (TeamAlpha.Members > 0)
        {
            users.Add(" ", " ", " ", " ");
        }
        foreach (Player player1 in TeamBeta.Players)
        {
            users.Add(player1.ToString());
        }
        users.Show(player);
    }
Esempio n. 5
0
        private void BuildInventoryDialog(Player player)
        {
            listInventory = new TablistDialog("Inventaire", new[] { "Nom", "Quantité" }, "Sélectionner", "Quitter");
            int         maxSpaceContainer  = player.ActiveCharacter.Inventory.MaxSpace;
            List <Item> listItemsContainer = player.ActiveCharacter.Inventory.ListItems;
            int         i = 0;

            foreach (Item item in listItemsContainer)
            {
                listInventory.Add(new[]
                {
                    item.Name,
                    item.Quantity.ToString()
                });
                i++;
            }
            if (i < maxSpaceContainer)
            {
                for (int a = 0; a < (maxSpaceContainer - i); a++)
                {
                    listInventory.Add(new[]
                    {
                        Color.Green + "Vide" + Color.White,
                        "0"
                    });
                }
            }
            listInventory.Show(player);
        }
    public static void PacketWeapons(Player player)
    {
        if (player.ListGuns.Count == 0)
        {
            player.SendClientMessage(Color.Red, "Error: No tienes ningún elemento en tu paquete de armas.");
            return;
        }
        var packet = new TablistDialog("Packet Weapons", 1, "Eliminar", "Cerrar");

        foreach (Gun gun in player.ListGuns)
        {
            packet.Add(gun.Weapon.ToString());
        }
        packet.Show(player);
        packet.Response += (sender, e) =>
        {
            if (e.DialogButton == DialogButton.Left)
            {
                player.SendClientMessage(Color.Red, $"[Weapon]: {Color.Yellow}{player.ListGuns[e.ListItem].Weapon} se eliminó de tu paquete de armas.");
                player.RemoveWeapon(e.ListItem);
                packet.Clear();
                foreach (Gun gun in player.ListGuns)
                {
                    packet.Add(gun.Weapon.ToString());
                }
                packet.Show(player);
            }
        };
    }
Esempio n. 7
0
 public void ShowTopTen(string campus, string nameColumn)
 {
     try
     {
         using var con = CreateConnection();
         int position  = 0;
         var dialogTop = new TablistDialog("Top Ten", new[] { "Position", "Name", $"{nameColumn}" }, "Atrás", "Cerrar");
         cmd.CommandText  = $"SELECT namePlayer, {campus} FROM players ORDER BY {campus} DESC LIMIT 10;";
         using var reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             dialogTop.Add(new[] { $"#{++position}", reader.GetString("namePlayer"), reader.GetInt32(campus).ToString() });
         }
         dialogTop.Response += (s, e) =>
         {
             if (e.DialogButton == DialogButton.Left)
             {
                 DialogMain.Show(Sender);
             }
         };
         dialogTop.Show(Sender);
     }
     catch (MySqlException e)
     {
         Sender.SendErrorMessage(e);
     }
 }
Esempio n. 8
0
 public CharacterSelectFlow(Player player)
 {
     _player = player;
     _player.SendClientMessage(Color.GreenYellow, "Wybierz swoją postać aby rozpocząć rozgrywkę.");
     _dialog = new TablistDialog("Wybór postaci", new []
     {
         "Nick", "Level"
     }, "Wybierz", "Wyjdź");
     _dialog.Response += DialogOnResponse;
     ChosenCharacter  += OnPlayerChosenCharacter;
 }
Esempio n. 9
0
    private static void ChangeTeam(Player player)
    {
        if (player.Team == BasePlayer.NoTeam)
        {
            player.SendClientMessage(Color.Red, "Error: Usted no pertenece a ningún equipo.");
            return;
        }
        TeamAlpha.GetMessageTeamEnable(out var msgAlpha, false);
        TeamBeta.GetMessageTeamEnable(out var msgBeta, false);
        var ct = new TablistDialog("Change Team",
                                   new[] {
            "Name",
            "Users",
            "Availability"
        }, "Seleccionar", "Cerrar");

        ct.ShowDialog(player);
        ct.Response += (sender, e) =>
        {
            if (e.DialogButton == DialogButton.Left)
            {
                if (player.PlayerTeam.Id == (TeamID)e.ListItem)
                {
                    player.SendClientMessage(Color.Red, "Error: Ya formas parte de ese equipo.");
                    ct.ShowDialog(player);
                    return;
                }
                if (TeamAlpha.Members == TeamBeta.Members)
                {
                    player.SendClientMessage(Color.Red, $"Error: No puedes cambiarte al equipo {(e.ListItem == 0 ? "Alpha" : "Beta")} porque el equipo {player.PlayerTeam.NameTeam} quedaría desequilibrado.");
                    ct.ShowDialog(player);
                    return;
                }
                if (player.PlayerTeam.TeamRival.IsFull())
                {
                    player.SendClientMessage(Color.Red, "Error: El equipo no está disponible.");
                    ct.ShowDialog(player);
                    return;
                }
                if (player.IsCapturedFlag())
                {
                    player.Drop();
                }
                Player.Remove(player);
                player.PlayerTeam = (e.ListItem == 0) ? TeamAlpha : TeamBeta;
                Player.Add(player);
                BasePlayer.SendClientMessageToAll($"{player.PlayerTeam.OtherColor}[Team {player.PlayerTeam.NameTeam}]: {player.Name} se cambió al equipo {player.PlayerTeam.NameTeam}.");
                TextDrawGlobal.UpdateCountUsers();
                player.Spawn();
            }
        };
    }
Esempio n. 10
0
    private static void RanksDialog(Player player)
    {
        var ct = new TablistDialog("Ranks",
                                   new[] {
            "Level",
            "Rank",
            "Total Kills Required"
        }, "Cerrar", "");

        for (int i = Rank.MAX_RANK; i != 0; --i)
        {
            ct.Add(i.ToString(), Rank.GetRankLevel(i), Rank.GetRequiredKills(i).ToString());
        }
        ct.Show(player);
    }
Esempio n. 11
0
    private static void ListAFKs(Player player)
    {
        if (Player.UserAFKs.Count == 0)
        {
            player.SendClientMessage(Color.Red, "Error: No hay ningún jugador en AFK.");
            return;
        }
        var dialog = new TablistDialog($"AFK users: {Player.UserAFKs.Count}", new[] { "Id", "Name", "Entry Hour", "Time in AFK" }, "Cerrar", "");

        foreach (UserAFK player1 in Player.UserAFKs)
        {
            dialog.Add(player1.ToString());
        }
        dialog.Show(player);
    }
Esempio n. 12
0
    private static void ListVips(Player player)
    {
        if (Player.Vips.Count == 0)
        {
            player.SendClientMessage(Color.Red, "Error: No hay usuarios VIPs conectados.");
            return;
        }
        var vips = new TablistDialog($"Vips: {Player.Vips.Count}", new[] { "Name", "Level", "Rank" }, "Aceptar", "");

        Player.Vips.Sort((a, b) => b.Data.LevelVip - a.Data.LevelVip);
        foreach (Player player1 in Player.Vips)
        {
            vips.Add(new[] { player1.Name, player1.Data.LevelVip.ToString(), Rank.GetRankVip(player1.Data.LevelVip) });
        }
        vips.Show(player);
    }
Esempio n. 13
0
    private static void ListAdmins(Player player)
    {
        if (Player.Admins.Count == 0)
        {
            player.SendClientMessage(Color.Red, "Error: No hay administradores conectados.");
            return;
        }
        var admins = new TablistDialog($"Admins: {Player.Admins.Count}", new[] { "Name", "Level", "Rank" }, "Aceptar", "");

        Player.Admins.Sort((a, b) => b.Data.LevelAdmin - a.Data.LevelAdmin);
        foreach (Player player1 in Player.Admins)
        {
            admins.Add(new[] { player1.Name, player1.Data.LevelAdmin.ToString(), Rank.GetRankAdmin(player1.Data.LevelAdmin) });
        }
        admins.Show(player);
    }
 public static void SetInfo(this TablistDialog vs)
 {
     vs.Clear();
     TeamAlpha.GetMessageTeamEnable(out var msgAlpha, false);
     TeamBeta.GetMessageTeamEnable(out var msgBeta, false);
     vs.Add(new[]
     {
         $"{TeamAlpha.OtherColor}{TeamAlpha.NameTeam}",
         $"{TeamAlpha.OtherColor}{TeamAlpha.Members}",
         $"{TeamAlpha.OtherColor}{msgAlpha}"
     });
     vs.Add(new[]
     {
         $"{TeamBeta.OtherColor}{TeamBeta.NameTeam}",
         $"{TeamBeta.OtherColor}{TeamBeta.Members}",
         $"{TeamBeta.OtherColor}{msgBeta}"
     });
 }
Esempio n. 15
0
 public static void ShowStatsDb(Player player, string playername)
 {
     try
     {
         using var con    = CreateConnection();
         cmd.CommandText  = $"call getPlayerInfo('{playername}');";
         using var reader = cmd.ExecuteReader();
         if (reader.Read())
         {
             var stats  = new TablistDialog("Stats", 2, "Aceptar", "");
             var id     = reader.GetInt32("accountNumber");
             var skinid = reader.GetInt32("skinid");
             stats.Add(new[] { "Name", reader.GetString("name") });
             stats.Add(new[] { "Account Number", id.ToString() });
             stats.Add(new[] { "Registry Date", ParseData.ToStringDateTime(reader.GetDateTime("registryDate")) });
             stats.Add(new[] { "Last Connection",
                               !Player.IsPlayerOnline(id) ? ParseData.ToStringDateTime(reader.GetDateTime("lastConnection")) : "Connected" });
             stats.Add(new[] { "Total Kills", reader.GetInt32("totalKills").ToString() });
             stats.Add(new[] { "Total Deaths", reader.GetInt32("totalDeaths").ToString() });
             stats.Add(new[] { "Killing Sprees", reader.GetInt32("killingSprees").ToString() });
             int level = reader.GetInt32("levelGame");
             stats.Add(new[] { "Game Level", level.ToString() });
             stats.Add(new[] { "Rank", Rank.GetRankLevel(level) });
             stats.Add(new[] { "Next Rank", Rank.GetNextRankLevel(level) });
             stats.Add(new[] { "Dropped Flags", reader.GetInt32("droppedFlags").ToString() });
             stats.Add(new[] { "Headshots", reader.GetInt32("headshots").ToString() });
             stats.Add(new[] { "Admin Level", reader.GetInt32("levelAdmin").ToString() });
             stats.Add(new[] { "VIP Level", reader.GetInt32("levelVip").ToString() });
             stats.Add(new[] { "Saved Skin", skinid == -1 ? "None" : skinid.ToString() });
             stats.Show(player);
         }
         else
         {
             player.SendClientMessage(Color.Red, "Error: Ese nombre no se encuentra en la base de datos del servidor.");
         }
     }
     catch (MySqlException e)
     {
         player.SendErrorMessage(e);
     }
 }
    public static void Combos(Player player)
    {
        var combos = new TablistDialog("Combos", new[] { "Combo", "Adrenalina" }, "Canjear", "Cerrar");

        combos.Add(new[] { "150% Health + 100% Armour", "100" });
        combos.Add(new[] { "Jumps", "100" });
        combos.Add(new[] { "Velocity", "100" });
        combos.Add(new[] { "Invisibility", "100" });
        combos.Add(new[] { "2 Grenades + 20% Armour", "25" });
        combos.Add(new[] { "2 Molotov cocktail + 20% Armour", "25" });
        combos.Add(new[] { "10 Tear gas", "10" });
        combos.Add(new[] { "3 Satchel charges + 30% Armour", "40" });
        combos.Show(player);
        combos.Response += (sender, e) =>
        {
            if (e.DialogButton == DialogButton.Left)
            {
                if ((e.ListItem >= 1 && e.ListItem <= 3) && (player.IsCapturedFlag()))
                {
                    player.SendClientMessage(Color.Red, "Error: Lleva la bandera de forma legal, no seas cobarde jeje!");
                    return;
                }
                switch (e.ListItem)
                {
                case 0:
                    player.HasAdrenaline(100);
                    player.Health     = 150;
                    player.Armour     = 100;
                    player.Adrenaline = 0;
                    break;

                case 1:
                    player.HasAdrenaline(100);
                    player.SendClientMessage(Color.Yellow, "* En 1 minuto el beneficio se terminará.");
                    player.JumpTime   = Time.GetTime() + (TIME * 60);
                    player.Adrenaline = 0;
                    player.GiveWeapon(Weapon.Parachute, 1);
                    break;

                case 2:
                    player.HasAdrenaline(100);
                    player.SendClientMessage("* En 1 minuto el beneficio se terminará.");
                    player.SendClientMessage(Color.Yellow, $"[Uso]: {Color.White}Presiona y suelta la tecla [SPACE] para correr.");
                    player.SpeedTime  = Time.GetTime() + (TIME * 60);
                    player.Adrenaline = 0;
                    break;

                case 3:
                    player.HasAdrenaline(100);
                    player.SendClientMessage(Color.Yellow, "* En 1 minuto perderás la invisibilidad.");
                    player.InvisibleTime = Time.GetTime() + (TIME * 60);
                    player.Adrenaline    = 0;
                    player.EnableInvisibility();
                    break;

                case 4:
                    player.HasAdrenaline(25);
                    player.SetWeapon(Weapon.Grenade, 2);
                    player.Armour     = 20;
                    player.Adrenaline = -25;
                    break;

                case 5:
                    player.HasAdrenaline(25);
                    player.SetWeapon(Weapon.Moltov, 2);
                    player.Armour     = 20;
                    player.Adrenaline = -25;
                    break;

                case 6:
                    player.HasAdrenaline(10);
                    player.SetWeapon(Weapon.Teargas, 10);
                    player.Adrenaline = -10;
                    break;

                default:
                    player.HasAdrenaline(40);
                    player.SetWeapon(Weapon.SatchelCharge, 3);
                    player.GiveWeapon(Weapon.Detonator, 1);
                    player.Armour     = 30;
                    player.Adrenaline = -40;
                    break;
                }
                BasePlayer.SendClientMessageToAll(Color.Red, $"[Combo]: {Color.Yellow}{player.Name} canjeó su adrenalina por algún beneficio {Color.Red}(con /combos).");
            }
        };
    }
 public static void ShowDialog(this TablistDialog vs, Player player)
 {
     vs.SetInfo();
     vs.Show(player);
 }
Esempio n. 18
0
        public static void ShowContainer(Player player, Container container)
        {
            ServerDbContext dbContext         = ((GameMode)GameMode.Instance).DbContext;
            int             maxSpaceContainer = container.MaxSpace;

            listContainer = new TablistDialog(container.Name + " (" + container.ListItems.Count + "/" + maxSpaceContainer + ")", new[] { "Nom", "Quantité" }, "Sélectionner", "Quitter");

            List <Item> listItemsContainer = container.ListItems;
            int         i = 0;

            foreach (Item item in listItemsContainer)
            {
                listContainer.Add(item.Name, item.Quantity.ToString());
                i++;
            }
            if (i < maxSpaceContainer)
            {
                for (int a = 0; a < (maxSpaceContainer - i); a++)
                {
                    listContainer.Add(Color.DarkGray + " Vide" + Color.White, Color.DarkGray + "0");
                }
            }
            listContainer.Show(player);

            listContainer.Response += (playerReponse, EventArgs) =>
            {
                if (EventArgs.DialogButton == DialogButton.Right)
                {
                    return;
                }
                if (container.ListItems.Count <= EventArgs.ListItem ||
                    container.ListItems[EventArgs.ListItem] == null)   //  Put item in container
                {
                    if (player.ActiveCharacter.ItemInHand != null)
                    {
                        try
                        {
                            if (player.ActiveCharacter.ItemInHand is Gun)
                            {
                                player.SetArmedWeapon(((Gun)player.ActiveCharacter.ItemInHand).idWeapon);
                                player.ActiveCharacter.ItemInHand.Quantity = player.WeaponAmmo;
                            }
                            container.ListItems.Add(player.ActiveCharacter.ItemInHand); // Add item to container
                            ItemHelper.RemoveItemFromPlayerHand(player);
                            dbContext.SaveChanges();
                        }
                        catch (Exception e)
                        {
                            Chat.ErrorChat(player, "Impossible de prendre l'objet.");
                        }
                    }
                }
                else // Take item from container
                {
                    if (player.ActiveCharacter.ItemInHand == null)
                    {
                        try
                        {
                            //ItemHelper.PutItemInPlayerHand(player, container.ListItems[EventArgs.ListItem]);

                            InventoryHelper.AddItemToCharacter(player.ActiveCharacter, container.ListItems[EventArgs.ListItem]);
                            container.ListItems.RemoveAt(EventArgs.ListItem);

                            dbContext.SaveChanges();
                        }
                        catch (Exception e)
                        {
                            Chat.ErrorChat(player, "Impossible de prendre l'objet : " + e.Message);
                        }
                    }
                    else
                    {
                        try
                        {
                            Item itemContainer = container.ListItems[EventArgs.ListItem];
                            Item itemInHand    = player.ActiveCharacter.ItemInHand;

                            container.ListItems.RemoveAt(EventArgs.ListItem);
                            InventoryHelper.RemoveItemFromCharacter(player.ActiveCharacter, player.ActiveCharacter.ItemInHand);

                            container.ListItems.Add(itemInHand);
                            InventoryHelper.AddItemToCharacter(player.ActiveCharacter, itemContainer);
                        }
                        catch (Exception e)
                        {
                            Chat.ErrorChat(player, "Impossible de prendre l'objet : " + e.Message);
                        }
                    }
                }
            };
        }