SetSoundMaxDistance: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(distance default)
mNo edit summary
 
(5 intermediate revisions by 5 users not shown)
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool setSoundMaxDistance ( element sound, int distance )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool setSoundMaxDistance ( element sound, int distance )</syntaxhighlight>  
 
{{OOP||[[sound]]:setMaxDistance|maxDistance|getSoundMaxDistance}}
===Required Arguments===  
===Required Arguments===  
*'''sound:''' a [[sound]] element.
*'''sound:''' a [[sound]] element.
*'''distance:''' the default value for this is 10
*'''distance:''' the default value for this is 20
===Returns===
===Returns===
Returns a ''true'' if the max distance was set, ''false'' otherwise.
Returns a ''true'' if the max distance was set, ''false'' otherwise.
Line 26: Line 26:
==See Also==
==See Also==
{{Client_audio_functions}}
{{Client_audio_functions}}
[[hu:setSoundMaxDistance]]
[[ar:setSoundMaxDistance]]
[[pt-br:setSoundMaxDistance]]

Latest revision as of 01:59, 19 August 2021

Sets a custom sound max distance at which the sound stops.

Syntax

bool setSoundMaxDistance ( element sound, int distance )

OOP Syntax Help! I don't understand this!

Method: sound:setMaxDistance(...)
Variable: .maxDistance
Counterpart: getSoundMaxDistance


Required Arguments

  • sound: a sound element.
  • distance: the default value for this is 20

Returns

Returns a true if the max distance was set, false otherwise.

Example

Click to collapse [-]
Client
local sound = playSound3D("sounds/song.mp3", 373.14, -125.21, 1001, true)

function maxdistanceFunc(command, param)
  setSoundMaxDistance(sound, tonumber(param))
end
addCommandHandler("setmaxdistance", maxdistanceFunc)

See Also