Jump to content

[HELP] realsounds effects


dorken

Recommended Posts

hi mta community just i have a mta realsounds effects like play in city or something anyway 
i want if you go to this pos the sound stop and play another sound 
this script i do and i need  the stop (city.mp3) and plays (tenger.mp3)
sry is bad english just if you dont (understand) im sorry 

local sounds = {}

addEventHandler("onClientResourceStart", getRootElement(),
	function()
		local newValue = getElementData(localPlayer, "loggedIn")
		if newValue == true then
			sounds[1] = playSound3D("files/tenger.mp3", 1382.8380126953, 479.56735229492, 20.468042373657, true) -- tenger
			setSoundMaxDistance(sounds[1], 50)

			sounds[2] = playSound3D("files/city.mp3", 1362.4620361328, -22.705436706543, 95.041290283203, true)
			setSoundMaxDistance(sounds[2], 5000)
		end
	end
)

local sound = {}


function startSound()
	for i, v in ipairs(sounds) do
		sound[i] = playSound3D(sounds[i][4], sounds[i][1], sounds[i][2], sounds[i][3], true)
		setSoundMaxDistance(sound[i], 2000)
		setSoundVolume(sound[i], 1)
	end
end
addEventHandler("onClientResourceStart", getResourceRootElement(), startSound)

 

Note: just in the future will add more sounds

Link to comment
5 hours ago, dorken said:

hi mta community just i have a mta realsounds effects like play in city or something anyway 
i want if you go to this pos the sound stop and play another sound 
this script i do and i need if you go to (tenger.mp3) pos the (city.mp3) stop and plays  (tenger.mp3)
sry is bad english just if you dont (understand) im sorry 

local sounds = {}

addEventHandler("onClientResourceStart", getRootElement(),
	function()
		local newValue = getElementData(localPlayer, "loggedIn")
		if newValue == true then
			sounds[1] = playSound3D("files/tenger.mp3", 1382.8380126953, 479.56735229492, 20.468042373657, true) -- tenger
			setSoundMaxDistance(sounds[1], 50)

			sounds[2] = playSound3D("files/city.mp3", 1362.4620361328, -22.705436706543, 95.041290283203, true)
			setSoundMaxDistance(sounds[2], 5000)
		end
	end
)

local sound = {}


function startSound()
	for i, v in ipairs(sounds) do
		sound[i] = playSound3D(sounds[i][4], sounds[i][1], sounds[i][2], sounds[i][3], true)
		setSoundMaxDistance(sound[i], 2000)
		setSoundVolume(sound[i], 1)
	end
end
addEventHandler("onClientResourceStart", getResourceRootElement(), startSound)

 

Note: just in the future will add more sounds

 

Edited by dorken
Link to comment
local sounds = {}

addEventHandler("onClientResourceStart", getRootElement(),
    function()
        local isLoggedIn = getElementData(localPlayer, "loggedIn")
        if isLoggedIn then
            sounds[1] = {
                file = "files/tenger.mp3",
                x = 1382.8380126953, y = 479.56735229492, z = 20.468042373657,
                maxDistance = 50
            }
            sounds[2] = {
                file = "files/city.mp3",
                x = 1362.4620361328, y = -22.705436706543, z = 95.041290283203,
                maxDistance = 5000
            }

            for _, soundData in ipairs(sounds) do
                local soundElement = playSound3D(soundData.file, soundData.x, soundData.y, soundData.z, true)
                setSoundMaxDistance(soundElement, soundData.maxDistance)
                setSoundVolume(soundElement, 1)
            end
        end
    end
)

Try this

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...