Description
[color=blue][size=16][b]Information[/b][/size][/color]
This addon allows server owners to add sound managing functionality to a source server, without the need of a separate plug-in such as Mani Admin. It also exposes functions for EventScripts scripters to work with to add sound managing functionality to their script in seconds!
[color=blue][size=14][b]Specifics For Server Owners[/b][/size][/color]
Functionality provided by this system is limited, as it is intended more for scripters to use as a standardised way of creating a sound managing script. However, you will be able to do the following just with this addon:
[list]
[*] [b]Add/Remove sounds via RCON[/b], e.g.: sm_add_sound "mySound" "mySound.mp3"; sm_remove_sound "mySound"
[*] [b]Play/Emit/Stop sounds via RCON[/b], by multiple filters (i.e. by player, by group of player, by all players), e.g.: sm_play_sound "mySound" player 5; sm_stop_sound "mySound" all
[*] [b]Modify global sound properties via RCON[/b], e.g.: sm_global_volume 0.5; sm_global_attenuation 0.2
[*] Of course, as these are RCON commands, you can add them to your autoexec.cfg file to easily set up a list of sounds to use, and to quickly configure the SoundManager.
[/list]
It should be noted that all sounds added using SoundManager will automatically be added to the 'downloads' table upon map start, so you will not have to worry about registering the sound list every map start!
[color=blue][size=14][b]Specifics For EventScripts Scripters[/b][/size][/color]
This script can be used to create your own simple sound manager in seconds! Here's an example script that uses the SoundManager functionality:
[syntax="python"]import es
from soundmanager import *
def load():
soundmanager.addSound("newSound", "myNewSound.mp3")
def unload():
soundmanager.removeSound("newSound")
def round_start(event_var):
soundmanager.getSound("newSound").playSoundToAll()[/syntax]
The recommended functions that you have available are (under the soundmanager module):
[syntax="python"]addSound(soundname, filename, [volume], [attenuation], [length])
# Adds a sound to the soundmanager sounds list, and returns the new Sound object.
# Can give a custom volume, attenuation and length for the sound.
removeSound(soundname)
removeSound(Sound-object)
# Removes a sound from the soundmanager sounds list.
# Can give either a string of the soundname, or the Sound object itself.
getSound(soundname)
# Returns the Sound object with the specified name, or None if not found.
getGlobalVolume()
# Returns the maximum global volume for all sounds, i.e. a sounds' volume cannot go above the global volume.
setGlobalVolume(newvolume)
# Sets the maximum global volume for all sounds.
getGlobalAttenuation()
# Returns the minimum global attenuation for all sounds, i.e. a sounds' attenuation cannot go below the global attenuation.
setGlobalAttenuation(newattenuation)
# Sets the minimum global attenuation for all sounds.
getNextSound()
# Returns the next sound in the soundmanager sounds dictionary.
# If the end is found, it will return to the beginning of the dictionary.
# If no sounds are listed, then None is returned.[/syntax]
SoundManager also works with objects using the Sound class, to better organise Sounds. Here are the recommended exposed functions for the Sound class, which can be used on the Sound objects:
[syntax="python"]getSoundname()
#Returns the sound name of the sound.
getFilename()
#Returns the file name of the sound.
getVolume()
# Returns the volume of the sound (is used when a play/emit function is called).
setVolume(newvolume)
# Sets the volume of the sound.
getAttenuation()
# Returns the attenuation of the sound (is used when an emit function is called).
setAttenuation(newAttenuation)
# Sets the attenuation of the sound
getLength()
# Returns the length of the sound, or None if no length was defined on creation.
getPlaying()
# Returns True if the sound is playing, and False otherwise.
# Note: This will only return True for playing if a length was defined on creation.
getLooping()
# Returns True if the sound will loop when played, and False otherwise.
setLooping(newLoop)
# Sets the loop state to the Boolean value.
# Note: This will only occur if a length was defined on creation.
playSoundToPlayer(playerID)
# Plays the sound only to the player with ID of playerID.
playSoundToList(listFilter)
# Plays the sound to players that fall within a filtered list string.
# The filters used are a direct copy of those used in playerlib.getPlayerList()
playSoundToAll()
# Plays the sound to all players.
emitSoundFromPlayer(playerID)
# Emits the sound from the player with ID of playerID.
emitSoundFromEntity(entityIndex)
# Emits the sounds from the entity with index of entityIndex.
stopSoundToPlayer(playerID)
# Stops the sound only for the player with ID of playerID.
stopSoundToList(listFilter)
# Stops the sound for players that fall within a filtered list string.
stopSoundToAll()
# Stops the sound for all players.[/syntax]
In addition to all of the above exposed functions, you can also subscribe to events that are fired by soundmanager. These do not require the "from soundmanager import *" line, as they use the EventScripts event firing system. The events available at current are:
[list]
[*] [b]sound_play[/b]
[*] [b]sound_emit[/b]
[*] [b]sound_stop[/b]
[/list]
For these events, the event_vars available are:
[list]
[*] [b]soundname[/b]: Name of the sound triggered.
[*] [b]filename[/b]: File name of the sound triggered.
[*] [b]volume[/b]: Volume of the sound triggered.
[*] [b]attenuation[/b]: Attenuation of the sound triggered.
[*] [b]length[/b]: Length of the sound triggered.
[*] [b]filtertype[/b]: Type of the filter for the sound triggered; Can be either:
[list]
[*] "player" – event occurred on a player.
[*] "entity" – event occurred on an entity.
[*] "list" – event occurred on a filtered list of players.
[*] "all" – event occurred on all players.
[/list]
[*] [b]filtervalue[/b]: Value of the filter according to the filtertype above, i.e.:
[list]
[*] For "player", this will be the playerID of the player.
[*] For "entity", this will be the entityIndex of the entity.
[*] For "list", this will be the list filter string of the players.
[*] For "all", this will be an empty string ("").
[/list]
[/list]