API

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

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

Example:

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

HasCarRadio(LicensePlate)

If you need to check specific type then use this export

HasCarRadioType(LicensePlate, radioType)

Example:

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

RemoveRadioFromCar(LicensePlate)

Example:

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)

Last updated