// GTA V Radio Control Script
// Version: 1.0
// Author: Abusayeed Shafee
// Contact: https://m.me/shafee9

// Description:
// This script allows players to toggle the vehicle radio on and off in Grand Theft Auto V. By default, the radio is enabled when the player enters a vehicle. Pressing the designated toggle key (Q by default) will enable or disable the vehicle radio. The script continuously checks if the player is in a vehicle and updates the radio state accordingly. A notification is displayed whenever the radio is enabled or disabled.

using GTA;
using GTA.Math;
using GTA.Native;
using System;
using System.Windows.Forms;

public class RadioControlScript : Script
{
    private bool radioEnabled;
    private Keys toggleKey = Keys.Q; // Customize the toggle key as desired

    public RadioControlScript()
    {
        radioEnabled = true;
        Tick += OnTick;
        KeyUp += OnKeyUp;
        Interval = 100; // Check every 0.1 seconds
    }

    private void OnTick(object sender, EventArgs e)
    {
        if (Game.Player.Character.IsInVehicle())
        {
            Vehicle playerVehicle = Game.Player.Character.CurrentVehicle;
            if (playerVehicle != null)
            {
                if (radioEnabled)
                {
                    Function.Call(Hash.SET_VEHICLE_RADIO_ENABLED, playerVehicle.Handle, true);
                }
                else
                {
                    Function.Call(Hash.SET_VEHICLE_RADIO_ENABLED, playerVehicle.Handle, false);
                }
            }
        }
    }

    private void OnKeyUp(object sender, KeyEventArgs e)
    {
        if (Game.Player.Character.IsInVehicle() && e.KeyCode == toggleKey)
        {
            radioEnabled = !radioEnabled;
            string message = radioEnabled ? "Radio enabled." : "Radio disabled.";
            UI.Notify(message);
        }
    }
}
