Raised This Month: $51 Target: $400
 12% 

Map ambience sounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mlk27
Veteran Member
Join Date: May 2008
Old 07-28-2008 , 00:19   Map ambience sounds
Reply With Quote #1

i havent found anyone made this plugin. i need a plugin that will play ambience sound throughout the map that is being played. and i want to set different sounds for different maps so it must have cvar like these, eg

// amx_ambience "map-name" "mp3-name" "duration(sec)"
amx_ambience_1 "zm_die_hard_tn" "ambience001.mp3" "100"
amx_ambience_2 "zm_office_b2" "ambience003.mp3" "50"
Mlk27 is offline
Jon
Veteran Member
Join Date: Dec 2007
Old 07-28-2008 , 17:56   Re: Map ambience sounds
Reply With Quote #2

Untested.

Instead of cvars I made a config file where the syntax is the same as you wrote in your cvars (mapname, sound, duration).

The cvar amx_ambience_method is for if you want to play waves or mp3 files. Value 0 = Mp3, Value 1 = .wav. Default: 0.

Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Ambience Sounds" #define VERSION "1.0" #define AUTHOR "Jon" new gCvarMethod; new gSound[64]; new gDuration[32]; new gMap[32]; new bool:gFoundMap; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         gCvarMethod = register_cvar("amx_ambience_method", "0")         set_task(20.0, "PlaySound")         get_mapname(gMap, 31) } public plugin_cfg() {     new configfile[96];     get_configsdir(configfile, 96);     add(configfile, 96, "/ambience_sounds.ini");         new f = fopen(configfile, "rt");         while (!feof(f))     {         new Data[160]         new Map[32]         new Sound[64];         new Duration[32];                 fgets(f, Data, 160);         parse(Data, Map, 20, Sound, 64, Duration, 32);                 if(equali(gMap, Map) && strlen(Sound) > 0 && strlen(Duration) > 0)         {             gSound = Sound             gDuration = Duration             gFoundMap = true;                     return;         }     }         fclose(f); } public PlaySound() {     if(!gFoundMap)         return;             if(get_pcvar_num(gCvarMethod) == 1)         client_cmd(0, "spk %s", gSound)             else          client_cmd(0, "mp3 play %s", gSound)         set_task(float(str_to_num(gDuration)) + 5.0, "PlaySound") }
Attached Files
File Type: ini ambience_sounds.ini (157 Bytes, 171 views)
Jon is offline
Mlk27
Veteran Member
Join Date: May 2008
Old 07-28-2008 , 21:25   Re: Map ambience sounds
Reply With Quote #3

thanks. compiled and tested. but why the sound doesnt play immediately when players join and it's still playing in client cs when they disconnect. the sound need to be looped over and over again.

thanks again
Mlk27 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode