[Request] Loud car radios

Hello,
I just thought it would be great to have this singplayer mod on fiveM server. Maybe someone’s able to create fiveM version?
Cheers,
Patison

You could easy implement it yourself. All it does is:

  1. Check whether last vehicle’s engine is running with
BOOL GET_IS_VEHICLE_ENGINE_RUNNING(Vehicle vehicle);

and

Vehicle GET_VEHICLE_PED_IS_IN(Ped ped, BOOL lastVehicle);

  1. Make the radio loud of that vehicle with
void SET_VEHICLE_RADIO_LOUD(Vehicle vehicle, BOOL toggle);

Edit: Here you go @patison Download me

Untested

1 Like

When I leave my engine running (with this) and step out of my car I dont hear anything but it does work partially because when I enter car I hear loud, muffled radio for a second. I dont have anyone to test if other players hear my loud radio right now.
Cheers

I see okay. I can’t test it either right now. Will maybe look into it later tonight. If it doesn’t work as intended, then the original script doesn’t work too.

Ok so basically when I’m outside and my friend’s inside the vehicle, I can hear his radio loudly, but doesnt work when no one’s inside. I think the problem is with keeping engine running. When I leave my car the engine goes off and quickly turns on so maybe it’s like radio is off because there is no one to turn on radio.
I guess I should talk to LeaveEngineRunning’s author or maybe u can help me somehow.

Edit
When I kill the driver I can hear radio loudly so its 100% problem with LeaveEngineRunning.

I just realized author’s not gonna update his plugin so can u help me out with this by any chance?
Here u have his source code.

client.lua (630 Bytes)
Thank you in advance :slight_smile:

Here you go, thought I would fix it for you.

Just a few lines of code [Release] Loud Radio C#

Thank you very much. Works perfectly :smiley:

or actually doesnt. I cant exit vehicle with turning off th engine. Now it keeps engine on all the time :confused:

Yes, that’s what @BabbaTundaee code does. And that’s also what fixes the issue what you had when no one was in a car. To be able to turn on a radio, the car needs to be on. So if it turn off and on again, the radio will also have to be turned on.

As @d0p3t Said you cannot have your radio playing outside of your vehicle without it being on all the time unfortunately, however you could implement a key or a command to manually turn off your engine. As all that script does is a check if the engine is on if so, set it on when you leave your vehicle.

Command

RegisterCommand("engine", function()
    local ply = PlayerPedId()
    local veh = GetVehiclePedIsIn(ply, false)
	
	if IsPedInAnyVehicle(ply) then
        if IsVehicleEngineOn(veh) then
            SetVehicleEngineOn(veh, false, false, true)
            SetVehicleUndriveable(veh, true)
		    drawNotification('~r~Your engine has been turned off.')
        else
            SetVehicleEngineOn(veh, true, false, true)
            SetVehicleUndriveable(veh, false)
		    drawNotification('~g~Your engine has been turned on.')
        end
	else
	    drawNotification('~r~You are not in a vehicle.')
    end
end, false)

function drawNotification(text)
    SetNotificationTextEntry("STRING")
    AddTextComponentString(text)
    DrawNotification(false, false)
end

Button

Citizen.CreateThread(function()
	while true do
		Wait(0)

		local ply = PlayerPedId()
		local veh = GetVehiclePedIsIn(ply, false)
		
		if IsControlPressed(1, 244) then
			if IsPedInAnyVehicle(ply) then
				if IsVehicleEngineOn(veh) then
					SetVehicleEngineOn(veh, false, false, true)
					SetVehicleUndriveable(veh, true)
					drawNotification('~r~Your engine has been turned off.')
				else
					SetVehicleEngineOn(veh, true, false, true)
					SetVehicleUndriveable(veh, false)
					drawNotification('~g~Your engine has been turned on.')
				end
			else
				drawNotification('~r~You are not in a vehicle.')
			end
		end
	end
end)

function drawNotification(text)
    SetNotificationTextEntry("STRING")
    AddTextComponentString(text)
    DrawNotification(false, false)
end

I just wanted it to be like this:

  • I leave car with engine on = loud radio and engine on
  • I leave car turning off engine = no radio because engine is off.
    I’m using this addon to simply choose whether I want to turn off engine why leaving or leaving it on.

Now I cant leave my car with engine off using this addon.

What?

oh gosh.
LeaveEngineRunning lets me go out of the car in two ways

  • pressing F to go out without turning off the engine
  • holding F to go out with turning off engine.

With ur loud radio plugin I cant leave my car using second way. The engine is running no matter what.
I thought about using script u mentioned but wanted to keep everything simple. Thats why I’m using LeaveEngineRunning. Is there any way to make these two plugins work together? I dont really want command / button for toggling engine’s state.

Just alter my code (LeaveEngineRunning) in the client.lua like so:

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)

		local ped = GetPlayerPed(-1)
		
		if DoesEntityExist(ped) and IsPedInAnyVehicle(ped, false) and IsControlPressed(2, 75) and not IsEntityDead(ped) and not IsPauseMenuActive() then
			local engineWasRunning = GetIsVehicleEngineRunning(GetVehiclePedIsIn(ped, true))
			Citizen.Wait(1000)
			if DoesEntityExist(ped) and not IsPedInAnyVehicle(ped, false) and not IsEntityDead(ped) and not IsPauseMenuActive() then
				local veh = GetVehiclePedIsIn(ped, true)
				if (engineWasRunning) then
					SetVehicleEngineOn(veh, true, true, true)
                    SetVehicleRadioEnabled(veh, true);
                    SetVehicleRadioLoud(veh, true);
				end
			end
		end
	end
end)

There you go do that ^^

Teamwork :hugs:

1 Like

I still cant leave my car without leaving my engine on…
I altered @ToastinYou’s code.

edit. I could add engine-toggle on button as @BabbaTundaee asked me to do but cant find id of i button

Hey,
I was wondering if someone is able to fix patison’s issue because I’d like to have this resource on my server aswell
Greetings!

so can sum one like send me one or reply with one plz i really want a loud radio and ima bad dev so idrk how to do this ty