PlayMissionAudio

From Multi Theft Auto: Wiki
Dialog-warning.png Function has been disabled.

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

This function plays a game sound in a specific slot. Be sure to preload your sound with PreloadMissionAudio into the slot beforehand. An optional position element can be specified.

Usage

Both server side and client side. "thePlayer" argument isn't used in the client side version of this function.

Syntax

Click to collapse [-]
Server
bool playMissionAudio ( player thePlayer, int slot, float x, float y, float z )

Required Arguments

  • thePlayer: the player you want to play the sound for.
  • slot: int sound slot in which you preloaded the sound
  • x: float position's x coordinate
  • y: float position's y coordinate
  • z: float position's z coordinate
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 )
    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