Jump to content

[HELP] setBrowserVolume


Recommended Posts

Hi! I'm working on a cinema script, everything fine, but i don't know how to calculate the volume by distance. Anybody can help me please?

 

                    local cinemax, cinemay, cinemaz =  0, 0, 0
                    local x, y, z = getElementPosition(localPlayer)
                    local dis = getDistanceBetweenPoints3D(x, y, z, cinemax, cinemay, cinemaz)
                    
                    local volume = dis/2 -- Idk what to use                    
                    setBrowserVolume(Screen,volume)

 

Link to comment

Try something like this:

	local maxDist = 500

	local cinemax, cinemay, cinemaz =  0, 0, 0
	local x, y, z = getElementPosition(localPlayer)
	local dis = getDistanceBetweenPoints3D(x, y, z, cinemax, cinemay, cinemaz)
      
	local volume = ( dis / maxDist )
	volume = dis >= maxDist and 1 or volume
	
	setBrowserVolume( Screen, 1-volume )

 

Edited by DNL291
  • Thanks 1
Link to comment
11 hours ago, DNL291 said:

Try something like this:


	local maxDist = 500

	local cinemax, cinemay, cinemaz =  0, 0, 0
	local x, y, z = getElementPosition(localPlayer)
	local dis = getDistanceBetweenPoints3D(x, y, z, cinemax, cinemay, cinemaz)
      
	local volume = ( dis / maxDist )
	volume = dis >= maxDist and 1 or volume
	
	setBrowserVolume( Screen, 1-volume )

 

Thank you!

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...