Skip to content

Vehicle audio settings #2350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

TheNormalnij
Copy link
Member

@TheNormalnij TheNormalnij commented Sep 12, 2021

Hi, everybody. It's a old feature, that provide vehicle audio settings interface.

-- All functions are clinet-side
setVehicleModelAudioSetting( number modelID, eVehicleSoundSetting parameter, var value ) 
getVehicleModelAudioSettings( number modelID )
resetVehicleModelAudioSettings( number modelID )

setVehicleAudioSetting( vehicle theVehicle, eVehicleSoundSetting parameter, var value ) 
getVehicleAudioSettings( vehicle theVehicle )
resetVehicleAudioSettings( vehicle theVehicle )

Possible parameters:

  • door-sound
  • engine-off-soundbank-id
  • engine-on-soundbank-id
  • horn-high (float)
  • horn-ton
  • horn-volume-delta (float)
  • radion-num
  • radio-type
  • sound-type
  • bass-setting
  • engine-upgrade
  • bass-eq
  • filed-c // unknown
  • vehicle-type-for-audio

I didn't check this code last time. Maybe it can cause crash with wrong *-soundbank-id parameters

@StrixG StrixG added the enhancement New feature or request label Sep 12, 2021
@Inder00
Copy link
Contributor

Inder00 commented Sep 12, 2021

What about RC Rider or RC Plane sound ?

@Allerek
Copy link
Contributor

Allerek commented Sep 14, 2021

What about RC Rider or RC Plane sound ?

They're just vehicles like infernus, dodo, jetmax etc, there should not be a problem with those.

@Haxardous Haxardous mentioned this pull request Oct 8, 2022
1 task
@patrikjuvonen patrikjuvonen added the feedback Further information is requested label Apr 8, 2023
@patrikjuvonen patrikjuvonen marked this pull request as draft April 8, 2023 11:42
@patrikjuvonen
Copy link
Contributor

Merge conflicts must be resolved.

@patrikjuvonen patrikjuvonen added this to the Next Release (1.6.1) milestone Apr 8, 2023
@github-actions github-actions bot added the stale Inactive for over 90 days, to be closed label Jul 8, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2023

This draft pull request is stale because it has been open for at least 90 days with no activity. Please continue on your draft pull request or it will be closed in 30 days automatically.

@TheNormalnij TheNormalnij marked this pull request as ready for review July 14, 2023 19:58
@TheNormalnij TheNormalnij removed the stale Inactive for over 90 days, to be closed label Jul 14, 2023
@TheNormalnij
Copy link
Member Author

Merge conflicts solved

@Fernando-A-Rocha
Copy link
Contributor

Fernando-A-Rocha commented Dec 18, 2023

Nice feature. I think this should be added. Radio sync (#2781) is a different feature that can be added later.

@Dutchman101
Copy link
Member

@TheNormalnij Please resolve conflicts and see if there's anything you would have done differently if you'd make this feature in 2024

@Fernando-A-Rocha
Copy link
Contributor

Will it work with allocated model IDs (engineRequestModel) ?

@Fernando-A-Rocha
Copy link
Contributor

Bump?

@TheNormalnij
Copy link
Member Author

Will it work with allocated model IDs (engineRequestModel) ?

yes

@lynconsix
Copy link

Is it still in progress?

@Fernando-A-Rocha
Copy link
Contributor

It would be nice to have this new feature, does it need testing?

@lynconsix
Copy link

It seems that there is still some script left to work, that's what I think

@tederis
Copy link
Member

tederis commented Jan 10, 2025

I'd love to see it merged. @TheNormalnij please, resolve the conflicts.

@Fernando-A-Rocha
Copy link
Contributor

Works with engine request model ids?

@TheNormalnij
Copy link
Member Author

Works with engine request model ids?

setVehicleAudioSetting and getVehicleAudioSetting should work with aloocated models.

@Dutchman101
Copy link
Member

Thank you for all the work on this, it will be nice to present for MTA 1.6.1
Please add it to wiki, @TheNormalnij

@Dutchman101 Dutchman101 merged commit 53ee579 into multitheftauto:master Apr 10, 2025
6 checks passed
MTABot pushed a commit that referenced this pull request Apr 10, 2025
@Fernando-A-Rocha
Copy link
Contributor

Nice that this got added

@Dutchman101
Copy link
Member

Nice that this got added

yes, it's huge for MTA

@Dutchman101
Copy link
Member

Also, i didnt see TheNormalnij active so much in recent weeks, it would be better if someone else adds documentation to wiki? Anyone interested?

@Xenius97
Copy link
Contributor

Xenius97 commented Apr 11, 2025

Works well for me, here is a small snippet if anyone wants to test it:

local replaceDefaultSoundsEnabled = (type(setVehicleModelAudioSetting) == "function" and true or false)
local customParameters = {
	[478] = getVehicleModelAudioSettings(411) -- # walton <> infernus
}

local possibleValues = {
	["sound-type"] = true, ["engine-on-soundbank-id"] = true, ["engine-off-soundbank-id"] = true, ["bass-setting"] = true, ["bass-eq"] = true, ["field-c"] = true,
	["horn-ton"] = true, ["horn-high"] = true, ["engine-upgrade"] = true, ["door-sound"] = true, ["vehicle-type-for-audio"] = true, ["horn-volume-delta"] = true
}

addEventHandler("onClientResourceStart", resourceRoot, function()
	if not replaceDefaultSoundsEnabled then
		return
	end

	for modelId, values in pairs(customParameters) do
		for key, value in pairs(values) do
			if possibleValues[key] then
				setVehicleModelAudioSetting(modelId, key, value)
			end
		end
	end

	-- # fix streaming after resource start [instantly change sound of vehicle, otherwise you need to use engineRestreamWorld()]
	for _, vehicle in ipairs(getElementsByType("vehicle", root, true)) do
		local model = getElementModel(vehicle)
		if customParameters[model] then
			local values = customParameters[model]
			for key, value in pairs(values) do
				if possibleValues[key] then
					setVehicleAudioSetting(vehicle, key, value)
				end
			end
		end
	end
end)

addEventHandler("onClientResourceStop", resourceRoot, function()
	if not replaceDefaultSoundsEnabled then
		return
	end
	
	for modelId in pairs(customParameters) do
		resetVehicleModelAudioSettings(modelId)
	end
end)

@PlatinMTA
Copy link
Contributor

You broke custom vehicles default sounds, I will open an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feedback Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.