/// <summary>
        /// Removes the vehicle.
        /// </summary>
        /// <param name="licencedPlayer">The licenced player.</param>
        /// <param name="vehicleSettings">The vehicle settings.</param>
        private void RemoveVehicle(LicencedPlayer licencedPlayer, VehicleSettings vehicleSettings)
        {
            var player  = licencedPlayer.Player;
            var vehicle = licencedPlayer.GetVehicle(vehicleSettings.prefab);

            if (player != null && vehicle == null)
            {
                SendReply(player, string.Format(Msg("vehicleNotYetPurchased", player.UserIDString), vehicleSettings.name));
            }
            else
            {
                var vehicleId = vehicle.Id;
                _vehiclesCache.Remove(vehicle.Id);
                BaseNetworkable.serverEntities.Find(vehicle.Id)?.Kill();
                vehicle.Id = 0;
                licencedPlayer.SetVehicle(vehicle);
                if (player != null && vehicleId != 0)
                {
                    SendReply(player, string.Format(Msg("vehicleRecalled", player.UserIDString), vehicleSettings.name));
                }
                else if (player != null && vehicleId == 0)
                {
                    SendReply(player, string.Format(Msg("vehicleNotOut", player.UserIDString), vehicleSettings.name));
                }
            }
        }
        void CmdLicenceHelp(BasePlayer player, string command, string[] args)
        {
            SendReply(player, Msg("helpLicence", player.UserIDString));
            LicencedPlayer licencedPlayer;

            if (!_licencedPlayer.TryGetValue(player.userID, out licencedPlayer))
            {
                licencedPlayer = new LicencedPlayer(player.userID);
                _licencedPlayer.Add(player.userID, licencedPlayer);
            }
        }
        void CmdBuyVehicle(BasePlayer player, string command, string[] args)
        {
            if (args.Length == 0)
            {
                SendReply(player, string.Format(Msg("helpBuy", player.UserIDString), _itemsNeededToBuyVehicles,
                                                GetVehicleSettings(rowBoatPrefab).price, GetVehicleSettings(rhibPrefab).price, GetVehicleSettings(sedanPrefab).price,
                                                GetVehicleSettings(hotAirBalloonPrefab).price, GetVehicleSettings(miniCopterPrefab).price, GetVehicleSettings(chinookPrefab).price));
            }
            if (args.Length >= 1)
            {
                LicencedPlayer licencedPlayer;
                if (!_licencedPlayer.TryGetValue(player.userID, out licencedPlayer))
                {
                    licencedPlayer = new LicencedPlayer(player.userID);
                    _licencedPlayer.Add(player.userID, licencedPlayer);
                }

                var arg = args[0].ToLower();
                if (!PlayerHasPermission(player, arg))
                {
                    SendReply(player, Msg("noPermission", player.UserIDString));
                    return;
                }
                if (IsCase(arg, rowBoatPrefab))
                {
                    BuyVehicle(player, licencedPlayer, rowBoatPrefab);
                }
                else if (IsCase(arg, rhibPrefab))
                {
                    BuyVehicle(player, licencedPlayer, rhibPrefab);
                }
                else if (IsCase(arg, sedanPrefab))
                {
                    BuyVehicle(player, licencedPlayer, sedanPrefab);
                }
                else if (IsCase(arg, hotAirBalloonPrefab))
                {
                    BuyVehicle(player, licencedPlayer, hotAirBalloonPrefab);
                }
                else if (IsCase(arg, miniCopterPrefab))
                {
                    BuyVehicle(player, licencedPlayer, miniCopterPrefab);
                }
                else if (IsCase(arg, chinookPrefab))
                {
                    BuyVehicle(player, licencedPlayer, chinookPrefab);
                }
                else
                {
                    SendReply(player, Msg("helpOptionNotFound", player.UserIDString));
                }
            }
        }
        /// <summary>
        /// Buys the vehicle.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="licencedPlayer">The licenced player.</param>
        /// <param name="prefab">The prefab.</param>
        private void BuyVehicle(BasePlayer player, LicencedPlayer licencedPlayer, string prefab)
        {
            Vehicle vehicle;
            var     vehicleSettings = GetVehicleSettings(prefab);

            if (licencedPlayer.Vehicles.TryGetValue(prefab, out vehicle))
            {
                SendReply(player, string.Format(Msg("vehicleAlreadyPurchased", player.UserIDString), vehicleSettings.name));
            }
            else if (vehicleSettings.name != "null" && vehicleSettings.purchasable)
            {
                if (Withdraw(player, vehicleSettings))
                {
                    vehicle = new Vehicle(prefab, player.userID);
                    licencedPlayer.SetVehicle(vehicle);
                }
            }
            else
            {
                SendReply(player, string.Format(Msg("vehicleCannotBeBuyed", player.UserIDString), vehicleSettings.name));
            }
        }
        /// <summary>
        /// Determines whether the specified licenced player is spawning.
        /// </summary>
        /// <param name="licencedPlayer">The licenced player.</param>
        /// <param name="prefab">The prefab.</param>
        /// <param name="water">if set to <c>true</c> [water].</param>
        /// <returns>
        ///   <c>true</c> if the specified licenced player is spawning; otherwise, <c>false</c>.
        /// </returns>
        private bool IsSpawning(LicencedPlayer licencedPlayer, string prefab, bool water = false)
        {
            var player = licencedPlayer.Player;

            if (player == null)
            {
                return(false);
            }
            var vehicleSettings = GetVehicleSettings(prefab);
            var vehicle         = licencedPlayer.GetVehicle(prefab);

            if (vehicle == null)
            {
                SendReply(player, string.Format(Msg("vehicleNotYetPurchased", player.UserIDString), vehicleSettings.name));
                return(false);
            }
            else if (vehicle.Id != 0)
            {
                SendReply(player, string.Format(Msg("alreadyVehicleOut", player.UserIDString), vehicleSettings.name));
                return(false);
            }
            else if (water && !IsInWater(player))
            {
                SendReply(player, Msg("notInWater", player.UserIDString));
                return(false);
            }
            else if (vehicleSettings.cooldownToSpawn > 0 && vehicle.Spawned > (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).Subtract(TimeSpan.FromSeconds(vehicleSettings.cooldownToSpawn)))
            {
                SendReply(player, string.Format(Msg("vehicleOnCooldown", player.UserIDString),
                                                Convert.ToInt32((vehicle.Spawned - (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).Subtract(TimeSpan.FromSeconds(vehicleSettings.cooldownToSpawn))).TotalSeconds),
                                                vehicleSettings.name));
                return(false);
            }
            else
            {
                return(true);
            }
        }
        /// <summary>
        /// Spawns the vehicle.
        /// </summary>
        /// <param name="licencedPlayer">The licenced player.</param>
        /// <param name="prefab">The prefab.</param>
        /// <returns></returns>
        private BaseEntity SpawnVehicle(LicencedPlayer licencedPlayer, string prefab)
        {
            var player = licencedPlayer.Player;

            if (player == null)
            {
                return(null);
            }
            var vehicleSettings = GetVehicleSettings(prefab);
            var vehicle         = licencedPlayer.GetVehicle(prefab);

            if (vehicle == null)
            {
                return(null);
            }
            var        position = player.transform.position + new Vector3(0f, 1.6f, 0f);
            var        rotation = player.transform.rotation;
            BaseEntity entity   = GameManager.server.CreateEntity(vehicle.Prefab, position + (Vector3.forward * vehicleSettings.distanceToSpawn), rotation);

            if (entity == null)
            {
                return(null);
            }
            entity.enableSaving = true;
            entity.Spawn();
            if (entity.net == null)
            {
                return(null);
            }
            vehicle.Spawned      = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
            vehicle.Id           = entity.net.ID;
            vehicle.LastDismount = DateTime.UtcNow;
            _vehiclesCache.Add(vehicle.Id, vehicle);
            licencedPlayer.SetVehicle(vehicle);
            SendReply(player, string.Format(Msg("vehicleSpawned", player.UserIDString), vehicleSettings.name));

            return(entity);
        }