Adding New Static Emitters

Possibly relevant excerpt from fm_mission_controler.c

case joaat("prop_boombox_01"):
case joaat("prop_ghettoblast_02"):
case joaat("prop_tapeplayer_01"):
case joaat("prop_radio_01"):
	if (iVar11 <= iVar10 || iVar11 == -1)
	{
		if (MISC::IS_BIT_SET(Global_4456448.f_54289[iParam0 /*71*/].f_21, 10))
		{
			if (ENTITY::DOES_ENTITY_EXIST(iLocal_1899[iParam0]))
			{
				fVar17 = 50f;
				fVar18 = 100f;
				fVar19 = MISC::GET_DISTANCE_BETWEEN_COORDS(CAM::GET_GAMEPLAY_CAM_COORD(), ENTITY::GET_ENTITY_COORDS(iLocal_1899[iParam0], 1), true);
				if (fVar19 <= fVar18)
				{
					if (iLocal_879 == -1)
					{
						if (!AUDIO::IS_AUDIO_SCENE_ACTIVE("MP_Reduce_Score_For_Emitters_Scene"))
						{
							AUDIO::START_AUDIO_SCENE("MP_Reduce_Score_For_Emitters_Scene");
						}
						AUDIO::_0x651D3228960D08AF("SE_Script_Placed_Prop_Emitter_Boombox", iLocal_1899[iParam0]);
						AUDIO::SET_EMITTER_RADIO_STATION("SE_Script_Placed_Prop_Emitter_Boombox", AUDIO::GET_RADIO_STATION_NAME(Global_4456448.f_54289[iParam0 /*71*/].f_23));
						AUDIO::SET_STATIC_EMITTER_ENABLED("SE_Script_Placed_Prop_Emitter_Boombox", true);
						iLocal_879 = iParam0;
					}
					if (iLocal_879 != -1 && iLocal_879 == iParam0)
					{
						if (AUDIO::IS_AUDIO_SCENE_ACTIVE("MP_POSITIONED_RADIO_MUTE_SCENE"))
								{
									AUDIO::SET_AUDIO_SCENE_VARIABLE("MP_POSITIONED_RADIO_MUTE_SCENE", "apply", (1f - ((1f / fVar18) * (fVar18 - func_1417((fVar19 - fVar17), 0f, fVar18)))));
								}
								if (AUDIO::IS_AUDIO_SCENE_ACTIVE("MP_Reduce_Score_For_Emitters_Scene"))
						{
							AUDIO::SET_AUDIO_SCENE_VARIABLE("MP_Reduce_Score_For_Emitters_Scene", "apply", ((1f / fVar18) * (fVar18 - func_1417((fVar19 - fVar17), 0f, fVar18))));
						}
					}
				}
				else if (iLocal_879 != -1)
				{
					if (AUDIO::IS_AUDIO_SCENE_ACTIVE("MP_Reduce_Score_For_Emitters_Scene"))
					{
						AUDIO::STOP_AUDIO_SCENE("MP_Reduce_Score_For_Emitters_Scene");
					}
					AUDIO::SET_STATIC_EMITTER_ENABLED("SE_Script_Placed_Prop_Emitter_Boombox", false);
					iLocal_879 = -1;
				}
			}
		}
	}
	break;
1 Like

Curious what that native does. Not finding much on it in the native references.

Thanks for sharing. I may submit this over as a feature request.

The arguments are an ‘emitter name’ and an entity. Could be worth testing.

I tested it a bit this morning, can’t seem to get anything to play. I attached the static emitter using the native mentioned above to both my player ped, as well as a spawned object, and neither would play. I also made the script iterate through all ~36 radio stations and set the emitter to that radio station for 5 seconds to see if the emitter would play any, and it didn’t :confused:

This is what I tried out. Thoughts?

Attaching to Player Ped:

Citizen.CreateThread(function()
	Citizen.InvokeNative(0x651D3228960D08AF, "Test_Emitter", GetPlayerPed(-1))
	SetEmitterRadioStation("Test_Emitter", GetRadioStationName(1))
	SetStaticEmitterEnabled("Test_Emitter", true)
end)

Attaching to Spawned Object:

local model = GetHashKey("prop_boombox_01")

Citizen.CreateThread(function()
	RequestModel(model)
	while not HasModelLoaded(model) do
		Citizen.Wait(0)
	end
	local coords = GetEntityCoords(GetPlayerPed(-1), true)
	local thisObject = CreateObject(model, coords.x + 1.0, coords.y + 1.0, coords.z, true, false, false)
	Citizen.InvokeNative(0x651D3228960D08AF, "Test_Emitter", thisObject)
	SetEmitterRadioStation("Test_Emitter", GetRadioStationName(1))
	SetStaticEmitterEnabled("Test_Emitter", true)
end)

My only suggestion would be to try “SE_Script_Placed_Prop_Emitter_Boombox” instead of “Test_Emitter”.

1 Like

Wow. That did it. Thanks a ton man.

local model = GetHashKey("prop_boombox_01")

Citizen.CreateThread(function()
	RequestModel(model)
	while not HasModelLoaded(model) do
		Citizen.Wait(0)
	end
	local coords = GetEntityCoords(GetPlayerPed(-1), true)
	local thisObject = CreateObject(model, coords.x + 1.0, coords.y + 1.0, coords.z, true, false, false)
	Citizen.InvokeNative(0x651D3228960D08AF, "SE_Script_Placed_Prop_Emitter_Boombox", thisObject)
	SetEmitterRadioStation("SE_Script_Placed_Prop_Emitter_Boombox", GetRadioStationName(1))
	SetStaticEmitterEnabled("SE_Script_Placed_Prop_Emitter_Boombox", true)
end)

Which suggests you can’t make ‘new’ static emitters (strings), only move around existing ones. Let me go find the strings in the scripts. (Called by SET_STATIC_EMITTER_ENABLED.)

COUNTRYSIDE_ALTRUIST_CULT_01
DLC_IE_Office_Garage_Mod_Shop_Radio_01 *
DLC_IE_Office_Garage_Radio_01 *
DLC_IE_Steal_Photo_Shoot_Pier_Radio_Emitter *
DLC_IE_Steal_Photo_Shoot_Sonora_Desert_Radio_Emitter *
DLC_IE_Steal_Photo_Shoot_Wind_Farm_Radio_Emitter *
DLC_IE_Steal_Pool_Party_Lake_Vine_Radio_Emitter *
DLC_IE_Steal_Pool_Party_Milton_Rd__Radio_Emitter *
DLC_IE_Warehouse_Radio_01 *
LOS_SANTOS_AMMUNATION_GUN_RANGE
LOS_SANTOS_VANILLA_UNICORN_01_STAGE
LOS_SANTOS_VANILLA_UNICORN_02_MAIN_ROOM
LOS_SANTOS_VANILLA_UNICORN_03_BACK_ROOM
MP_ARM_WRESTLING_RADIO_01
MP_ARM_WRESTLING_RADIO_02
MP_ARM_WRESTLING_RADIO_03
MP_ARM_WRESTLING_RADIO_04
MP_ARM_WRESTLING_RADIO_05
MP_ARM_WRESTLING_RADIO_06
MP_ARM_WRESTLING_RADIO_07
MP_ARM_WRESTLING_RADIO_08
MP_ARM_WRESTLING_RADIO_09
MP_ARM_WRESTLING_RADIO_10
SE_AMMUNATION_CYPRESS_FLATS_GUN_RANGE
SE_ba_dlc_club_exterior *
SE_ba_dlc_int_01_Bogs
SE_ba_dlc_int_01_Entry_Hall
SE_ba_dlc_int_01_Entry_Stairs
SE_ba_dlc_int_01_garage
SE_ba_dlc_int_01_main_area
SE_ba_dlc_int_01_main_area_2
SE_ba_dlc_int_01_office
SE_ba_dlc_int_01_rear_L_corridor
se_ba_int_02_ba_workshop_radio
se_ba_int_03_ba_hktrk_radio
SE_bkr_biker_dlc_int_01_BAR
SE_bkr_biker_dlc_int_01_GRG
SE_bkr_biker_dlc_int_01_REC
SE_bkr_biker_dlc_int_02_GRG
SE_bkr_biker_dlc_int_02_REC
SE_COUNTRY_SAWMILL_MAIN_BUILDING
SE_DLC_APT_Custom_Bedroom *
SE_DLC_APT_Custom_Heist_Room *
SE_DLC_APT_Custom_Living_Room *
SE_DLC_APT_Stilts_A_Bedroom *
SE_DLC_APT_Stilts_A_Heist_Room *
SE_DLC_APT_Stilts_A_Living_Room *
SE_DLC_APT_Stilts_B_Bedroom *
SE_DLC_APT_Stilts_B_Heist_Room *
SE_DLC_APT_Stilts_B_Living_Room *
SE_DLC_APT_Yacht_Bar *
SE_DLC_APT_Yacht_Bedroom *
SE_DLC_APT_Yacht_Bedroom_02 *
SE_DLC_APT_Yacht_Bedroom_03 *
SE_DLC_APT_Yacht_Exterior_01 *
SE_DLC_APT_Yacht_Exterior_02 *
SE_DLC_APT_Yacht_Exterior_03 *
SE_DLC_APT_Yacht_Exterior_04 *
SE_DLC_Biker_Cash_Warehouse_Radio *
SE_DLC_Biker_Crack_Warehouse_Radio *
SE_DLC_Biker_FakeID_Warehouse_Radio *
SE_DLC_Biker_Meth_Warehouse_Radio *
SE_DLC_Biker_Tequilala_Exterior_Emitter
SE_DLC_Biker_Weed_Warehouse_Radio *
SE_DLC_BTL_Yacht_Exterior_01 *
SE_DLC_GR_MOC_Radio_01 *
SE_DLC_SM_Hangar_Radio_Living_Quarters_01 *
SE_DLC_SM_Hangar_Radio_Living_Quarters_02 *
SE_DLC_SM_Hangar_Radio_Mechanic *
SE_DLC_SM_Hangar_Radio_Office_01 *
SE_DLC_SM_Hangar_Radio_Office_02 *
SE_DLC_SM_Hangar_Radio_Office_03 *
SE_DLC_SM_Hangar_Radio_Office_04 *
SE_DMOD_Trailer_Radio
SE_ex_int_office_01a_Radio_01 *
SE_ex_int_office_01b_Radio_01 *
SE_ex_int_office_01c_Radio_01 *
SE_ex_int_office_02a_Radio_01 *
SE_ex_int_office_02b_Radio_01 *
SE_ex_int_office_02c_Radio_01 *
SE_ex_int_office_03a_Radio_01 *
SE_ex_int_office_03b_Radio_01 *
SE_ex_int_office_03c_Radio_01 *
SE_EXEC_WH_L_RADIO *
SE_EXEC_WH_M_RADIO *
SE_EXEC_WH_S_RADIO *
SE_FAMILY_2_BOAT_RADIO
SE_FRANKLIN_AUNT_HOUSE_RADIO_01
SE_FRANKLIN_HILLS_HOUSE_RADIO_01
SE_LOS_SANTOS_EPSILONISM_BUILDING_01
SE_LR_Car_Park_Radio_01
SE_LS_DOCKS_RADIO_01
SE_LS_DOCKS_RADIO_02
SE_LS_DOCKS_RADIO_03
SE_LS_DOCKS_RADIO_04
SE_LS_DOCKS_RADIO_05
SE_LS_DOCKS_RADIO_06
SE_LS_DOCKS_RADIO_07
SE_LS_DOCKS_RADIO_08
SE_MICHAELS_HOUSE_RADIO
SE_MP_AP_RAD_v_apart_midspaz_lounge
SE_MP_AP_RAD_v_studio_lo_living
SE_MP_APT_1_1
SE_MP_APT_1_2
SE_MP_APT_1_3
SE_MP_APT_10_1
SE_MP_APT_10_2
SE_MP_APT_10_3
SE_MP_APT_11_1
SE_MP_APT_11_2
SE_MP_APT_11_3
SE_MP_APT_12_1
SE_MP_APT_12_2
SE_MP_APT_12_3
SE_MP_APT_13_1
SE_MP_APT_13_2
SE_MP_APT_13_3
SE_MP_APT_14_1
SE_MP_APT_14_2
SE_MP_APT_14_3
SE_MP_APT_15_1
SE_MP_APT_15_2
SE_MP_APT_15_3
SE_MP_APT_16_1
SE_MP_APT_16_2
SE_MP_APT_16_3
SE_MP_APT_17_1
SE_MP_APT_17_2
SE_MP_APT_17_3
SE_MP_APT_2_1
SE_MP_APT_2_2
SE_MP_APT_2_3
SE_MP_APT_3_1
SE_MP_APT_3_2
SE_MP_APT_3_3
SE_MP_APT_4_1
SE_MP_APT_4_2
SE_MP_APT_4_3
SE_MP_APT_5_1
SE_MP_APT_5_2
SE_MP_APT_5_3
SE_MP_APT_6_1
SE_MP_APT_6_2
SE_MP_APT_6_3
SE_MP_APT_7_1
SE_MP_APT_7_2
SE_MP_APT_7_3
SE_MP_APT_8_1
SE_MP_APT_8_2
SE_MP_APT_8_3
SE_MP_APT_9_1
SE_MP_APT_9_2
SE_MP_APT_9_3
SE_MP_APT_NEW_1_1
SE_MP_APT_NEW_1_2
SE_MP_APT_NEW_1_3
SE_MP_APT_NEW_2_1
SE_MP_APT_NEW_2_2
SE_MP_APT_NEW_2_3
SE_MP_APT_NEW_3_1
SE_MP_APT_NEW_3_2
SE_MP_APT_NEW_3_3
SE_MP_APT_NEW_4_1
SE_MP_APT_NEW_4_2
SE_MP_APT_NEW_4_3
SE_MP_APT_NEW_5_1
SE_MP_APT_NEW_5_2
SE_MP_APT_NEW_5_3
SE_MP_GARAGE_L_RADIO
SE_MP_GARAGE_M_RADIO
SE_MP_GARAGE_S_RADIO
SE_RESTAURANTS_SUNSET_13
SE_Script_Placed_Prop_Emitter_Boombox *
SE_TREVOR_TRAILER_RADIO_01
se_xm_int_01_avngr_radio
se_xm_int_02_bedroom_radio *
se_xm_int_02_lounge_radio *
se_xm_x17dlc_int_sub_stream
TREVOR_APARTMENT_RADIO
TREVOR1_TRAILER_PARK_MAIN_STAGE_RADIO
TREVOR1_TRAILER_PARK_MAIN_TRAILER_RADIO_01
TREVOR1_TRAILER_PARK_MAIN_TRAILER_RADIO_02
TREVOR1_TRAILER_PARK_MAIN_TRAILER_RADIO_03

I suspect they aren’t case sensitive, but haven’t checked. The ones with asterisks may be called by the 0x651D3228960D08AF native.

2 Likes

Thats means i could reuse an emitter, create a radio with my own songs, put it where I want it to be and set it on said created radio, well i mean, I guess it’s doable ?

Yes, that is correct. I’m not sure if you can stream custom music from your server. Personally, I made an internet radio resource that uses an invisible NUI element to stream music from a URL.

OoOooh
True I havent thought about that

Thanks for that I’m gonna do the same

How do I make this a resource for my server? And I might be stupid but whats the script resource name in openiv for this?

It’s just a client side resource using the natives I listed above.

I really want to add a radio to a few areas in game. Could someone help me with this?

This is exactly what I’ve been trying to do for my server. Add radio’s to certain locations like apartments. Has anyone had any luck?

1 Like

how to run it for everyone in the server who visits the place where the boombox is created ?

1 Like

what part of this shows what station to play. was thinking about changing the prop name to something that is rare enough that it would not show up in the world. maybe the alien egg that I see in codewalker.

The GetRadioStationName native selects the radio station.

ok thanks i see it 1 = a station , now to look for a list

should be able to make a script pretty fast out of your section pretty fast.

ya using this could be a better prop to use prop_alien_egg_01 but looks like still have to make a new emitter. I’ll figure it out. thanks for the help so far, I’m supprised there has not been a release for that ( yes yes I know its ‘simple’) but how many doorlock scripts do we really need hahaha or reskin’d thew huds.

1 Like

I did some research on it at some point and had a list but it’s long gone. I’d just make a loop like 1-100 and print out the values in the console and see what’s what. If I remember, the names were pretty intuitive. There are normal car radio station names, as well as store and shop location radios (like the strip clubs, ammunation, etc).

1 Like