Esempio n. 1
0
            private static void GetInfo(Player player, int id)
            {
                Dictionary <string, string> result = RaceCreator.GetRaceInfo(id);

                if (result.Count == 0)
                {
                    player.SendClientMessage("No race found !");
                }
                else
                {
                    var    infoList = new ListDialog("Race info", "Ok", "");
                    string str      = "";
                    foreach (KeyValuePair <string, string> kvp in result)
                    {
                        str = new Color(50, 50, 255) + kvp.Key + ": " + new Color(255, 255, 255) + kvp.Value;
                        if (str.Length >= 64)
                        {
                            infoList.AddItem(str.Substring(0, 63));
                            infoList.AddItem(str.Substring(63));
                        }
                        else
                        {
                            infoList.AddItem(str);
                        }
                    }
                    infoList.Show(player);
                }
            }
Esempio n. 2
0
        public void ShowManagerDialog(Player player)
        {
            ListDialog managerDialog = new ListDialog("Event manager", "Select", "Cancel");

            managerDialog.AddItem(Color.Green + "Create event");
            foreach (Event evt in eventList)
            {
                managerDialog.AddItem(Color.White + "[" + evt.Status.ToString() + "]" + evt.Name);
            }

            managerDialog.Show(player);
            managerDialog.Response += (sender, eventArgs) =>
            {
                if (eventArgs.DialogButton == DialogButton.Left)
                {
                    if (eventArgs.ListItem == 0) // Create event
                    {
                        ShowCreateEventTypeDialog(player);
                    }
                    else
                    {
                        ShowEventOptionDialog(player, eventList.ElementAt(eventArgs.ListItem + 1));
                    }
                }
                else
                {
                    player.Notificate("Cancelled");
                }
            };
        }
Esempio n. 3
0
        public PlayerCharacterChoice(Player player)
        {
            this.player = player;

            ServerDbContext dbContext = ((GameMode)GameMode.Instance).DbContext;

            playerChars = dbContext.Characters.Select(c => c).Where(c => c.Account == player.AccountData).ToList();

            if (playerChars.Count == 0)
            {
                charCreationMenu = new PlayerCharacterCreation();
            }
            else
            {
                charList           = new ListDialog("Choix de personnage", "Confirmer", "Quitter");
                charList.Response += ChoiceResponse;

                foreach (Character chr in playerChars)
                {
                    charList.AddItem(chr.Name + " (Niveau " + chr.Level + " - " + Utils.SexUtils.SexToString(chr.Sex) + " de " + chr.Age + " ans)");
                }

                if (playerChars.Count < SemiRP.Constants.MAX_CHARACTERS)
                {
                    charList.AddItem(Color.DarkGray + "Créer un autre personnage...");
                }
            }
        }
Esempio n. 4
0
        private void ShowCheckpointDialog()
        {
            Checkpoint cp       = editingRace.checkpoints[checkpointIndex];
            ListDialog cpDialog = new ListDialog("Checkpoint options", "Select", "Cancel");

            cpDialog.AddItem("Edit checkpoint position");
            cpDialog.AddItem("Edit checkpoint size [" + cp.Size.ToString() + "]");

            if (cp.Type == CheckpointType.Normal || cp.Type == CheckpointType.Finish)
            {
                cpDialog.AddItem("Change checkpoint type: " + Color.Green + "Normal" + Color.White + "/Air");
            }
            else if (cp.Type == CheckpointType.Air || cp.Type == CheckpointType.AirFinish)
            {
                cpDialog.AddItem("Change checkpoint type: Normal/" + Color.Green + "Air");
            }

            if (checkpointIndex > 0)
            {
                cpDialog.AddItem("Edit events");
            }

            cpDialog.Show(player);
            cpDialog.Response += CpDialog_Response;
        }
Esempio n. 5
0
        private void ShowCheckpointEventDialog()
        {
            ListDialog cpEventDialog = new ListDialog("Checkpoint events", "Select", "Cancel");

            if (editingRace.checkpoints[checkpointIndex].NextVehicle == null)
            {
                cpEventDialog.AddItem("Vehicle event [None]");
            }
            else
            {
                cpEventDialog.AddItem("Vehicle event [" + editingRace.checkpoints[checkpointIndex].NextVehicle.ToString() + "]");
            }
            cpEventDialog.Show(player);
            cpEventDialog.Response += CpEventDialog_Response;
        }
Esempio n. 6
0
        public void ShowCreateEventTypeDialog(Player player)
        {
            ListDialog createEventDialog = new ListDialog("Create an event", "Create", "Cancel");

            foreach (EventType t in (EventType[])Enum.GetValues(typeof(EventType)))
            {
                createEventDialog.AddItem(t.ToString());
            }

            createEventDialog.Show(player);
            createEventDialog.Response += (sender, eventArgs) =>
            {
                if (eventArgs.DialogButton == DialogButton.Left)
                {
                    EventType evtType;
                    if (Enum.TryParse(eventArgs.InputText, out evtType))
                    {
                        ShowCreateEventNameDialog(player, evtType);
                    }
                    else
                    {
                        ShowCreateEventTypeDialog(player);
                        player.Notificate("Unable to parse event type");
                    }
                }
                else
                {
                    player.Notificate("Cancelled");
                    ShowManagerDialog(player);
                }
            };
        }
Esempio n. 7
0
        public static void OnMutedCommand(BasePlayer sender)
        {
            var mutedPlayersDialog = new ListDialog("Muted players:", "Ok");

            foreach (var basePlayer in Player.All)
            {
                var player = (Player)basePlayer;

                if (!player.IsLoggedIn)
                {
                    continue;
                }

                if (player.Account.Muted > DateTime.Now)
                {
                    mutedPlayersDialog.AddItem($"{player.Name} (ID:{player.Id})");
                }
            }

            if (mutedPlayersDialog.Items.Count != 0)
            {
                mutedPlayersDialog.Show(sender);
            }
            else
            {
                sender.SendClientMessage(Color.GreenYellow, Messages.ThereAreNoMutedPlayers);
            }
        }
 private static void BanIps(Player player)
 {
     if (player.IsAdminLevel(3))
     {
         return;
     }
     try
     {
         var lists = File.ReadAllLines("./samp.ban");
         if (lists.Length == 0)
         {
             player.SendClientMessage(Color.Red, "Error: No se encontró ninguna IP prohíbida.");
             return;
         }
         var dialog = new ListDialog($"Ban IPs: ({lists.Length})", "Cerrar", "");
         foreach (string info in lists)
         {
             dialog.AddItem(info);
         }
         dialog.Show(player);
         SendMessageToAdmins(player, "banips");
     }
     catch (FileNotFoundException)
     {
         player.SendClientMessage(Color.Red, "Error: No se encontró ninguna IP prohíbida.");
     }
 }
        public static void OnWeatherCommand(BasePlayer sender)
        {
            var weatherListDialog = new ListDialog("Select weather type:", Messages.DialogButtonSelect,
                                                   Messages.DialogButtonCancel);

            weatherListDialog.AddItem(
                "Normal\nStormy\nFoggy\nScorching Hot\nDull, cloudy, rainy\nSandstorm\nGreen Fog\nDark, cloudy, brown\nExtremely bright\nDark toxic clouds\nBlack & white sky");
            weatherListDialog.Show(sender);
            weatherListDialog.Response += (objectSender, e) =>
            {
                switch (e.ListItem)
                {
                case 0:
                    Server.SetWeather(0);
                    break;

                case 1:
                    Server.SetWeather(8);
                    break;

                case 2:
                    Server.SetWeather(9);
                    break;

                case 3:
                    Server.SetWeather(11);
                    break;

                case 4:
                    Server.SetWeather(16);
                    break;

                case 5:
                    Server.SetWeather(19);
                    break;

                case 6:
                    Server.SetWeather(20);
                    break;

                case 7:
                    Server.SetWeather(33);
                    break;

                case 8:
                    Server.SetWeather(39);
                    break;

                case 9:
                    Server.SetWeather(43);
                    break;

                case 10:
                    Server.SetWeather(44);
                    break;
                }
            };
        }
Esempio n. 10
0
        public static void ShowAdminDialog(Player player, Player receiver = null)
        {
            listAdmin = new ListDialog("Administration", "Sélectionner", "Quitter");
            listAdmin.AddItem("Modération");
            listAdmin.AddItem("Donner");
            listAdmin.AddItem("Véhicule");
            listAdmin.AddItem("Permissions");
            listAdmin.Show(player);
            listAdmin.Response += (sender, EventArgs) =>
            {
                if (EventArgs.DialogButton == SampSharp.GameMode.Definitions.DialogButton.Right)
                {
                    return;
                }

                switch (EventArgs.ListItem)
                {
                case 0:
                {
                    ShowModerationDialog(player, receiver);
                    break;
                }

                case 1:
                {
                    ShowGiveDialog(player);
                    break;
                }

                case 2:
                {
                    ShowVehicleDialog(player);
                    break;
                }

                case 3:
                {
                    ShowPermsDialog(player);
                    break;
                }

                default: return;
                }
            };
        }
        public static void OnCarOptionCommand(BasePlayer sender)
        {
            if (!sender.IsDriving())
            {
                sender.SendClientMessage(Color.Red, Messages.CommandAllowedOnlyAsDriver);
                return;
            }

            var carOptionsDialog = new ListDialog("Select option for your vehicle:", Messages.DialogButtonToggle,
                                                  Messages.DialogButtonCancel);

            carOptionsDialog.AddItem("Engine\nLights\nAlarm\nDoors\nBonnet\nBoot\nObjective");
            carOptionsDialog.Show(sender);

            carOptionsDialog.Response += (objectSender, e) =>
            {
                if (e.DialogButton != DialogButton.Left)
                {
                    return;
                }

                var playerVehicle = sender.Vehicle;

                switch (e.ListItem)
                {
                case 0:
                    playerVehicle.Engine = !playerVehicle.Engine;
                    break;

                case 1:
                    playerVehicle.Lights = !playerVehicle.Lights;
                    break;

                case 2:
                    playerVehicle.Alarm = !playerVehicle.Alarm;
                    break;

                case 3:
                    playerVehicle.Doors = !playerVehicle.Doors;
                    break;

                case 4:
                    playerVehicle.Bonnet = !playerVehicle.Bonnet;
                    break;

                case 5:
                    playerVehicle.Boot = !playerVehicle.Boot;
                    break;

                case 6:
                    playerVehicle.Objective = !playerVehicle.Objective;
                    break;
                }
            };
        }
Esempio n. 12
0
        public void Show(Player player)
        {
            ListDialog dialog = new ListDialog(Title, "Sélectionner", CanQuit ? "Quitter" : null);

            foreach (Field f in fields)
            {
                if (datas.ContainsKey(f.Dataname))
                {
                    dialog.AddItem(Color.Green + f.Title);
                }
                else
                {
                    dialog.AddItem(Color.Red + f.Title);
                }
            }

            dialog.AddItem(ContinueButton);
            dialog.Response += DialogResponse;
            dialog.Show(player);
        }
Esempio n. 13
0
        private void ShowRaceDialog()
        {
            ListDialog raceDialog = new ListDialog("Race options", "Select", "Cancel");

            raceDialog.AddItem("Select starting vehicle [" + editingRace.StartingVehicle + "]");
            raceDialog.AddItem("Edit race name");

            if (editingRace.startingSpawn[0].Position == Vector3.Zero)
            {
                raceDialog.AddItem("Set spawn positions");
            }
            else
            {
                raceDialog.AddItem("Edit spawn position");
            }

            raceDialog.AddItem("Lap: " + editingRace.Laps);

            raceDialog.Show(player);
            raceDialog.Response += RaceDialog_Response;
        }
Esempio n. 14
0
        public static void OnConvoyCommand(Player sender)
        {
            if (sender.PlayerClass != PlayerClassType.TruckDriver)
            {
                sender.SendClientMessage(Color.Red, Messages.CommandOnlyAllowedAsTruckDriver);
                return;
            }

            var convoyStatus     = string.Empty;
            var convoyListDialog =
                new ListDialog("Select convoy:", Messages.DialogButtonSelect, Messages.DialogButtonCancel);

            foreach (var convoy in MissionConvoy.Convoys)
            {
                string leaderName;
                int    memberCount;
                if (convoy.Status == ConvoyStatus.Empty)
                {
                    memberCount  = 0;
                    leaderName   = "None";
                    convoyStatus = "Empty";
                }
                else
                {
                    memberCount = convoy.Members.Count;
                    leaderName  = convoy.Members[0].Name;

                    switch (convoy.Status)
                    {
                    case ConvoyStatus.Open:
                        convoyStatus = "Open";
                        break;

                    case ConvoyStatus.Closed:
                        convoyStatus = "Closed";
                        break;

                    case ConvoyStatus.Full:
                        convoyStatus = "Full";
                        break;
                    }
                }

                convoyListDialog.AddItem(
                    $"Leader: {{00FF00}}{leaderName}{{FFFFFF}}, members: {{FF0000}}{memberCount}{{FFFFFF}}, Status: {{00FF00}}{convoyStatus}{{FFFFFF}}");
            }

            convoyListDialog.Show(sender);
            convoyListDialog.Response += ConvoyController.ConvoyListDialog_Response;
        }
Esempio n. 15
0
        public void ShowEventOptionDialog(Player player, Event evt)
        {
            ListDialog managerOptionDialog = new ListDialog(evt.Name, "Select", "Cancel");

            if (evt.Status == EventStatus.Loaded)
            {
                managerOptionDialog.AddItem("Open event to players");
            }
            if (evt.Status == EventStatus.Waiting)
            {
                managerOptionDialog.AddItem("Start event");
            }
            managerOptionDialog.AddItem(Color.Red + "Abort event");

            managerOptionDialog.Show(player);
            managerOptionDialog.Response += (sender, eventArgs) =>
            {
                if (eventArgs.DialogButton == DialogButton.Left)
                {
                    if (eventArgs.ListItem == 0) // Open / Start
                    {
                        if (evt.Status == EventStatus.Loaded)
                        {
                            evt.Open();
                        }
                        if (evt.Status == EventStatus.Waiting)
                        {
                            evt.Start();
                        }
                    }
                    else if (eventArgs.ListItem == 1) // Abort
                    {
                        evt.End();
                    }
                }
            };
        }
Esempio n. 16
0
        public static void OnAdminsCommand(BasePlayer sender)
        {
            var dialogAdmins = new ListDialog("Online admins:", "Close");

            foreach (var basePlayer in Player.All)
            {
                var player = (Player)basePlayer;

                if (!player.IsLoggedIn)
                {
                    continue;
                }

                if (player.IsAdmin)
                {
                    dialogAdmins.AddItem(
                        $"{AdminRanks.AdminLevelNames[player.Account.AdminLevel]}: {player.Name} (id: {player.Id}), admin-level: {player.Account.AdminLevel} (RCON admin)");
                    continue;
                }

                if (player.Account.AdminLevel > 0)
                {
                    dialogAdmins.AddItem(
                        $"{AdminRanks.AdminLevelNames[player.Account.AdminLevel]}: {player.Name} (id: {player.Id}), admin-level: {player.Account.AdminLevel}");
                }
            }

            if (dialogAdmins.Items.Count > 0)
            {
                dialogAdmins.Show(sender);
            }
            else
            {
                sender.SendClientMessage(Color.Red, Messages.NoAdminOnline);
            }
        }
Esempio n. 17
0
        public static void OnConvoyMembersCommand(Player sender)
        {
            if (!sender.IsInConvoy)
            {
                sender.SendClientMessage(Color.Red, Messages.PlayerNotPartOfAnyConvoy);
                return;
            }

            var convoy            = sender.Convoy;
            var membersListDialog = new ListDialog("Convoy members:", Messages.DialogButtonOk);

            foreach (var member in convoy.Members)
            {
                membersListDialog.AddItem($"{member.Name}\n");
            }

            membersListDialog.Show(sender);
        }
Esempio n. 18
0
        public static void OnGoBaseCommand(Player sender)
        {
            if (sender.State != PlayerState.OnFoot)
            {
                sender.SendClientMessage(Color.Red, Messages.MustBeOnFoot);
                return;
            }

            if (sender.Account.Wanted != 0)
            {
                sender.SendClientMessage(Color.Red, Messages.MustBeInnocent);
                return;
            }

            if (sender.IsDoingMission)
            {
                sender.SendClientMessage(Color.Red, Messages.CommandOnlyIfNotDoingAJob);
                return;
            }

            if (sender.Account.Jailed != 0)
            {
                sender.SendClientMessage(Color.Red, Messages.CommandOnlyIfNotJailed);
                return;
            }

            var dialogSpawns = new ListDialog("Select your spawn", "Select", "Cancel");

            var spawns = new ClassSpawnRepository(ConnectionFactory.GetConnection).GetAllByClassType((int)sender.PlayerClass);

            switch (sender.PlayerClass)
            {
            default:
                foreach (var spawn in spawns)
                {
                    dialogSpawns.AddItem($"{spawn.Name}");
                }

                dialogSpawns.Response += (senderObject, e) => DialogSpawns_Response(senderObject, e, sender.PlayerClass);
                break;
            }

            dialogSpawns.Show(sender);
        }
Esempio n. 19
0
        public void ShowCreateEventSearchDialog(Player player, EventType eventType, string str)
        {
            Dictionary <string, string> row;
            Dictionary <string, object> param = new Dictionary <string, object>
            {
                { "@name", str }
            };

            GameMode.mySQLConnector.OpenReader("SELECT race_id, race_name FROM races WHERE race_name LIKE @name", param);
            row = GameMode.mySQLConnector.GetNextRow();
            if (row.Count == 0)
            {
                player.Notificate("No race found");
                GameMode.mySQLConnector.CloseReader();
                ShowCreateEventNameDialog(player, eventType);
            }
            else
            {
                List <int> foundRaces        = new List <int>();
                ListDialog eventSearchDialog = new ListDialog("Found races", "Launch", "Cancel");
                while (row.Count > 0)
                {
                    foundRaces.Add(Convert.ToInt32(row["race_id"]));
                    eventSearchDialog.AddItem(row["race_id"] + "_" + row["race_name"]);
                    row = GameMode.mySQLConnector.GetNextRow();
                }
                eventSearchDialog.Show(player);
                eventSearchDialog.Response += (sender, eventArgs) =>
                {
                    if (eventArgs.DialogButton == DialogButton.Left)
                    {
                        CreateEvent(player, eventType, foundRaces[eventArgs.ListItem]);
                    }
                    else
                    {
                        player.Notificate("Cancelled");
                        ShowCreateEventTypeDialog(player);
                    }
                };

                GameMode.mySQLConnector.CloseReader();
            }
        }
Esempio n. 20
0
        public static void OnReportsCommand(BasePlayer sender)
        {
            if (Report.Reports[0].IsEmpty)
            {
                sender.SendClientMessage(Color.Red, Messages.NoReports);
                return;
            }

            var reportsDialog = new ListDialog("Reports list:", "Ok");

            foreach (var report in Report.Reports)
            {
                if (!report.IsEmpty)
                {
                    reportsDialog.AddItem($"{report.OffenderName}: {report.Reason}");
                }
            }

            reportsDialog.Show(sender);
        }
Esempio n. 21
0
        public void Show(BasePlayer player)
        {
            menuDialog.Items.Clear();

            if (continueItem != null)
            {
                if (menuItems.Contains(continueItem))
                {
                    menuItems.Remove(continueItem);
                }

                this.AddItem(continueItem);
            }

            foreach (var menuItem in menuItems)
            {
                menuDialog.AddItem(menuItem.Name);
            }

            menuDialog.Show(player);
        }
        public static void DialogBusDriverMission_Response(object sender, DialogResponseEventArgs e)
        {
            if (e.DialogButton != SampSharp.GameMode.Definitions.DialogButton.Left)
            {
                return;
            }

            if (!(e.Player is Player player))
            {
                return;
            }

            if (player.IsDoingMission)
            {
                player.SendClientMessage(Color.Red, Messages.AlreadyDoingAMission);
                return;
            }

            var selectRouteDialog = new ListDialog("Select busroute: ", Messages.DialogButtonSelect, Messages.DialogButtonCancel);

            switch (e.ListItem)
            {
            case 0:
                foreach (var busRoute in BusRoute.BusRoutes)
                {
                    selectRouteDialog.AddItem($"Line {busRoute.LineNumber} ({busRoute.Description})\n");
                }

                selectRouteDialog.Show(player);
                selectRouteDialog.Response += SelectRouteDialog_Response;
                break;

            case 1:
                var random = new Random();

                StartMission(player, BusRoute.BusRoutes[random.Next(BusRoute.BusRoutes.Count)]);
                break;
            }
        }
    public static void Weapons(Player player)
    {
        var weapons = new ListDialog("Weapons", "Seleccionar", "Cerrar");

        foreach (Gun gun in Gun.GetInstanceArray())
        {
            weapons.AddItem(gun.Weapon.ToString());
        }
        weapons.Show(player);
        weapons.Response += (sender, e) =>
        {
            if (e.DialogButton == DialogButton.Left)
            {
                int gunIndex;
                /* Gets the weapon that the player selected in the dialog. */
                var itemWeapon = Gun.GetWeapon(e.ListItem);
                /* Check if the weapon the player selected is not in their current weapon pack. */
                if (player.ListGuns.Find(gun => gun == itemWeapon) != null)
                {
                    player.SendClientMessage(Color.Red, $"Error: {itemWeapon.Weapon} ya se encuentra en el paquete de armas.");
                    weapons.Show(player);
                    return;
                }
                /* Check if there is no weapon with the same category in the player's weapon pack. */
                if ((gunIndex = player.ListGuns.FindIndex(gun => gun.Slot == itemWeapon.Slot)) != -1)
                {
                    player.ListGuns[gunIndex] = itemWeapon;
                }
                else
                {
                    player.ListGuns.Add(itemWeapon);
                }
                player.GiveWeapon(itemWeapon.Weapon);
                player.SendClientMessage(Color.Red, $"[Weapon]: {Color.Yellow}{itemWeapon.Weapon} se agregó en tu paquete de armas.");
                weapons.Show(player);
            }
        };
    }
Esempio n. 24
0
        public static void MissionDialogResponse(object sender, DialogResponseEventArgs e)
        {
            if (e.DialogButton != DialogButton.Left)
            {
                return;
            }

            var playerVehicleModel        = e.Player.Vehicle?.Model;
            var playerVehicleTrailerModel = e.Player.Vehicle?.Trailer?.Model;

            switch (e.ListItem)
            {
            case 0:
                var cargoList = GetMissionCargoes(playerVehicleModel, playerVehicleTrailerModel);

                if (cargoList == null)
                {
                    return;
                }

                var dialogCargoSelect = new ListDialog(Messages.MissionTruckerDialogSelectLoad,
                                                       Messages.DialogButtonSelect, Messages.DialogButtonCancel);

                foreach (var cargo in cargoList)
                {
                    dialogCargoSelect.AddItem(cargo.Name);
                }

                dialogCargoSelect.Show(e.Player);
                dialogCargoSelect.Response += DialogCargoSelect_Response;

                break;

            case 1:
                StartRandomMission((Player)e.Player);
                break;
            }
        }
Esempio n. 25
0
        private static void DialogCargoSelect_Response(object sender, DialogResponseEventArgs e)
        {
            if (e.DialogButton != DialogButton.Left)
            {
                return;
            }

            var playerVehicleModel        = e.Player.Vehicle?.Model;
            var playerVehicleTrailerModel = e.Player.Vehicle?.Trailer?.Model;

            if (!(e.Player is Player player))
            {
                return;
            }

            var cargoList = GetMissionCargoes(playerVehicleModel, playerVehicleTrailerModel);

            var dialogSelectStartLocation = new ListDialog(Messages.MissionTruckerSelectStartingLocation,
                                                           Messages.DialogButtonSelect, Messages.DialogButtonCancel);

            player.MissionCargo = cargoList[e.ListItem];

            foreach (var startLocationIndex in player.MissionCargo.FromLocations)
            {
                if (startLocationIndex != 0)
                {
                    dialogSelectStartLocation.AddItem(MissionLocation.MissionLocations[startLocationIndex].Name);
                }
                else
                {
                    break;
                }
            }

            dialogSelectStartLocation.Show(e.Player);
            dialogSelectStartLocation.Response += DialogSelectStartLocation_Response;
        }
Esempio n. 26
0
        private static void DialogSelectStartLocation_Response(object sender, DialogResponseEventArgs e)
        {
            if (e.DialogButton != DialogButton.Left)
            {
                return;
            }

            if (!(e.Player is Player player))
            {
                return;
            }

            var cargo = player.MissionCargo;
            var startLocationIndex = player.MissionCargo.FromLocations[e.ListItem];

            player.FromLocation = MissionLocation.MissionLocations[startLocationIndex];

            var dialogSelectEndLocation = new ListDialog(Messages.MissionTruckerSelectEndingLocation,
                                                         Messages.DialogButtonSelect, Messages.DialogButtonCancel);

            for (var i = 0; i < cargo.ToLocations.Length; i++)
            {
                var endLocationIndex = player.MissionCargo.ToLocations[i];

                if (endLocationIndex != 0)
                {
                    dialogSelectEndLocation.AddItem(MissionLocation.MissionLocations[endLocationIndex].Name);
                }
                else
                {
                    break;
                }
            }

            dialogSelectEndLocation.Show(e.Player);
            dialogSelectEndLocation.Response += DialogSelectEndLocation_Response;
        }
Esempio n. 27
0
        public static void OnCmdsCommand(Player sender)
        {
            var commandList = new ListDialog("Commands:", "Select", "Cancel");

            commandList.AddItem("Player\nAdmin level 1\nAdmin level 2\nAdmin level 3");
            commandList.Show(sender);
            commandList.Response += (senderObject, e) =>
            {
                if (e.DialogButton != DialogButton.Left)
                {
                    return;
                }

                var commandMessageDialog = new MessageDialog("Commands:", "", "Back", "Cancel");
                switch (e.ListItem)
                {
                case 0:
                    var playerCommands = new StringBuilder();

                    playerCommands.AppendLine("/admins - Displays all online admins");
                    playerCommands.AppendLine("/assist - Call for assistance to repair/refuel your vehicle");
                    playerCommands.AppendLine("/bank - Register/login/manage your bank account");
                    playerCommands.AppendLine("/bonus - Shows the current bonus mission (only for trucker class)");
                    playerCommands.AppendLine("/changepassword - Allows the player to change his login password");
                    playerCommands.AppendLine("/convoy - Lets you start or join a convoy");
                    playerCommands.AppendLine("/convoycancel - Cancels the convoy you're in");
                    playerCommands.AppendLine("/convoykick <Player> - Kicks a member from the convoy");
                    playerCommands.AppendLine("/convoyleave - You leave the convoy");
                    playerCommands.AppendLine("/convoymembers - Displays all convoy members");
                    playerCommands.AppendLine("/detach - Detaches your trailer");
                    playerCommands.AppendLine("/eject <Player> - Ejects a player from your vehicle");
                    playerCommands.AppendLine("/engine - Toggle engine-status on or off");
                    playerCommands.AppendLine("/flip - Flips your vehicle back onto it's wheels");
                    playerCommands.AppendLine("/givecash <Player> <Amount> - Give money to a player");
                    playerCommands.AppendLine("/gobase - Teleports you to a location where your class starts");
                    playerCommands.AppendLine("/me <Action> - Just a silly command to repeat your text");
                    playerCommands.AppendLine("/overload - Lets a trucker to overload his vehicle");
                    playerCommands.AppendLine("/pm <Player> <Message> - Send a private message to a player");
                    playerCommands.AppendLine("/reclass - Choose another class");
                    playerCommands.AppendLine("/report <Player> <Message> - Report a player for breaking the rules");
                    playerCommands.AppendLine("/rules - Display the rules and get a small gift (only once)");
                    playerCommands.AppendLine("/radio <Message> - Say something to players that have same class as you");
                    playerCommands.AppendLine("/stats - Displays statistics about yourself");
                    playerCommands.AppendLine("/stopwork - Ends the current job");
                    playerCommands.AppendLine("/work - Starts a job");

                    commandMessageDialog.Message = playerCommands.ToString();
                    break;

                case 1:
                    var adminLevel1Commands = new StringBuilder();

                    adminLevel1Commands.AppendLine("/achat - Admin-chat (this allows admins to chat privately)");
                    adminLevel1Commands.AppendLine("/spawnvehicle <Vehicle> - Spawn the specified vehicle");
                    adminLevel1Commands.AppendLine("/endspec - Stop spectating a player");
                    adminLevel1Commands.AppendLine("/freeze <Player> <Duration> <Reason> - Freeze a player for a certain time in seconds");
                    adminLevel1Commands.AppendLine("/unfreeze <Player> - Unfreeze a player");
                    adminLevel1Commands.AppendLine("/fuel - Refuels your vehicle for free");
                    adminLevel1Commands.AppendLine("/get <Player> - Teleports a player to your location");
                    adminLevel1Commands.AppendLine("/jail <Player> <Duration> <Reason> - Jails a player for a certain time in seconds");
                    adminLevel1Commands.AppendLine("/unjail <Player> - Unjail a player");
                    adminLevel1Commands.AppendLine("/kick <Player> <Reason> - Kick a player");
                    adminLevel1Commands.AppendLine("/mute <Player> <Duration> <Reason> - Mute a player for x minutes");
                    adminLevel1Commands.AppendLine("/muted - Display muted players");
                    adminLevel1Commands.AppendLine("/nos - Adds nitro to your vehicle");
                    adminLevel1Commands.AppendLine("/port <Player> - Teleport yourself to a player");
                    adminLevel1Commands.AppendLine("/portloc <x> <y> <z> - Teleport yourself to the given coordinates");
                    adminLevel1Commands.AppendLine("/portvehicle <Vehicle ID> - Teleport yourself to a vehicle");
                    adminLevel1Commands.AppendLine("/reports - Show the last 50 reports in a dialog");
                    adminLevel1Commands.AppendLine("/repair - Repairs your vehicle for free");
                    adminLevel1Commands.AppendLine("/respawnvehicle <Vehicle ID> - Forces a vehicle to respawn");
                    adminLevel1Commands.AppendLine("/spec <Player> - Spectate a player");
                    adminLevel1Commands.AppendLine("/tele <Player 1> <Player 2> - Teleport a player to an other player");
                    adminLevel1Commands.AppendLine("/unmute <Player> - Un-mutes a player");
                    adminLevel1Commands.AppendLine("/warn <Player> <Reason> - Warn a player");
                    adminLevel1Commands.AppendLine("/announce <Style (0-6)> <Duration> <Message> - Shows a message on player's screen");

                    commandMessageDialog.Message = adminLevel1Commands.ToString();
                    break;

                case 2:
                    var adminLevel2Commands = new StringBuilder();

                    adminLevel2Commands.AppendLine("/setwanted <Player> <Stars (0-6)> - Set a player's wanted level");
                    adminLevel2Commands.AppendLine("/ban <Player> <Days> <Reason> - Ban a player for a certain time");
                    adminLevel2Commands.AppendLine("/caroption - Changes some options for your vehicle");
                    adminLevel2Commands.AppendLine("/cleanupallvehicles - Removes all admin spawned vehicles from the map");
                    adminLevel2Commands.AppendLine("/cleanupvehicle <Vehicle ID> - Deletes a vehicle spawned by an admin");
                    adminLevel2Commands.AppendLine("/fly - Equips yourself with a jetpack");
                    adminLevel2Commands.AppendLine("/fuelall - Fuel all vehicles for free");
                    adminLevel2Commands.AppendLine("/givelicense <Player> - Gives a free trucker license to a player");
                    adminLevel2Commands.AppendLine("/healall - Heals all the players");
                    adminLevel2Commands.AppendLine("/ipban <Player> <Reason> - Ban a player's IP");
                    adminLevel2Commands.AppendLine("/loc - Display your current location");
                    adminLevel2Commands.AppendLine("/rangeban <Player> <Reason> - Ban a player's entire IP-range");
                    adminLevel2Commands.AppendLine("/repairall - Repair all vehicles for free");
                    adminLevel2Commands.AppendLine("/setscore <Player> <Amount> - Sets a player's score to the given value");
                    adminLevel2Commands.AppendLine("/unban <Player> - Unban a player");
                    adminLevel2Commands.AppendLine("/setskin <Player> <Skin ID (0-311)> - Changes a player's skin-id");
                    adminLevel2Commands.AppendLine("/weather - Changes the weather");

                    commandMessageDialog.Message = adminLevel2Commands.ToString();
                    break;

                case 3:
                    var adminLevel3Comamnds = new StringBuilder();

                    adminLevel3Comamnds.AppendLine("/createcamera <Max Speed> - Create s speedcamera at your location");
                    adminLevel3Comamnds.AppendLine("/deletecamera - Delete a speedcamera");
                    adminLevel3Comamnds.AppendLine("/resetplayer <Player> <Money (0/1)> <Score (0/1)> <Stats (0/1)> <Reason> - Reset a player's money, score, stats");
                    adminLevel3Comamnds.AppendLine("/setadmin <Player> <Admin Level (0-3)> - Changes a player's admin-level");

                    commandMessageDialog.Message = adminLevel3Comamnds.ToString();
                    break;
                }

                commandMessageDialog.Show(sender);
                commandMessageDialog.Response += (objectSender, ev) =>
                {
                    if (ev.DialogButton == DialogButton.Left)
                    {
                        commandList.Show(sender);
                    }
                };
            };
        }
Esempio n. 28
0
        private static void ShowModerationDialog(Player player, Player receiver)
        {
            listModeration = new ListDialog("Administration - Modération", "Sélectionner", "Quitter");
            listModeration.AddItem("Se téléporter à");
            listModeration.AddItem("Téléporter à sois");
            listModeration.AddItem("Slap");
            listModeration.AddItem("Freeze");
            listModeration.AddItem("Unfreeze");
            listModeration.AddItem("Activer/Désactiver PM");
            listModeration.Show(player);
            listModeration.Response += (sender, EventArgs) =>
            {
                switch (EventArgs.ListItem)
                {
                case 0:
                {
                    if (receiver != null)
                    {
                        responseDialog           = new InputDialog("Se téléporter à", "Indiquez l'ID du joueur auquel se téléporter :", false, "Sélectionner", "Quitter");
                        responseDialog.Response += (sender, EventArgs) =>
                        {
                            try
                            {
                                AdminHelper.Goto(player, receiver);
                            }
                            catch (Exception e)
                            {
                                Utils.Chat.ErrorChat(player, "Une erreur est survenue, impossible de se téléporter au joueur." + e.Message);
                            }
                        };
                    }
                    else
                    {
                        responseDialog           = new InputDialog("Se téléporter à", "Indiquez l'ID du joueur auquel se téléporter :", false, "Sélectionner", "Quitter");
                        responseDialog.Response += (sender, EventArgs) =>
                        {
                            try
                            {
                                receiver = PlayerHelper.AskId(player);
                                AdminHelper.Goto(player, receiver);
                            }
                            catch (Exception e)
                            {
                                Utils.Chat.ErrorChat(player, "Une erreur est survenue, impossible de se téléporter au joueur." + e.Message);
                            }
                        };
                    }
                    break;
                }

                case 1:
                {
                    responseDialog           = new InputDialog("Téléporter à sois", "Indiquez l'ID du joueur que vous voulez téléporter :", false, "Sélectionner", "Quitter");
                    responseDialog.Response += (sender, EventArgs) =>
                    {
                        try
                        {
                        }
                        catch (Exception e)
                        {
                            Utils.Chat.ErrorChat(player, "Une erreur est survenue, impossible de téléporter le joueur." + e.Message);
                        }
                    };
                    break;
                }

                case 2:
                {
                    responseDialog           = new InputDialog("Slap", "Indiquez l'ID du joueur que vous voulez slap :", false, "Sélectionner", "Quitter");
                    responseDialog.Response += (sender, EventArgs) =>
                    {
                        try
                        {
                        }
                        catch (Exception e)
                        {
                            Utils.Chat.ErrorChat(player, "Une erreur est survenue, impossible de slap le joueur." + e.Message);
                        }
                    };
                    break;
                }

                case 3:
                {
                    responseDialog           = new InputDialog("Freeze", "Indiquez l'ID du joueur que vous voulez freeze :", false, "Sélectionner", "Quitter");
                    responseDialog.Response += (sender, EventArgs) =>
                    {
                        try
                        {
                        }
                        catch (Exception e)
                        {
                            Utils.Chat.ErrorChat(player, "Une erreur est survenue, impossible de freeze le joueur." + e.Message);
                        }
                    };
                    break;
                }

                case 4:
                {
                    responseDialog           = new InputDialog("Unfreeze", "Indiquez l'ID du joueur que vous voulez unfreeze :", false, "Sélectionner", "Quitter");
                    responseDialog.Response += (sender, EventArgs) =>
                    {
                        try
                        {
                        }
                        catch (Exception e)
                        {
                            Utils.Chat.ErrorChat(player, "Une erreur est survenue, impossible d'unfreeze le joueur." + e.Message);
                        }
                    };
                    break;
                }

                case 5:
                {
                    try
                    {
                    }
                    catch (Exception e)
                    {
                        Utils.Chat.ErrorChat(player, "Une erreur est survenue, impossible d'unfreeze le joueur." + e.Message);
                    }
                    break;
                }
                }
            };
        }
Esempio n. 29
0
        private void ShowTextdrawDialog()
        {
            ListDialog textdrawDialog = new ListDialog("Textdraw options", "Select", "Cancel");

            textdrawDialog.AddItem("Color [" + layers[layerIndex].GetTextdrawColor(editingTDName) + layers[layerIndex].GetTextdrawColor(editingTDName).ToString() + Color.White + "]");
            textdrawDialog.AddItem("Back color [" + layers[layerIndex].GetTextdrawBackColor(editingTDName) + layers[layerIndex].GetTextdrawBackColor(editingTDName).ToString() + Color.White + "]");

            textdrawDialog.Show(player);
            textdrawDialog.Response += (sender, eventArgs) =>
            {
                if (eventArgs.DialogButton == DialogButton.Left)
                {
                    switch (eventArgs.ListItem)
                    {
                    case 0:     // Color
                    {
                        InputDialog colorDialog = new InputDialog("Enter color", "Supported formats: 0xFF0000 ; red ; rbg(255, 0, 0)", false, "Set", "Cancel");
                        colorDialog.Response += (sender, eventArgs) =>
                        {
                            if (eventArgs.DialogButton == DialogButton.Left)
                            {
                                string input = eventArgs.InputText;
                                if (input.Length > 0)
                                {
                                    if (input.StartsWith("0x"))
                                    {
                                        if (input.Length == 8)
                                        {
                                            string r, g, b;
                                            r = input.Substring(2, 2);
                                            g = input.Substring(4, 2);
                                            b = input.Substring(6, 2);
                                            Color newColor = new Color(
                                                int.Parse(r, System.Globalization.NumberStyles.HexNumber),
                                                int.Parse(g, System.Globalization.NumberStyles.HexNumber),
                                                int.Parse(b, System.Globalization.NumberStyles.HexNumber)
                                                );
                                            layers[layerIndex].SetTextdrawColor(editingTDName, newColor);
                                            player.SendClientMessage("Color set to " + layers[layerIndex].GetTextdrawColor(editingTDName));
                                        }
                                        else
                                        {
                                            player.SendClientMessage(Color.Red, "Format error");
                                        }
                                        ShowTextdrawDialog();
                                    }
                                    else if (input.StartsWith("rgb("))
                                    {
                                        Regex regex = new Regex(@"[r][g][b][(](\d{1,3})[,;]\s*(\d{1,3})[,;]\s*(\d{1,3})[)]", RegexOptions.IgnoreCase);
                                        Match match = regex.Match(input);
                                        if (match.Success)
                                        {
                                            int r, g, b;
                                            r = int.Parse(match.Groups[0].Value);
                                            g = int.Parse(match.Groups[1].Value);
                                            b = int.Parse(match.Groups[2].Value);
                                            Color newColor = new Color(r, g, b);
                                            layers[layerIndex].SetTextdrawColor(editingTDName, newColor);
                                            player.SendClientMessage("Color set to " + layers[layerIndex].GetTextdrawColor(editingTDName));
                                        }
                                        else
                                        {
                                            player.SendClientMessage(Color.Red, "Format error");
                                        }
                                        ShowTextdrawDialog();
                                    }
                                }
                            }
                        };
                        break;
                    }

                    case 1:     // Back color
                    {
                        break;
                    }
                    }
                }
            };
        }
Esempio n. 30
0
        public static void ShowBankAccountOptions(this Player player)
        {
            var    title = $"Your bank funds: {{00FF00}}${player.BankAccount.Money}";
            string message;

            var bankOptionsDialog = new ListDialog(title, "Select", "Cancel");

            bankOptionsDialog.AddItem("{00FF00}Deposit money");
            bankOptionsDialog.AddItem("{00FF00}Withdraw money");
            bankOptionsDialog.AddItem("{00FF00}Transfer money");
            bankOptionsDialog.AddItem("{00FF00}Cancel bank account");

            bankOptionsDialog.Show(player);
            bankOptionsDialog.Response += (sender, e) =>
            {
                if (e.DialogButton != DialogButton.Left)
                {
                    return;
                }

                switch (e.ListItem)
                {
                case 0:
                    message =
                        $"Your money: {{00FF00}}${player.Account.Money}\n{{FFFFFF}}Bank account funds: {{00FF00}}${player.BankAccount.Money}" +
                        "\n \n{{FFFFFF}}Please enter the amount of money you want to deposit into your bank account:";

                    var moneyDepositDialog =
                        new InputDialog("Enter amount of money", message, false, "Accept", "Cancel");
                    moneyDepositDialog.Show(player);
                    moneyDepositDialog.Response += MoneyDepositDialog_Response;
                    break;

                case 1:
                    if (player.BankAccount.Money <= 0)
                    {
                        player.SendClientMessage(Color.Red, "You can't withdraw from an empty bank account.");
                        player.ShowBankAccountOptions();
                        return;
                    }

                    message =
                        $"Your money: {{00FF00}}${player.Account.Money}\n{{FFFFFF}}Bank account funds: {{00FF00}}${player.BankAccount.Money}" +
                        "\n \n{{FFFFFF}}Please enter the amount of money you want to withdraw into your bank account:";

                    var moneyWithdrawDialog =
                        new InputDialog("Enter amount of money", message, false, "Accept", "Cancel");
                    moneyWithdrawDialog.Show(player);
                    moneyWithdrawDialog.Response += MoneyWithdrawDialog_Response;
                    break;

                case 2:
                    if (player.BankAccount.Money < 1)
                    {
                        player.SendClientMessage(Color.Red, "You can't transfer money from an empty bank account.");
                        player.ShowBankAccountOptions();
                        return;
                    }

                    message =
                        $"Your money: {{00FF00}}${player.Account.Money}\n{{FFFFFF}}Bank account funds: {{00FF00}}${player.BankAccount.Money}" +
                        "\n \n{{FFFFFF}}Please enter the amount of money you want to transfer to another player's bank account:";

                    var moneyTransferDialog =
                        new InputDialog("Enter amount of money", message, false, "Accept", "Cancel");
                    moneyTransferDialog.Show(player);
                    moneyTransferDialog.Response += MoneyTransferDialog_Response;
                    break;

                case 3:
                    var hasMoneyMessage = string.Empty;
                    if (player.BankAccount.Money > 0)
                    {
                        hasMoneyMessage =
                            $"{{FFFFFF}}Your bank account has {{00FF00}}${player.BankAccount.Money}{{FFFFFF}} in it\n{{FFFFFF}}Your bank funds will be returned to you when you cancel your bank account\n";
                    }

                    message = $"{hasMoneyMessage}{{FFFFFF}}Are you sure you want to cancel your bank account?";

                    var bankCancelDialog = new MessageDialog("Are you sure?", message, "Yes", "No");
                    bankCancelDialog.Show(player);
                    bankCancelDialog.Response += BankCancelDialog_Response;
                    break;
                }
            };
        }