Skip to content

Vehicle audio settings - #2350

Merged
Dutchman101 merged 21 commits into
multitheftauto:masterfrom
TheNormalnij:TheNormalnij/audio_settings
Apr 10, 2025
Merged

Dutchman101 merged 21 commits into
multitheftauto:masterfrom
TheNormalnij:TheNormalnij/audio_settings

Conversation

@TheNormalnij

@TheNormalnij TheNormalnij commented Sep 12, 2021 •

Copy link
Copy Markdown
Contributor

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

Inder00 commented Sep 12, 2021

Copy link
Copy Markdown
Contributor

What about RC Rider or RC Plane sound ?

@Allerek

Allerek commented Sep 14, 2021

Copy link
Copy Markdown
Contributor

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 done
@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
Copy Markdown
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

github-actions Bot commented Jul 8, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

Merge conflicts solved

@Fernando-A-Rocha

Fernando-A-Rocha commented Dec 18, 2023 •

Copy link
Copy Markdown
Contributor

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

@Dutchman101

Copy link
Copy Markdown
Member

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

Comment thread Client/game_sa/CVehicleSA.cpp Outdated
Comment thread Client/game_sa/CVehicleSA.h Outdated
Comment thread Client/game_sa/CVehicleAudioSettingsEntrySA.h Outdated
Comment thread Client/game_sa/CVehicleAudioSettingsManagerSA.h Outdated
@Fernando-A-Rocha

Copy link
Copy Markdown
Contributor

Will it work with allocated model IDs (engineRequestModel) ?

@Fernando-A-Rocha

Copy link
Copy Markdown
Contributor

Bump?

@TheNormalnij

Copy link
Copy Markdown
Contributor Author

Will it work with allocated model IDs (engineRequestModel) ?

yes

@ghost

ghost commented Oct 8, 2024

Copy link
Copy Markdown

Is it still in progress?

@Fernando-A-Rocha

Copy link
Copy Markdown
Contributor

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

@ghost

ghost commented Oct 8, 2024

Copy link
Copy Markdown

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

@tederis

tederis commented Jan 10, 2025

Copy link
Copy Markdown
Member

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

@Fernando-A-Rocha

Copy link
Copy Markdown
Contributor

Works with engine request model ids?

@TheNormalnij

Copy link
Copy Markdown
Contributor Author

Works with engine request model ids?

setVehicleAudioSetting and getVehicleAudioSetting should work with aloocated models.

@Dutchman101

Copy link
Copy Markdown
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
MTABot pushed a commit that referenced this pull request Apr 10, 2025
@Fernando-A-Rocha

Copy link
Copy Markdown
Contributor

Nice that this got added

@Dutchman101

Copy link
Copy Markdown
Member

Nice that this got added

yes, it's huge for MTA

@Dutchman101

Copy link
Copy Markdown
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

Xenius97 commented Apr 11, 2025 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@PlatinMTA PlatinMTA mentioned this pull request Apr 11, 2025
1 task done
@MohabCodeX

Copy link
Copy Markdown
Contributor

Documented. ✅

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.