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

namespace ReallifeGamemode.Server.Events
{

    public class EnterVehicleAttempt : Script
    {
        [ServerEvent(Event.PlayerEnterVehicleAttempt)]
        public void OnPlayerEnterVehicleAttempt(Client player, Vehicle vehicle, sbyte seat)
        {
            if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
            {
                if (seat == 1) seat = 0;
                else if (seat == 0) seat = 1;
            }

            if (seat != 0) return;

            if (vehicle.GetServerVehicle() is FactionVehicle veh)
            {
                if (veh.FactionId != player.GetUser().FactionId)
                {
                    player.StopAnimation();
                    player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
                    return;
                }
            }
        }
    }
}
