using System;
using GTA;
using GTA.Native;

public class GtaClassicsPopups : Script
{
    private float offset = 0.15f;
    
    public GtaClassicsPopups()
    {
        Tick += OnTick;
    }
    void OnTick(object sender, EventArgs e)
    {
        Ped player = Game.Player.Character;

        if (player.IsInVehicle())
        {
            Vehicle vehicle = player.CurrentVehicle;
            if (vehicle.Model == "camaro68b" ||
                vehicle.Model == "camaro68c" ||
                vehicle.Model == "firebird87")
            {
                var popupRight = VehicleDoor.BackRightDoor;
                var popupLeft = VehicleDoor.BackLeftDoor;
                float doorVal = 0.0f;
                if (vehicle.LightsOn || vehicle.HighBeamsOn) {
                    doorVal = 1.0f;
                }            
                doorVal = doorVal * (1.0f-offset) + offset;
                Function.Call(Hash.SET_VEHICLE_DOOR_CONTROL, vehicle, (int)popupRight, 5, doorVal);
                Function.Call(Hash.SET_VEHICLE_DOOR_CONTROL, vehicle, (int)popupLeft, 5, doorVal);
            }
        }
    }
}