using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.WeaponDeal;

namespace ReallifeGamemode.Server.Events
{
  public class EnterVehicle : Script
  {
    [ServerEvent(Event.PlayerEnterVehicle)]
    public void OnPlayerEnterVehicle(Player client, GTANetworkAPI.Vehicle vehicle, sbyte seat)
    {
      if (seat != -1)
        return;
      if (vehicle.GetServerVehicle() is FactionVehicle veh)
      {
        if (client.GetUser().FactionId != null && (veh.FactionId == client.GetUser().FactionId) && (veh.Model == VehicleHash.Burrito3) && vehicle.HasData("weaponDeal") && vehicle.GetData<bool>("weaponDeal") == true)
        {
          Vector3 vector = WeaponDealPoints.getRndWD_Route(client.GetUser().FactionId.Value);
          if (vector == new Vector3())
            return;
          List<Vector3> dealPoint = new List<Vector3>();
          dealPoint.Add(vector);
          CheckPointHandle.StartCheckPointRoute(client, dealPoint, 5000, 1, 7, "loadWeaponTransport");
        }
      }
    }
  }
}
