# API

## Client side exports / events

#### Event: `rcore_radiocar:API:OpenPlayerUI`

* Description
  * This event will open the radio UI if the vehicle meets the requirements to open the radio.

Example:

```lua
RegisterCommand("openradio", function(source, args, raw)
	TriggerEvent("rcore_radiocar:API:OpenPlayerUI")
end)

-- can be called from server-side as well
-- assuming this is a server-side command
RegisterCommand("openradioserver", function(source, args, raw)
	TriggerClientEvent("rcore_radiocar:API:OpenPlayerUI", source)
end)
```

#### Export: OpenPlayerUI

* Description
  * This event will open the radio UI if the vehicle meets the requirements to open the radio.

Example:

```lua
RegisterCommand("test", function(source, args, raw)
	exports.rcore_radiocar:OpenPlayerUI()
end)
```

## Server side exports

if you want to use any of these exports you need to enable them in config.lua So go to your config.lua look for this\
\
`Config.OnlyCarWhoHaveRadio`

And set it to true

This function will allow to the specific plate vehicle to use radio

```lua
-- All types can be find in config.lua
-- Look for Config.RadioStyle
GiveRadioToCar(LicensePlate, typeRadio)
```

Example:

```lua
function GetVehPlate(source)
	return GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(source)))
end

function IsPedInAnyVehicle(source)
	return GetVehiclePedIsIn(GetPlayerPed(source), false) ~= 0
end

RegisterNetEvent("rcore_itemradio:sendLicensePlate", function()
	if not IsPedInAnyVehicle(source) then
		return
	end
	local plate = GetVehPlate(source)

	exports.rcore_radiocar:GiveRadioToCar(plate, 2)
end)
```

Simple function that will return true/false if the plate owns radio

```lua
HasCarRadio(LicensePlate)
```

If you need to check specific type then use this export

```lua
HasCarRadioType(LicensePlate, radioType)
```

Example:

```lua
function GetVehPlate(source)
	return GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(source)))
end

function IsPedInAnyVehicle(source)
	return GetVehiclePedIsIn(GetPlayerPed(source), false) ~= 0
end

RegisterNetEvent("rcore_itemradio:sendLicensePlate", function()
	if not IsPedInAnyVehicle(source) then
		return
	end
	local plate = GetVehPlate(source)

	if exports.rcore_radiocar:HasCarRadio(plate) then
		print("this plate", plate, "does have already the radio")
	else
		print("this plate", plate, "sadly doesnt have radio!")
	end
end)
```

This function will remove access to the radio for the specific plate

```lua
RemoveRadioFromCar(LicensePlate)
```

Example:

```lua
function GetVehPlate(source)
	return GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(source)))
end

function IsPedInAnyVehicle(source)
	return GetVehiclePedIsIn(GetPlayerPed(source), false) ~= 0
end

RegisterNetEvent("rcore_itemradio:sendLicensePlate", function()
	if not IsPedInAnyVehicle(source) then
		return
	end
	local plate = GetVehPlate(source)

	exports.rcore_radiocar:RemoveRadioFromCar(plate)
end)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.rcore.cz/paid-resources/rcore_radiocar/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
