PreloadMissionAudio: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Replaced template Needs Checking with Disabled)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Disabled|Its functionality left for a post-r1 release|1838}}
{{Server client function}}
__NOTOC__
This function preloads a game sound into a specific sound slot. The sound can then be played with [[PlayMissionAudio]].
This function preloads a game sound into a specific sound slot. The sound can then be played with [[PlayMissionAudio]].
==Usage==
Both server-side and client-side. "thePlayer" argument isn't used in client-side version of this function.


==Syntax==  
==Syntax==  
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool preloadMissionAudio ( player thePlayer, int sound, int slot )   
bool preloadMissionAudio ( player thePlayer, int sound, int slot )   
Line 11: Line 11:


===Required Arguments===  
===Required Arguments===  
*'''thePlayer''': the [[player]] you want to play the sound for.
*'''thePlayer:''' the [[player]] you want to play the sound for.
*'''sound''': the [[int]] sound id to play (interpreted as unsigned short). Valid values are those from the '''data/AudioEvents.txt''' file.
*'''sound:''' the [[int]] sound id to play (interpreted as unsigned short). Valid values are those from the '''data/AudioEvents.txt''' file.
*'''slot''': [[int]] sound slot in which you preloaded the sound.
*'''slot:''' [[int]] sound slot in which you preloaded the sound.
</section>
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
bool preloadMissionAudio ( int sound, int slot ) 
</syntaxhighlight>
 
===Required Arguments===
*'''sound:''' the [[int]] sound id to play (interpreted as unsigned short). Valid values are those from the '''data/AudioEvents.txt''' file.
*'''slot:''' [[int]] sound slot in which you preloaded the sound.
</section>


===Returns===
===Returns===
Line 19: Line 29:


==Example==   
==Example==   
See [[PlayMissionAudio]].
<section name="server" class="server" show="true">
This example plays a sound when a player spawns
<syntaxhighlight lang="lua">
function onPlayerSpawn ( theSpawnpoint, theTeam )
    preloadMissionAudio ( source, 5000, 1 )
    local x, y, z = getElementPosition ( source )
    playMissionAudio ( source, 1, x, y, z )
end
addEventHandler ( "onPlayerSpawn", getElementRoot(), onPlayerSpawn )
</syntaxhighlight>
</section>
<section name="client" class="client" show="true">
This example plays a sound when the server triggers the onSoundEvent client event.
<syntaxhighlight lang="lua">
function onSoundEvent ( )
    preloadMissionAudio ( source, 5000, 1 )
    local x, y, z = getElementPosition ( source )
    playMissionAudio ( 1, x, y, z )
end
addEvent ( "onSoundEvent" )
addEventHandler ( "onSoundEvent", getElementRoot(), onSoundEvent )
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Audio_functions}}
{{Audio_functions}}

Latest revision as of 12:07, 16 November 2011

Dialog-warning.png Function has been disabled.

Reason/Note: Its functionality left for a post-r1 release - Bugtracker Issue: #1838

This function preloads a game sound into a specific sound slot. The sound can then be played with PlayMissionAudio.

Syntax

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

Required Arguments

  • thePlayer: the player you want to play the sound for.
  • sound: the int sound id to play (interpreted as unsigned short). Valid values are those from the data/AudioEvents.txt file.
  • slot: int sound slot in which you preloaded the sound.
Click to collapse [-]
Client
bool preloadMissionAudio ( int sound, int slot )   

Required Arguments

  • sound: the int sound id to play (interpreted as unsigned short). Valid values are those from the data/AudioEvents.txt file.
  • slot: int sound slot in which you preloaded the sound.

Returns

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

Example

Click to collapse [-]
server

This example plays a sound when a player spawns

function onPlayerSpawn ( theSpawnpoint, theTeam )
    preloadMissionAudio ( source, 5000, 1 )
    local x, y, z = getElementPosition ( source )
    playMissionAudio ( source, 1, x, y, z )
end
addEventHandler ( "onPlayerSpawn", getElementRoot(), onPlayerSpawn )
Click to collapse [-]
client

This example plays a sound when the server triggers the onSoundEvent client event.

function onSoundEvent ( )
    preloadMissionAudio ( source, 5000, 1 )
    local x, y, z = getElementPosition ( source )
    playMissionAudio ( 1, x, y, z )
end
addEvent ( "onSoundEvent" )
addEventHandler ( "onSoundEvent", getElementRoot(), onSoundEvent )

See Also