51 lines
1.7 KiB
Lua
51 lines
1.7 KiB
Lua
local enabled = false
|
|
local station = 'RADIO_02_POP'
|
|
|
|
local function notify(message) exports.devx_core:Notify(message) end
|
|
|
|
local function apply(vehicle)
|
|
if not vehicle or vehicle == 0 then return end
|
|
if enabled then
|
|
SetVehicleRadioEnabled(vehicle, true)
|
|
SetVehRadioStation(vehicle, station)
|
|
SetRadioToStationName(station)
|
|
else
|
|
SetVehRadioStation(vehicle, 'OFF')
|
|
SetVehicleRadioEnabled(vehicle, false)
|
|
end
|
|
end
|
|
|
|
local function toggle()
|
|
local ped = PlayerPedId()
|
|
local vehicle = GetVehiclePedIsIn(ped, false)
|
|
if vehicle == 0 then notify('Das Radio ist nur in einem Fahrzeug verfügbar.'); return end
|
|
enabled = not enabled
|
|
apply(vehicle)
|
|
notify(enabled and 'Radio: Non-Stop-Pop FM' or 'Radio ausgeschaltet.')
|
|
end
|
|
|
|
RegisterCommand('radio', toggle, false)
|
|
RegisterCommand('+devxradio', toggle, false)
|
|
RegisterCommand('-devxradio', function() end, false)
|
|
RegisterKeyMapping('+devxradio', 'Fahrzeugradio: Non-Stop-Pop FM / Aus', 'keyboard', 'R')
|
|
|
|
CreateThread(function()
|
|
local lastVehicle = 0
|
|
while true do
|
|
local ped = PlayerPedId()
|
|
local vehicle = GetVehiclePedIsIn(ped, false)
|
|
if vehicle ~= 0 then
|
|
-- Hide the standard station wheel and keep the allowed state enforced.
|
|
DisableControlAction(0, 81, true)
|
|
DisableControlAction(0, 82, true)
|
|
DisableControlAction(0, 85, true)
|
|
if vehicle ~= lastVehicle then apply(vehicle); lastVehicle = vehicle end
|
|
if enabled and GetPlayerRadioStationName() ~= station then apply(vehicle) end
|
|
Wait(0)
|
|
else
|
|
lastVehicle = 0
|
|
Wait(500)
|
|
end
|
|
end
|
|
end)
|