using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Services;

namespace ReallifeGamemode.Server.Events
{
  class Waypoint : Script
  {
    [RemoteEvent("SERVER:waypointToDriver")]
    public void setWaypointToDriver(Player player, float x, float y)
    {
      if (!player.IsInVehicle)
      {
        return;
      }

      if (player.VehicleSeat == 0)
      {
        return;
      }

      Entity entity = NAPI.Vehicle.GetVehicleDriver(player.Vehicle);
      Player driver = PlayerService.GetPlayerByNameOrId(entity.Value.ToString());

      if (driver == null || entity == null)
      {
        return;
      }

      driver.TriggerEvent("SERVER:Util_setWaypoint", x, y);
      driver.SendNotification(player.Name + " hat dir eine Markierung auf der Karte gesetzt");
      player.SendNotification("Du hast " + driver.Name + " eine Markierung auf der Karte gesetzt");
    }
  }
}
