Esempio n. 1
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. 2
0
        private static void DialogSpawns_Response(object sender, DialogResponseEventArgs e, PlayerClassType classId)
        {
            if (e.DialogButton != DialogButton.Left)
            {
                return;
            }

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

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

            switch (classId)
            {
            default:
                player.Position = new Vector3(spawns.ElementAt(e.ListItem).PositionX, spawns.ElementAt(e.ListItem).PositionY, spawns.ElementAt(e.ListItem).PositionZ);
                break;
            }
        }
Esempio n. 3
0
        private void Class_PlayerRequestSpawn(object sender, RequestSpawnEventArgs e)
        {
            if (!(sender is Player player))
            {
                return;
            }

            var random   = new Random();
            var angle    = 0.0f;
            var position = Vector3.Zero;

            var spawns = new ClassSpawnRepository(ConnectionFactory.GetConnection).GetAllByClassType((int)player.PlayerClass);
            var index  = random.Next(0, spawns.Count());

            switch (player.PlayerClass)
            {
            case PlayerClassType.TruckDriver:
                position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ);
                angle    = spawns.ElementAt(index).Angle;

                BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedTruckerClass, player.Name);
                break;

            case PlayerClassType.BusDriver:
                position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ);
                angle    = spawns.ElementAt(index).Angle;

                BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedBusDriverClass, player.Name);
                break;

            case PlayerClassType.Pilot:
                position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ);
                angle    = spawns.ElementAt(index).Angle;

                BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedPilotClass, player.Name);
                break;

            case PlayerClassType.Police:

                if (!player.CheckIfPlayerCanJoinPolice())
                {
                    e.PreventSpawning = true;
                    return;
                }

                if (player.Account.Score < 100)
                {
                    player.GameText("You need 100 score points for police class", 5000, 4);
                    player.SendClientMessage(Color.Red, "You need 100 score points for police class");
                    e.PreventSpawning = true;
                    return;
                }

                if (player.Account.Wanted > 0)
                {
                    player.GameText("You are not allowed to choose police class when you're wanted", 5000, 4);
                    player.SendClientMessage(Color.Red, "You are not allowed to choose police class when you're wanted");
                    e.PreventSpawning = true;
                    return;
                }

                position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ);
                angle    = spawns.ElementAt(index).Angle;

                BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedPoliceClass, player.Name);
                break;

            case PlayerClassType.Mafia:
                position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ);
                angle    = spawns.ElementAt(index).Angle;

                BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedMafiaClass, player.Name);
                break;

            case PlayerClassType.Assistance:
                position = new Vector3(spawns.ElementAt(index).PositionX, spawns.ElementAt(index).PositionY, spawns.ElementAt(index).PositionZ);
                angle    = spawns.ElementAt(index).Angle;

                BasePlayer.SendClientMessageToAll(Messages.PlayerJoinedAssistanceClass, player.Name);
                break;
            }

            player.SetSpawnInfo(0, player.Skin, position, angle);
        }