PreloadMissionAudio

From Multi Theft Auto: Wiki
Revision as of 20:55, 16 November 2007 by Jbeta (talk | contribs) (Added deletion notice)
Jump to navigation Jump to search
Dialog-information.png This article needs checking.

Reason(s): This function has been disabled, its functionality left for a post-r1 release. --jbeta 14:55, 16 November 2007 (CST)

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