Jump to content
RAGE Multiplayer Community

Force vehicle radio to off


TimFL
 Share

Recommended Posts

I've been looking for a way to disable the radio as smoothly as possible (so no sound cut-off or infinite loops anywhere), this is what Daniel Hartung (from Discord) and I came up with:

 

Client-side (trigger this in your server-side playerEnterVehicle event, has to be triggered server-side cause the client-side variant triggers too early before the player is in the vehicle)

	const localPlayer = mp.players.local;
	let radioKillTimer = null;
	 
	mp.game.audio.setUserRadioControlEnabled(false);
	 
	mp.events.add("disableVehicleRadio", () => {
	    if(radioKillTimer == null){
	        radioKillTimer = setInterval(() => {
	            if(localPlayer.isSittingInAnyVehicle()){
	                mp.game.audio.setRadioToStationName("OFF");
	                clearInterval(radioKillTimer);
	                radioKillTimer = null;
	                return;
	            }
	       }, 100);
	   }
	});

 

The custom client event checks whether a timer to kill the radio already exists, if not it creates one (interval 100ms) that runs until the local player entity reports the fact that they're sitting in a vehicle. That's when the radio is set to off and the timer is killed and it's ensured that the radio station is only set once (preventing jittery sound).

  • Like 2
Link to comment
Share on other sites

why using server-resources when client-side only works.
 

mp.game.audio.setRadioToStationName("OFF");
mp.game.audio.setUserRadioControlEnabled(false);

mp.events.add("render", () => {

    if (mp.players.local.vehicle) {
        mp.game.audio.setRadioToStationName("OFF");
        mp.game.audio.setUserRadioControlEnabled(false);
    }

});
  • Like 1
Link to comment
Share on other sites

8 hours ago, DevGrab said:

why using server-resources when client-side only works.
 

mp.game.audio.setRadioToStationName("OFF");
mp.game.audio.setUserRadioControlEnabled(false);

mp.events.add("render", () => {

    if (mp.players.local.vehicle) {
        mp.game.audio.setRadioToStationName("OFF");
        mp.game.audio.setUserRadioControlEnabled(false);
    }

});

Because you're setting the stations once every render tick, and setting the radio has that sideeffect of jittery sound/radio frequency searching sound playing 247. Tried several ways of doing it, even with a render version (that works similar to the one in the first post) but this is the best/least resource intensive way we could come up with.

  • Like 1
Link to comment
Share on other sites

Am 15.12.2018 um 21:29 schrieb TimFL:

Because you're setting the stations once every render tick, and setting the radio has that sideeffect of jittery sound/radio frequency searching sound playing 247. Tried several ways of doing it, even with a render version (that works similar to the one in the first post) but this is the best/least resource intensive way we could come up with.

nope, works fine.

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...