|
Author
|
Message
|
|
Senior Member
Join Date: Feb 2008
Location: TEXAS
|

11-05-2009
, 12:53
Re: Ambience Sound + Loop
|
#1
|
Quote:
Originally Posted by Jon
Not tested.
PHP Code:
// SYNTAX: "map" "sound path" "duration" // Don't include "sound/" in the sound path
#include <amxmodx> #include <amxmisc> #include <engine>
#define PLUGIN "Ambience Sounds" #define VERSION "1.0" #define AUTHOR "Jon"
new const gClass[ ] = "SoundThinker"
new gSoundFormat, Float:gDuration, gSound[ 32 ]
public plugin_init( ) { register_plugin( PLUGIN, VERSION, AUTHOR ) new Data[ 96 ] get_configsdir( Data, 95 ) add( Data, 95, "/ambience_sounds.ini" ) new CurMap[ 32 ], Map[ 32 ], Duration[ 5 ], f = fopen( Data, "rt" ) get_mapname( CurMap, 31 ) while( !feof( f ) ) { fgets( f, Data, 95 ) trim( Data ) if( !Data[ 0 ] || Data[ 0 ] == ';' || Data[ 0 ] == '/' && Data[ 1 ] == '/' ) continue parse( Data, Map, 31, gSound, 31, Duration, 4 ) if( equal( CurMap, Map ) ) { if( containi( gSound, ".mp3" ) != -1 ) { gSoundFormat = true } gDuration = str_to_float( Duration ) + 1 register_think( gClass, "SoundThink" ) new Ent = create_entity( "info_target" ) entity_set_string( Ent, EV_SZ_classname, gClass ) entity_set_float( Ent, EV_FL_nextthink, get_gametime( ) + 15.0 ) break } } fclose( f ) }
public SoundThink( Ent ) { if( !is_valid_ent( Ent ) ) return PLUGIN_CONTINUE if( gSoundFormat ) { client_cmd( 0, "mp3 stop" ) client_cmd( 0, "mp3 play sound/%s", gSound ) } else client_cmd( 0, "spk sound/%s", gSound ) entity_set_float( Ent, EV_FL_nextthink, get_gametime( ) + gDuration ) return PLUGIN_CONTINUE }
|
I am about to try it, but just from looking at the code it doesnt look like it supports .wav files.
EDIT: Tried it, I get this error and my game crashes. COM_LoadFile:not enough space for /sound/ambience/music.wav
The plugin not support .wav files? I am about to try with a .mp3 file.
Is there a max amount of length the ambience sound can be? Mine is 3 minutes and 10 seconds, that might also be the problem?
EDIT AGAIN: MP3 doesnt 'work' but it doesnt crash my server either. I am ingame but no ambience music is playing...
__________________
Think Positive - Stay Positive
Last edited by drumzplaya13; 11-05-2009 at 13:07.
|
|
|
|