EventScripts Forums
Mattie's EventScripts and Source Forums
Mattie recommends...
Premier Sponsor:Platinum Sponsor:
 
Script Categories
addon (49) admin (269) admins (14) advert (15) adverts (19) afk (15) alerts (12) ammo (23) anti (15) auth (16) automatic (12) awp (23) ban (18) ba_jail (17) bhop (19) block (19) bomb (40) bonus (23) bot (24) bot-management (19) bots (17) bunnyhop (11) Buy (21) cash (65) chat (57) cheat (11) clan (16) classes (22) color (21) colors (18) command (20) commands (18) config (22) connect (42) CS:S (16) css (2498) Damage (35) database (11) dead (15) death (19) deathmatch (70) deathrun (12) disconnect (18) Dissolve (11) dm (20) dod:s (11) dods (386) easy (17) effects (120) English (15) entity (21) es_tools (12) Eventscript (12) flashbang (25) français (99) french (36) fun (286) funny (16) Gabeee (11) gameplay (174) give (16) gravity (11) grenade (25) grenades (29) gun (14) GunGame (26) GunGame5 (11) guns (17) Hack (15) headshot (32) health (54) hegrenade (13) hl2dm (329) HP (13) info (48) information (16) jail (26) jailbreak (11) join (23) jump (12) kick (23) kill (44) kills (22) knife (57) leveling (36) management (14) mani (15) map (25) map-management (27) maps (15) match (17) menu (106) message (20) messaging (52) mod (109) model (14) models (32) money (42) motd (12) music (29) mute (18) nades (18) name (13) noblock (35) player (40) player-management (31) player-tracking (28) popup (55) props (23) protection (27) punishment (50) python (63) quake (18) radio (21) random (36) rank (35) rates (16) rcon (13) realism (21) respawn (61) restrict (36) round (20) rpg (24) rules (42) say (11) scout (19) Script (20) script-helper (25) scriptpack (33) sdk (149) server (44) server-tools (42) shop (12) silly (31) simple (27) skins (24) slay (13) soccer (11) sound (45) sounds (92) spawn (62) speed (25) statistics (13) stats (48) STEAMID (23) Superhero (13) surf (31) Team (25) team-balance (14) teleport (11) text (14) TF2 (143) time (17) timer (14) tools (15) tracers (17) triggers (11) uedi (18) uses_auth (18) utility (11) vip (11) vote (36) voting (22) war (20) wcs (24) wcs:Python (32) weapon (77) weapons (114) web (14) welcome (12) zm (24) zombie (90) zombiemod (51) zombies (11)
Script Authors
*XYZ*SaYnt (12) .:MiB:. (11) .eMko* (6) 101satoon101 (10) 3R10N (24) 4u571n91 (5) 7355608 (9) Absolute (8) Ace Rimmer (40) adminc (5) Adz (8) AgathaKnuppelkuh (8) aidden (8) ajax (5) ak_47 (6) Al3c Tr3v3lyan (6) allstareng (5) ashbash1987 (9) ATAMAH (7) aznone (5) B00M (5) BackRaw (41) BFH_RedBull (8) bigfabi (7) Bioko (7) Blade (10) bladesback (13) bobdole (11) bodzsar1 (8) bonbon (36) Brainsucker (30) cagemonkey (8) carbon-14 (10) CaskioUTF (5) cbirou (15) ChaCaLz2psy4 (5) CharlesT (5) Chrisber (5) chrismrulz (9) Chun (6) cladiron (10) clipz934 (8) Colster (21) Cookieman8 (7) craziest (10) DanielB (19) Darkness123 (8) Dave (9) dbozan99 (7) deathx9 (5) Deathyy (15) dhack (16) Di[M]aN (12) DoCky (27) Don (15) dordtcore (8) DragonFreddo (8) Drassil (5) Einlanzers (42) EmbouT (10) emilplov (7) Errant (10) Eun (6) Fantole (9) Franc1sco (9) freddukes (18) Frequency (6) Fulmine (5) GAMEREN2 (8) german9114 (13) GODJonez (38) GoodfellaDeal (5) Hansi (6) HitThePipe (7) HOLLDIDAY (9) Icetouch (6) ichthys (25) infamous1 (9) Jeff91 (45) JoeyT2006 (30) Juba_PornBorn (12) jxl180 (10) KDBFame (6) L'In20Cible (7) Largo Usagi (10) Lobe (11) loKkdoKk (7) lolo-le-haricot (7) LosNir (5) Lumpi@Work (9) M4rc3L-XCN (7) macshot (6) Matth (5) Mattie (20) MBchrono (15) McFly (20) Medda (5) Memphis-84 (10) Messiah93 (12) Mickyy (5) micmacx (6) Mitchell (5) Mordavolt (7) MrScriptaz (5) mryoung (6) Nicolous (26) ojii (31) Omega_K2 (6) Owned|Myself (8) P3N (7) pand3mic (5) parsimba (5) Pascal257 (9) PatPeter (7) PDrop (10) Phaedrus (18) PhantOm Fury (7) phoenix131 (8) pinkyyy -.- (5) pitbull0993 (7) randomknifer (9) Ratzee (6) ReaCtioN2oo9 (6) Rennnyyy (17) revolutionfighters (6) RideGuy (12) Rio (9) Roeliekt (6) runamagic (13) sandking220 (6) Sarcasm_Poisoning (10) saRs| Johnny-5 (13) Schubaal (10) sea212 (5) sega74rus (7) sgt.angel (6) sicilia (5) sicman_adrian (22) skillz92 (7) sn4k3 (18) snake38 (10) sonicsight (7) spoonman184 (8) stabby (22) stas (22) Strontium Dog (30) SumGuy14 (25) SuperDave (45) surfteam (5) TaCo (5) TanaToS (17) Tealk (6) teowow (16) TheCheeTaH (20) TheDonFather (5) theresthatguy (6) Tiny Tod (7) Totyahun (9) uedi (38) Undead (25) usernamesaretaken (15) Warren (13) westham (6) WhiteAvenger (7) Wonder (14) X-Mania (5) XE_ManUp (13) xfalcon61 (5) zSweetXz (5) [Cs]Lord_Inferno2 (11) [NATO]Hunter (28) ||Wolf|| (10)
Search

Post new topic Reply to topic
Author Message
User avatar
Web Hotshot
Web Hotshot
Profile

Posts: 478
Location:
Darlington, UK

Steam Friends Name: ashbash1987
 
New postPosted: 2008-11-07, 5:59 pm 
   Post subject: [v1.0.1][6th Apr 09]SoundManager

SoundManager v1.0.1
Posted by: ashbash1987 on 2008-11-07 17:35:35.

Requirements:Description:

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!

Specifics For Server Owners
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:
  • Add/Remove sounds via RCON, e.g.: sm_add_sound "mySound" "mySound.mp3"; sm_remove_sound "mySound"
  • Play/Emit/Stop sounds via RCON, 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
  • Modify global sound properties via RCON, 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.
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!

Specifics For EventScripts Scripters
This script can be used to create your own simple sound manager in seconds! Here's an example script that uses the SoundManager functionality:
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()

The recommended functions that you have available are (under the soundmanager module):
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.

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:
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.

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:
  • sound_play
  • sound_emit
  • sound_stop
For these events, the event_vars available are:
  • soundname: Name of the sound triggered.
  • filename: File name of the sound triggered.
  • volume: Volume of the sound triggered.
  • attenuation: Attenuation of the sound triggered.
  • length: Length of the sound triggered.
  • filtertype: Type of the filter for the sound triggered; Can be either:
    • "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.
  • filtervalue: Value of the filter according to the filtertype above, i.e.:
    • 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 ("").
Download: Installation:
  • Extract contents of the *.zip file into your cstrike directory.
  • Add es_load soundmanager to your autoexec.cfg.
  • You're ready to use SoundManager! :) :)
  • For those wanting to script with SoundManager, use "from soundmanager import *" to retrieve the methods from soundmanager. Note: soundmanager must be loaded before your own soundmanager mod is loaded.
Current Notes:
  • First version, first release, not fully tested, and first ever major library-type addon. Be gentle :)

Version Notes:
  • v1.0.0 - First release


Last edited by ashbash1987 on 2009-04-06, 4:26 pm, edited 3 times in total.




User avatar
Professor
Professor
Profile

Posts: 1877
Location:
Erionville
 
New postPosted: 2008-11-07, 6:03 pm 

+woot

Really good idea

_________________
Image

Nacht der lebenden Toten


User avatar
New User
Profile

Posts: 1
 
New postPosted: 2009-04-04, 6:36 am 
   Post subject: maybe a little bug ?

Hi,

i'm a noob in python programmin but i think it rocks ;)

i like your plugin too and i try to base on it to create a jukebox player for my server.

When i try to use

Code:
soundmanager.removeSound(mTitle)


with mTitle set with a valid registred sound.

i get :
Code:
Traceback (most recent call last):
  File "/home/hl2wt/hl2mp/addons/eventscripts/es.py", line 271, in callBlock
    self.Blocks[blockname]()
  File "/home/hl2wt/hl2mp/addons/eventscripts/hello/hello.py", line 96, in unload
    soundmanager.removeSound(mTitle)
  File "/home/hl2wt/hl2mp/addons/eventscripts/soundmanager/soundmanager.py", line 229, in removeSound
    del _sounds[soundName]

as result.

so i tried to modify your plugin at line 226 :
Code:
def removeSound(sound):
    if sound in _sounds.keys():
        del _sounds[soundName]

into
Code:
def removeSound(sound):
    if sound in _sounds.keys():
        del _sounds[sound]

which makes it working for me. If it helps...


User avatar
Web Hotshot
Web Hotshot
Profile

Posts: 478
Location:
Darlington, UK

Steam Friends Name: ashbash1987
 
New postPosted: 2009-04-06, 4:19 pm 

I should be ashamed with that mistake. You are indeed correct with that code change. I will update the script post-haste!

_________________
A Test ESTuts Website: http://estuts.com


User avatar
Web Hotshot
Web Hotshot
Profile

Posts: 478
Location:
Darlington, UK

Steam Friends Name: ashbash1987
 
New postPosted: 2009-04-06, 4:25 pm 

v1.0.1 - v1.0.1:
- Fixed copy-paste error. Silly me :)

_________________
A Test ESTuts Website: http://estuts.com


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group