using System;
using System.Collections.Generic;
using GTANetworkAPI;
using Newtonsoft.Json;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Database.Models;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Database.Entities;


namespace ReallifeGamemode.Server.Job
{
  public class BusDriverJob : JobBase
  {
    public override int Id => 4;

    public override string Name => "Busfahrer";

    public override bool NeedVehicleToStart => false;

    private readonly IReadOnlyCollection<Vector3> Skill1Route1 = new List<Vector3>//Bus_Skill_1_Route_1
    {
      new Vector3(-1018.1577758789062, -2732.403564453125, 10.658967971801758),
      new Vector3(-153.04013061523438, -2033.8385009765625, 19.712543487548828),
      new Vector3(50.42457580566406, -1536.9090576171875, 26.184476852416992),
      new Vector3(361.1451721191406, -1064.6044921875, 26.36113166809082),
      new Vector3(119.01465606689453, -785.609619140625, 28.267763137817383),
      new Vector3(-172.00689697265625, -815.9910888671875, 28.13607406616211),
      new Vector3(-707.7088623046875, -826.9969482421875, 20.451000213623047),
      new Vector3(-658.1038818359375, -1393.321533203125, 7.509778022766113),
      new Vector3(-1018.1826171875, -2732.371826171875, 10.656649589538574),
      new Vector3(-647.2696533203125, -2215.64501953125, 2.989798069000244),
    }.AsReadOnly();

    private readonly IReadOnlyCollection<Vector3> Skill1Route2 = new List<Vector3>//Bus_Skill_1_Route_2
    {
      new Vector3(-567.6445922851562, -1233.4453125, 12.050300598144531),
      new Vector3(-509.224609375, -668.373291015625, 30.02402877807617),
      new Vector3(55.00559997558594, -749.8328247070312, 41.11421203613281),
      new Vector3(-173.65509033203125, -152.5533905029297, 40.615516662597656),
      new Vector3(-523.8310546875, -266.884033203125, 32.291507720947266),
      new Vector3(-1167.646728515625, -400.75, 32.39745330810547),
      new Vector3(-1408.329345703125, -567.8721923828125, 27.22767448425293),
      new Vector3(-1213.3565673828125, -1214.755859375, 4.5853986740112305),
      new Vector3(-746.8554077148438, -2372.227783203125, 11.740862846374512),
      new Vector3(-660.7366333007812, -2206.03662109375, 2.988998889923096),
    }.AsReadOnly();

    private readonly IReadOnlyCollection<Vector3> Skill1Route3 = new List<Vector3>//Bus_Skill_1_Route_3
    {
      new Vector3(423.4793395996094, -2143.4169921875, 15.23659896850586),
      new Vector3(875.1618041992188, -1766.7913818359375, 26.780052185058594),
      new Vector3(1166.110107421875, -1422.72265625, 31.477935791015625),
      new Vector3(807.715087890625, -1356.7987060546875, 23.29298210144043),
      new Vector3(785.9387817382812, -780.5958251953125, 23.333005905151367),
      new Vector3(895.2793579101562, 55.24346923828125, 75.82550048828125),
      new Vector3(775.8052368164062, 596.2352905273438, 122.77734375),
      new Vector3(307.64422607421875, -762.0469360351562, 26.197702407836914),
      new Vector3(-105.66091918945312, -1683.9630126953125, 26.190542221069336),
      new Vector3(-644.0516967773438, -2218.673828125, 2.991928577423096),
    }.AsReadOnly();

    private readonly IReadOnlyCollection<Vector3> Skill1Route4 = new List<Vector3>//Bus_Skill_1_Route_4
    {

      new Vector3(-694.1781616210938, -1199.3873291015625, 7.50633716583252),
      new Vector3(-1408.264892578125, -567.5278930664062, 27.21875),
      new Vector3(-1681.6112060546875, -503.3702392578125, 34.79117965698242),
      new Vector3(-1427.05712890625, -90.17198181152344, 49.015113830566406),
      new Vector3(-686.4015502929688, -374.3297424316406, 31.17094802856445),
      new Vector3(-509.60107421875, -668.41796875, 30.02873229980469),
      new Vector3(234.6927032470703, -857.5449829101562, 26.747934341430664),
      new Vector3(787.8258666992188, -1364.9345703125, 23.424083709716797),
      new Vector3(825.1477661132812, -1634.5733642578125, 27.521774291992188),
      new Vector3(-105.38816833496094, -1683.646728515625, 26.19083023071289),
      new Vector3(-655.6530151367188, -2209.579345703125, 2.98785924911499),
    }.AsReadOnly();

    private readonly IReadOnlyCollection<Vector3> Skill2Route1 = new List<Vector3>//Bus_Skill_2_Route_1
    {

      new Vector3(-1042.6405029296875, -2718.244384765625, 9.493847846984863),
      new Vector3(832.205322265625, -11.559977531433105, 76.72754669189453),
      new Vector3(2563.96826171875, 2633.976806640625, 35.279945373535156),
      new Vector3(1684.845947265625, 6402.1533203125, 28.877294540405273),
      new Vector3(-170.82965087890625, 6374.9560546875, 28.695466995239258),
      new Vector3(-1524.5302734375, 4998.1220703125, 60.54846954345703),
      new Vector3(-3234.168701171875, 974.0481567382812, 10.890801429748535),
      new Vector3(-1331.8995361328125, -1052.2794189453125, 5.4408793449401855),
      new Vector3(-647.2696533203125, -2215.64501953125, 2.989798069000244),
    }.AsReadOnly();
    private readonly IReadOnlyCollection<Vector3> Skill2Route2 = new List<Vector3>//Bus_Skill_2_Route_2
    {

      new Vector3(1925.767333984375, 2614.566162109375, 46.16560363769531),
      new Vector3(299.0667419433594, 2642.93798828125, 44.60177993774414),
      new Vector3(1162.4556884765625, 1806.3663330078125, 74.3133773803711),
      new Vector3(1297.0450439453125, 1105.742919921875, 105.6315689086914),
      new Vector3(-524.4381103515625, -268.2084045410156, 35.28974533081055),
      new Vector3(427.09521484375, -960.2006225585938, 29.13089942932129),
      new Vector3(-567.5792846679688, -2212.6533203125, 5.859220504760742),
    }.AsReadOnly();
    private readonly IReadOnlyCollection<Vector3> Skill2Route3 = new List<Vector3>//Bus_Skill_2_Route_3
    {

      new Vector3(-562.68, -2203.85, 5.5),
    }.AsReadOnly();
    private readonly IReadOnlyCollection<Vector3> Skill2Route4 = new List<Vector3>//Bus_Skill_2_Route_4
    {

      new Vector3(-562.68, -2203.85, 5.5),
    }.AsReadOnly();
    private readonly IReadOnlyCollection<Vector3> Skill3Route1 = new List<Vector3>//Bus_Skill_3_Route_1
    {

      new Vector3(-598.849365234375, -2053.087646484375, 5.8428778648376465),
      new Vector3(-229.679931640625, -2049.821533203125, 27.384798049926758),
      new Vector3(-72.33480834960938, -615.8173217773438, 35.91234588623047),
      new Vector3(-176.9166717529297, -153.85665893554688, 43.38493728637695),
      new Vector3(-508.5746765136719, -261.1121826171875, 35.247962951660156),
      new Vector3(-1396.5457763671875, 51.69581604003906, 53.21350860595703),
      new Vector3(-1911.845458984375, 205.62884521484375, 84.06185150146484),
      new Vector3(-1675.4029541015625, 488.7856140136719, 128.6395721435547),
      new Vector3(-995.8155517578125, 589.4381713867188, 102.18698120117188),
      new Vector3(-314.6571350097656, 451.9184875488281, 107.99801635742188),
      new Vector3(211.09194946289062, 350.1848449707031, 105.41163635253906),
      new Vector3(599.4515380859375, 626.0756225585938, 128.6754608154297),
      new Vector3(969.324462890625, 164.03329467773438, 80.59388732910156),
      new Vector3(1069.521240234375, -763.7572631835938, 57.43597412109375),
      new Vector3(1421.075927734375, -1854.2821044921875, 70.56175994873047),
      new Vector3(268.5604248046875, -2070.274169921875, 16.816179275512695),
      new Vector3(-147.51795959472656, -1974.3182373046875, 22.48438262939453),
      new Vector3(-569.0294189453125, -2210.80908203125, 5.571292877197266),
    }.AsReadOnly();
    private readonly IReadOnlyCollection<Vector3> Skill3Route2 = new List<Vector3>//Bus_Skill_3_Route_2
    {

      new Vector3(-597.8766479492188, -2053.534423828125, 5.853154182434082),
      new Vector3(-895.4871826171875, -2074.380126953125, 8.602267265319824),
      new Vector3(-667.8001708984375, -1233.9366455078125, 10.274462699890137),
      new Vector3(-1349.004150390625, -1119.2432861328125, 4.00660514831543),
      new Vector3(-2127.448974609375, -333.7845153808594, 13.013818740844727),
      new Vector3(-1426.419189453125, -90.23416137695312, 51.81801223754883),
      new Vector3(-827.4555053710938, -235.72817993164062, 36.84095764160156),
      new Vector3(-558.2310791015625, -161.801513671875, 37.93125534057617),
      new Vector3(220.4048309326172, -852.0598754882812, 29.874643325805664),
      new Vector3(363.25042724609375, -1470.600830078125, 28.91864776611328),
      new Vector3(-200.07644653320312, -1941.02783203125, 27.382631301879883),
      new Vector3(-605.2278442382812, -2087.974853515625, 5.752280235290527),
    }.AsReadOnly();
    private readonly IReadOnlyCollection<Vector3> Skill3Route3 = new List<Vector3>//Bus_Skill_3_Route_3
    {

      new Vector3(-562.68, -2203.85, 5.5),
    }.AsReadOnly();
    private readonly IReadOnlyCollection<Vector3> Skill3Route4 = new List<Vector3>//Bus_Skill_3_Route_4
    {

      new Vector3(-562.68, -2203.85, 5.5),
    }.AsReadOnly();

    public BusDriverJob()
    {
      JobStart += BusDriverJob_JobStart;
    }

    private void BusDriverJob_JobStart(Player player)
    {
      /*List<String> listRouteTexts = new List<string>();
      List<String> listRouteTexts2 = new List<string>();
      List<String> listRouteTexts3 = new List<string>();

      Vehicle veh = player.Vehicle;

      if ((VehicleHash)veh.Model == VehicleHash.Bus)
      {
        listRouteTexts2.Add("Kurz 1");
        listRouteTexts2.Add("Kurz 2"); ;

        player.TriggerEvent("showBusRouteMenu", JsonConvert.SerializeObject(listRouteTexts2));
      }
      else if ((VehicleHash)veh.Model == VehicleHash.Tourbus)
      {
        listRouteTexts3.Add("Mittel 1");
        player.TriggerEvent("showBusRouteMenu", JsonConvert.SerializeObject(listRouteTexts3));
      }
      else
      {
        listRouteTexts.Add("Lang 1");
        listRouteTexts.Add("Lang 2");

        player.TriggerEvent("showBusRouteMenu", JsonConvert.SerializeObject(listRouteTexts));
      }*/
      /*if (player.GetUser().BusSkill < 300)
      {
        Random rnd = new Random();
        int rroute = rnd.Next(1, 3);
        switch (rroute)
        {
          case 1:
            {
              StartBusRoute(player, "Route1");
              player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 1");
              break;
            }
          case 2:
            {
              StartBusRoute(player, "Route2");
              player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 2");
              break;
            }
        }
      }
      if (player.GetUser().BusSkill > 300 && player.GetUser().BusSkill < 300)
      {
        Random rnd = new Random();
        int rroute = rnd.Next(1, 3);
        switch (rroute)
        {
          case 1:
            {
              StartBusRoute(player, "Route3");
              player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 3");
              break;
            }
          case 2:
            {
              StartBusRoute(player, "Route4");
              player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 4");
              break;
            }
        }
      }
      if (player.GetUser().BusSkill >= 800)
      {
        StartBusRoute(player, "Route5");
        player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 5");
      }*/
    }

    [RemoteEvent("startBusRoute")]
    public void StartBusRoute(Player player, string type)
    {
      Vehicle veh = player.Vehicle;
      if (player.VehicleSeat == 0)
      {
        if (type == "RouteStart")
        {
          if ((VehicleHash)veh.Model == VehicleHash.Bus)
          {
            Random rnd = new Random();
            int rroute = rnd.Next(1, 5);
            switch (rroute)
            {
              case 1:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill1Route1, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 1");
                  player.SetData("Route", "Skill1Route1");
                  break;
                }
              case 2:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill1Route2, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 2");
                  player.SetData("Route", "Skill1Route2");
                  break;
                }
              case 3:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill1Route3, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 3");
                  player.SetData("Route", "Skill1Route3");
                  break;
                }
              case 4:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill1Route4, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 4");
                  player.SetData("Route", "Skill1Route4");
                  break;
                }
            }
            player.TriggerEvent("CLIENT:SetDoorOpen", 0, false, false);
            player.TriggerEvent("CLIENT:SetDoorOpen", 1, false, false);
            player.TriggerEvent("CLIENT:SetDoorOpen", 2, false, false);
            player.TriggerEvent("CLIENT:SetDoorOpen", 3, false, false);
            player.TriggerEvent("CLIENT:SetDoorShut", 0, false);
            player.TriggerEvent("CLIENT:SetDoorShut", 1, false);
            player.TriggerEvent("CLIENT:SetDoorShut", 2, false);
            player.TriggerEvent("CLIENT:SetDoorShut", 3, false);
          }
          if ((VehicleHash)veh.Model == VehicleHash.Coach)
          {
            Random rnd = new Random();
            int rroute = rnd.Next(1, 5);
            switch (rroute)
            {
              case 1:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill2Route1, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 1");
                  player.SetData("Route", "Skill2Route1");
                  break;
                }
              case 2:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill2Route2, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 2");
                  player.SetData("Route", "Skill2Route2");
                  break;
                }
              case 3:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill2Route3, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 3");
                  player.SetData("Route", "Skill2Route3");
                  break;
                }
              case 4:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill2Route4, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 4");
                  player.SetData("Route", "Skill2Route3");
                  break;
                }
            }
            player.TriggerEvent("CLIENT:SetDoorOpen", 0, false, false);
            player.TriggerEvent("CLIENT:SetDoorShut", 0, false);
          }
          if ((VehicleHash)veh.Model == VehicleHash.Tourbus)
          {
            Random rnd = new Random();
            int rroute = rnd.Next(1, 5);
            switch (rroute)
            {
              case 1:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill3Route1, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 1");
                  player.SetData("Route", "Skill3Route1");
                  break;
                }
              case 2:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill3Route2, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 2");
                  player.SetData("Route", "Skill3Route2");
                  break;
                }
              case 3:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill3Route3, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 3");
                  player.SetData("Route", "Skill3Route3");
                  break;
                }
              case 4:
                {
                  CheckPointHandle.StartCheckPointRoute(player, Skill3Route4, 4000, 1, 7, 3, true, "busDriverJob");
                  player.SendChatMessage("~y~[JOB] ~w~Route wurde gesetzt.: ~g~Route 4");
                  player.SetData("Route", "Skill3Route4");
                  break;
                }
            }
            player.TriggerEvent("CLIENT:SetDoorOpen", 2, false, false);
            player.TriggerEvent("CLIENT:SetDoorOpen", 3, false, false);
            player.TriggerEvent("CLIENT:SetDoorShut", 2, false);
            player.TriggerEvent("CLIENT:SetDoorShut", 3, false);
          }
        }
        /*if (type == "Skill1Route1")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill1Route1, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill1Route2")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill1Route2, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill1Route3")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill1Route3, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill1Route4")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill1Route4, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill2Route1")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill2Route1, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill2Route2")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill2Route2, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill2Route3")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill2Route3, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill2Route4")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill2Route4, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill3Route1")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill3Route1, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill3Route2")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill3Route2, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill3Route3")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill3Route3, 4000, 1, 7, 4, true, "busDriverJob");
        }
        if (type == "Skill3Route4")
        {
          CheckPointHandle.StartCheckPointRoute(player, Skill3Route4, 4000, 1, 7, 4, true, "busDriverJob");
        }*/
        //player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/StartJob", "wav", 50);
      }
    }

    public static void payWage(Player jobber, int wage)
    {
      using (var dbContext = new DatabaseContext())
      {
        if (jobber.VehicleSeat == 0)
        {
          jobber.GetUser(dbContext).Wage += wage;
          //jobber.SendNotification($"~y~[JOB] ~g~+{wage}$");
          jobber.GetUser(dbContext).BusSkill++;
          dbContext.SaveChanges();
          if (jobber.GetUser(dbContext).BusSkill == 300)
          {
            jobber.SendChatMessage($"~y~[JOB] ~w~Du hast nun ~g~Skill-Level 2 ~w~erreicht!");
            jobber.SendChatMessage($"~y~[JOB] ~w~Du kannst jetzt auch mit dem Coach-Bus fahren!");
          }
          if (jobber.GetUser(dbContext).BusSkill == 800)
          {
            jobber.SendChatMessage($"~y~[JOB] ~w~Du hast nun ~g~Skill-Level 3 ~w~erreicht!");
            jobber.SendChatMessage($"~y~[JOB] ~w~Du kannst jetzt mit dem Coach, und dem Tourbus fahren!");
          }
        }
        else
        {
          JobBase job = JobManager.GetJob(jobber.GetUser().JobId ?? -1);
          job.StopJob(jobber);
          CheckPointHandle.DeleteCheckpoints(jobber);
          ChatService.SendMessage(jobber, $"~y~[JOB]~s~ Du hast deinen Job ~o~{job.Name}~s~ beendet.");
        }
        //BusLetzterCheckpoint(jobber);
        //BusDriverJob rt = null;
        //rt.BusLetzterCheckpoint()
      }
    }

    [RemoteEvent("BusLetzterCheckpoint")]
    public static void BusLetzterCheckpoint(Player player)
    {
      BusDriverJob c = new BusDriverJob();
      Vehicle v = player.Vehicle;
      player.SendChatMessage("~y~[JOB] ~w~Die neue Route Lädt. Bitte Warten...");
      NAPI.Task.Run(() =>
      {
        if (player.VehicleSeat == 0)
        {
          player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/FahrplanAbfahrt", "wav", 15);
          c.StartBusRoute(player, "RouteStart");
        }
        else
        {
          Vehicle LastVehicle = player.GetData<Vehicle>("LastVehicle");
          JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
          if (LastVehicle.GetServerVehicle() is JobVehicle vehJ)
          {
            if (LastVehicle.GetData<bool>("timerJobVehicleRespawn") == true)
            {
              if (vehJ.GetJob().GetUsersInJob().Contains(player))
              {
                if (LastVehicle != null)
                {
                  LastVehicle.ResetData("timerJobVehicleRespawn");
                  ServerVehicle sVeh = VehicleManager.GetServerVehicleFromVehicle(LastVehicle);
                  ServerVehicleExtensions.Spawn(sVeh, LastVehicle);
                  job.StopJob(player);
                  ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{job.Name}~s~ beendet.");
                  CheckPointHandle.DeleteCheckpoints(player);
                  if (!player.HasData("isDead") || player.GetData<bool>("isDead") == false)
                  {
                    if (player.GetUser().JobId == 1)//Taxifahrer
                    {
                      //VehicleManager.DeleteVehicle(v);
                    }
                    if (player.GetUser().JobId == 2)//Müllmann
                    {
                      //VehicleManager.DeleteVehicle(v);
                    }
                    if (player.GetUser().JobId == 3)//Pilot
                    {
                      if (!player.HasData("PilotenBase") || player.GetData<int>("PilotenBase") == 1) //Sandyshores
                      {
                        player.Position = new Vector3(1707.2711181640625, 3276.216064453125, 41.155494689941406);
                        player.Heading = (-154.65234375f);
                      }
                      if (player.HasData("PilotenBase") && player.GetData<int>("PilotenBase") == 2) //LS Airport
                      {
                        player.Position = new Vector3(-1622.48, -3151.58, 13);
                        player.Heading = (48.44f);
                      }
                    }
                    if (player.GetUser().JobId == 4)//Busfahrer
                    {
                      player.Position = new Vector3(-535.46, -2144.97, 5.95);
                      player.Heading = (57.03f);
                    }
                  }
                }
              }
            }
          }
        }
        /*if (v.Model == (uint)Types.VehicleModel.Bus)
        {
          player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/FahrplanAbfahrt", "wav", 15);
          Random rnd = new Random();
          int rroute = rnd.Next(1, 5);
          switch (rroute)
          {
            case 1:
              {
                  c.StartBusRoute(player, "Skill1Route1");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 1");
                break;
              }
            case 2:
              {
                  c.StartBusRoute(player, "Skill1Route2");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 2");
                break;
              }
            case 3:
              {
                  c.StartBusRoute(player, "Skill1Route3");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 3");
                break;
              }
            case 4:
              {
                  c.StartBusRoute(player, "Skill1Route4");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 4");
                break;
              }
          }
        }
        if (v.Model == (uint)Types.VehicleModel.Coach)
        {
          player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/FahrplanAbfahrt", "wav", 15);
          Random rnd = new Random();
          int rroute = rnd.Next(1, 5);
          switch (rroute)
          {
            case 1:
              {
                  c.StartBusRoute(player, "Skill2Route1");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 1");
                break;
              }
            case 2:
              { 
                  c.StartBusRoute(player, "Skill2Route2");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 2");
                break;
              }
            case 3:
              {
                  c.StartBusRoute(player, "Skill2Route3");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 3");
                break;
              }
            case 4:
              {
                  c.StartBusRoute(player, "Skill2Route4");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 4");
                break;
              }
          }
        }
        if (v.Model == (uint)Types.VehicleModel.Tourbus)
        {
          player.TriggerEvent("CLIENT:PlaySound", "jobs/busfahrer/FahrplanAbfahrt", "wav", 15);
          Random rnd = new Random();
          int rroute = rnd.Next(1, 5);
          switch (rroute)
          {
            case 1:
              {
                  c.StartBusRoute(player, "Skill3Route1");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 1");
                break;
              }
            case 2:
              {
                  c.StartBusRoute(player, "Skill3Route2");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 2");
                break;
              }
            case 3:
              {
                  c.StartBusRoute(player, "Skill3Route3");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 3");
                break;
              }
            case 4:
              {
                  c.StartBusRoute(player, "Skill3Route4");
                  player.SendChatMessage("~y~[JOB] ~w~Eine neue Route wurde gesetzt.: ~g~Route 4");
                break;
              }
          }
        }*/
      }, delayTime: 30000);
    }
  }
}
