PlaySoundFrontEnd: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(fixed command handler -> event handler. fixed player -> source. added comments)
mNo edit summary
 
(46 intermediate revisions by 23 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Server client function}}
This function plays a sound for the specified player
__NOTOC__
This function plays a frontend sound for the specified player.
{{Note|These sounds can be disabled with [[setWorldSoundEnabled]] so if these sounds stop working you should check if you're disabling the sounds.}}
{{Note|These sounds don't work when [[fadeCamera]] has been used to make the screen black.}}


==Syntax==  
==Syntax==  
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool playSound ( player player, int sound )   
bool playSoundFrontEnd ( player thePlayer, int sound )   
</syntaxhighlight>  
</syntaxhighlight>
{{New feature/item|3.0141|1.4.0|6987|{{OOP||[[player]]:playSoundFrontEnd}}}}


===Required Arguments===  
===Required Arguments===  
*'''player:''' The player you want the sound to play for.
*'''thePlayer:''' the [[player]] you want the sound to play for.
*'''sound:''' A whole integer specifying the sound id to play. Valid values are:
*'''sound:''' a whole [[int]] specifying the sound id to play. Valid values are:
{{Sounds}}
{{Sounds}}
</section>
<section name="Client" class="client" show="false">
<syntaxhighlight lang="lua">
bool playSoundFrontEnd ( int sound ) 
</syntaxhighlight>
{{New feature/item|3.0141|1.4.0|6987|{{OOP||[[Sound]].playFrontEnd}}}}
===Required Arguments===
*'''sound:''' a whole [[int]] specifying the sound id to play. Valid values are:
{{Sounds}}
</section>


===Returns===
===Returns===
Returns ''true'' if the sound was successfully played , ''false'' otherwise.
Returns ''true'' if the sound was successfully played, ''false'' otherwise.


==Example==
==Example==
This example plays a sound when a player spawns
<section name="server" class="server" show="true">
<syntaxhighlight lang="lua">addEventHandler ( "onPlayerSpawn", getElementRoot(), "onPlayerSpawn" ) --add an event for onPlayerSpawn
This example plays a sound when a player spawns.
function onPlayerSpawn ( spawnpoint, team ) --when a player spawns
<syntaxhighlight lang="lua">
  playSound ( source, 16 ) --play a sound for him
function onPlayerSpawn ( theSpawnpoint, theTeam )
end</syntaxhighlight>
    playSoundFrontEnd ( source, 16 )
end
addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn )
</syntaxhighlight>
</section>
<section name="client" class="client" show="true">
This example plays a sound when the player types the command '/sound'.
<syntaxhighlight lang="lua">
function onSoundEvent ( )
    playSoundFrontEnd ( 16 )
end
addCommandHandler("sound", onSoundEvent)
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Audio_functions}}
{{Client_audio_functions}}
 
[[hu:playSoundFrontEnd]]
[[de:playSoundFrontEnd]]
[[ar:playSoundFrontEnd]]
[[pt-br:playSoundFrontEnd]]

Latest revision as of 22:58, 18 August 2021

This function plays a frontend sound for the specified player.

[[{{{image}}}|link=|]] Note: These sounds can be disabled with setWorldSoundEnabled so if these sounds stop working you should check if you're disabling the sounds.
[[{{{image}}}|link=|]] Note: These sounds don't work when fadeCamera has been used to make the screen black.

Syntax

Click to collapse [-]
Server
bool playSoundFrontEnd ( player thePlayer, int sound )   

OOP Syntax Help! I don't understand this!

Method: player:playSoundFrontEnd(...)

Required Arguments

  • thePlayer: the player you want the sound to play for.
  • sound: a whole int specifying the sound id to play. Valid values are:
    • 0 - 20 Selection sounds
    • 27 - 30 Bullet sounds
    • 32 - 33 Selection sounds
    • 34 Radio static
    • 35 Stop Radio static
    • 37 - 38 Tick
    • 40 Selection sounds
    • 41 - 42 Tick (no ammo)
    • 43 - 45 Race countdown
    • 46 Repair
    • 47 White noise static
    • 48 Stop White noise static
    • 49 Static short
    • 101 Countdown/selection
Click to expand [+]
Client

Returns

Returns true if the sound was successfully played, false otherwise.

Example

Click to collapse [-]
server

This example plays a sound when a player spawns.

function onPlayerSpawn ( theSpawnpoint, theTeam )
    playSoundFrontEnd ( source, 16 )
end
addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn )
Click to collapse [-]
client

This example plays a sound when the player types the command '/sound'.

function onSoundEvent ( )
    playSoundFrontEnd ( 16 )
end
addCommandHandler("sound", onSoundEvent)

See Also