SixL client API / game/audio / GameAudioMp

Interface: GameAudioMp

Audio: scenes, scripted conversations, speech, radio stations and slow motion audio.

Remarks

Every getter returns a Promise. Names passed as strings are hashed (see GameNameOrHash).

Methods

activateSlowmoMode()

activateSlowmoMode(mode): void

Switches on a slow motion audio mode (the sound is slowed down with the game's slow motion).

Parameters

mode

GameNameOrHash

The mode's name, or its hash.

Returns

void

Example

mp.game.audio.activateSlowmoMode('slowmo_mode');

addPedToConversation()

addPedToConversation(index, ped, p2): void

Adds a ped to the conversation that the scripted conversation plays.

Parameters

index

number

The conversation's index (an integer).

ped

GameEntity

The ped to add.

p2

GameNameOrHash

A name or hash of the conversation's voice set.

Returns

void

Remarks

The third argument is a name or hash here; RAGE MP passes a string.

Example

mp.game.audio.addPedToConversation(0, ped.handle, 'speech_set');

deactivateSlowmoMode()

deactivateSlowmoMode(mode): void

Switches off a slow motion audio mode.

Parameters

mode

GameNameOrHash

The mode's name, or its hash.

Returns

void

Example

mp.game.audio.deactivateSlowmoMode('slowmo_mode');

doesPlayerVehHaveRadio()

doesPlayerVehHaveRadio(): Promise<boolean>

Tells whether the player's vehicle has a radio.

Returns

Promise<boolean>

A Promise of true when the vehicle has a radio.

Example

const hasRadio = await mp.game.audio.doesPlayerVehHaveRadio();

enableStallWarningSounds()

enableStallWarningSounds(vehicle, toggle): void

Switches the stall warning sound of a vehicle on or off.

Parameters

vehicle

GameEntity

The vehicle.

toggle

boolean

true to enable the warning sound, false to disable it.

Returns

void

Example

mp.game.audio.enableStallWarningSounds(vehicle.handle, false);

getMusicPlaytime()

getMusicPlaytime(): Promise<number>

The playtime of the current music track.

Returns

Promise<number>

A Promise of the playtime in the game's own unit (the unit is not verified).

Example

const playtime = await mp.game.audio.getMusicPlaytime();

getNumUnlockedRadioStations()

getNumUnlockedRadioStations(): Promise<number>

The number of radio stations the player has unlocked.

Returns

Promise<number>

A Promise of the count (an integer).

Example

const count = await mp.game.audio.getNumUnlockedRadioStations();

getPlayerRadioStationGenre()

getPlayerRadioStationGenre(): Promise<number>

The genre of the radio station the player is listening to.

Returns

Promise<number>

A Promise of the genre (an integer, the game's own value).

Example

const genre = await mp.game.audio.getPlayerRadioStationGenre();

getPlayerRadioStationIndex()

getPlayerRadioStationIndex(): Promise<number>

The index of the radio station the player is listening to.

Returns

Promise<number>

A Promise of the station index (an integer).

Example

const station = await mp.game.audio.getPlayerRadioStationIndex();

getRadioStationName()

getRadioStationName(radioStation): Promise<number>

The name of a radio station, by its index.

Parameters

radioStation

number

The station's index (an integer).

Returns

Promise<number>

A Promise of the value the game gives for the station; it is a number here, not the text RAGE MP returns.

Remarks

Differs from RAGE MP: the result is the game's own number, not a label string.

Example

const name = await mp.game.audio.getRadioStationName(0);

getSoundId()

getSoundId(): Promise<number>

Takes a free sound id, the handle a sound is played and stopped by. Release it with GameAudioMp.releaseSoundId when done.

Returns

Promise<number>

A Promise of the sound id as an integer.

Example

const soundId = await mp.game.audio.getSoundId();

isAmbientSpeechPlaying()

isAmbientSpeechPlaying(ped): Promise<boolean>

Tells whether the ped is playing ambient speech (idle chatter).

Parameters

ped

GameEntity

The ped.

Returns

Promise<boolean>

A Promise of true while the ped speaks.

Example

const talking = await mp.game.audio.isAmbientSpeechPlaying(ped.handle);

isAnySpeechPlaying()

isAnySpeechPlaying(ped): Promise<boolean>

Tells whether the ped is playing any speech, ambient or scripted.

Parameters

ped

GameEntity

The ped.

Returns

Promise<boolean>

A Promise of true while the ped speaks.

Example

const talking = await mp.game.audio.isAnySpeechPlaying(ped.handle);

isAudioSceneActive()

isAudioSceneActive(scene): Promise<boolean>

Tells whether an audio scene is playing.

Parameters

scene

GameNameOrHash

The scene's name, or its hash.

Returns

Promise<boolean>

A Promise of true while the scene is active.

Example

const active = await mp.game.audio.isAudioSceneActive('main_scene');

isPedInCurrentConversation()

isPedInCurrentConversation(ped): Promise<boolean>

Tells whether the ped takes part in the conversation that is playing.

Parameters

ped

GameEntity

The ped.

Returns

Promise<boolean>

A Promise of true when the ped is in the current conversation.

Example

const inIt = await mp.game.audio.isPedInCurrentConversation(ped.handle);

isRadioRetuning()

isRadioRetuning(): Promise<boolean>

Tells whether the radio is tuning to another station right now.

Returns

Promise<boolean>

A Promise of true while the radio retunes.

Example

const retuning = await mp.game.audio.isRadioRetuning();

isSceneActive()

isSceneActive(scene): Promise<boolean>

The same as GameAudioMp.isAudioSceneActive.

Parameters

scene

GameNameOrHash

The scene's name, or its hash.

Returns

Promise<boolean>

A Promise of true while the scene is active.

Example

const active = await mp.game.audio.isSceneActive('main_scene');

isScriptedConversationLoaded()

isScriptedConversationLoaded(): Promise<boolean>

Tells whether the scripted conversation has loaded.

Returns

Promise<boolean>

A Promise of true once the conversation is loaded.

Example

const loaded = await mp.game.audio.isScriptedConversationLoaded();

isScriptedSpeechPlaying()

isScriptedSpeechPlaying(p0): Promise<boolean>

Tells whether the entity is playing scripted speech.

Parameters

p0

GameEntity

The ped.

Returns

Promise<boolean>

A Promise of true while the scripted speech plays.

Example

const talking = await mp.game.audio.isScriptedSpeechPlaying(ped.handle);

pauseScriptedConversation()

pauseScriptedConversation(p0): void

Pauses or resumes the scripted conversation.

Parameters

p0

boolean

true to pause, false to resume.

Returns

void

Example

mp.game.audio.pauseScriptedConversation(true);

releaseSoundId()

releaseSoundId(soundId): void

Releases a sound id taken with GameAudioMp.getSoundId, so that it can be used again.

Parameters

soundId

number

The sound id, an integer from getSoundId.

Returns

void

Example

mp.game.audio.releaseSoundId(soundId);

setAmbientZoneState()

setAmbientZoneState(zoneName, p1, p2): void

Sets the state of an ambient audio zone (a zone where the game plays ambient sound).

Parameters

zoneName

GameNameOrHash

The zone's name, or its hash.

p1

boolean

The first flag, as the game defines it.

p2

boolean

The second flag, as the game defines it.

Returns

void

Remarks

The flags are not explained beyond their type; the zone name is a hash here.

Example

mp.game.audio.setAmbientZoneState('zone_name', true, false);

setAudioFlag()

setAudioFlag(flagName, toggle): void

Sets an audio flag on or off. The flag is named by a string, hashed here as the game hashes names.

Parameters

flagName

string

The flag's name.

toggle

boolean

true to set the flag, false to clear it.

Returns

void

Example

mp.game.audio.setAudioFlag('disable_flight_music', true);

setFlag()

setFlag(flagName, toggle): void

The same as GameAudioMp.setAudioFlag.

Parameters

flagName

string

The flag's name.

toggle

boolean

true to set the flag, false to clear it.

Returns

void

Example

mp.game.audio.setFlag('disable_flight_music', false);

setHornEnabled()

setHornEnabled(vehicle, toggle): void

Enables or disables the vehicle's horn.

Parameters

vehicle

GameEntity

The vehicle.

toggle

boolean

true to enable the horn, false to disable it.

Returns

void

Example

mp.game.audio.setHornEnabled(vehicle.handle, false);

setRadioToStationIndex()

setRadioToStationIndex(radioStation): void

Tunes the radio to a station by its index in the game's station list.

Parameters

radioStation

number

The station's index, an integer.

Returns

void

Example

mp.game.audio.setRadioToStationIndex(3);

setRadioToStationName()

setRadioToStationName(stationName): void

Tunes the radio to a station by its name. The name is hashed.

Parameters

stationName

string

The station's name, as the game names it.

Returns

void

Example

mp.game.audio.setRadioToStationName('radio_01_pop');

setSirenWithNoDriver()

setSirenWithNoDriver(vehicle, toggle): void

Switches the siren of a vehicle on or off while nobody drives it.

Parameters

vehicle

GameEntity

The vehicle.

toggle

boolean

true to allow the siren without a driver, false to stop it.

Returns

void

Example

mp.game.audio.setSirenWithNoDriver(vehicle.handle, true);

setUserRadioControlEnabled()

setUserRadioControlEnabled(toggle): void

Allows or forbids the player to change the radio station with the controls.

Parameters

toggle

boolean

true to allow the player to change the station, false to forbid it.

Returns

void

Example

mp.game.audio.setUserRadioControlEnabled(false);

skipRadioForward()

skipRadioForward(): void

Skips the radio to the next station, forward.

Returns

void

Example

mp.game.audio.skipRadioForward();

skipToNextScriptedConversationLine()

skipToNextScriptedConversationLine(): void

Skips the scripted conversation to its next line.

Returns

void

Example

mp.game.audio.skipToNextScriptedConversationLine();

stopCurrentPlayingSpeech()

stopCurrentPlayingSpeech(ped): void

Stops the speech that the ped is playing now.

Parameters

ped

GameEntity

The ped.

Returns

void

Example

mp.game.audio.stopCurrentPlayingSpeech(ped.handle);

stopScriptedConversation()

stopScriptedConversation(p0): Promise<number>

Stops the scripted conversation.

Parameters

p0

boolean

Whether to stop it now (true) or not (false).

Returns

Promise<number>

A Promise of the game's result code (an integer); its meaning is not documented by the game.

Example

await mp.game.audio.stopScriptedConversation(true);

stopSound()

stopSound(soundId): void

Stops a sound that was started under a sound id.

Parameters

soundId

number

The sound id, an integer from getSoundId.

Returns

void

Example

mp.game.audio.stopSound(soundId);

unlockMissionNewsStory()

unlockMissionNewsStory(newsStory): void

Unlocks a news story of the mission.

Parameters

newsStory

number

The news story's index (an integer).

Returns

void

Example

mp.game.audio.unlockMissionNewsStory(1);