Raised This Month: $ Target: $400
 0% 

Ambience Sound + Loop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jon
Veteran Member
Join Date: Dec 2007
Old 11-05-2009 , 11:00   Re: Ambience Sound + Loop
Reply With Quote #1

Not tested.

PHP Code:
// SYNTAX: "map" "sound path" "duration"
// Don't include "sound/" in the sound path

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

#define PLUGIN "Ambience Sounds"
#define VERSION "1.0"
#define AUTHOR "Jon"

new const gClass[ ] = "SoundThinker"

new gSoundFormatFloat:gDurationgSound32 ]

public 
plugin_init( )
{
    
register_pluginPLUGINVERSIONAUTHOR )
    
    new 
Data96 ]
    
get_configsdirData95 )
    
addData95"/ambience_sounds.ini" )
    
    new 
CurMap32 ], Map32 ], Duration], fopenData"rt" )
    
get_mapnameCurMap31 )
    
    while( !
feof) )
    {
        
fgetsfData95 )
        
trimData )
        
        if( !
Data] || Data] == ';' || Data] == '/' && Data] == '/' )
            continue
        
        
parseDataMap31gSound31Duration)
        
        if( 
equalCurMapMap ) )
        {
            if( 
containigSound".mp3" ) != -)
            {
                
gSoundFormat true
                
                engfunc
EngFunc_PrecacheGenericgSound )
            }
            
            else
                
engfuncEngFunc_PrecacheSoundgSound )
            
            
gDuration str_to_floatDuration ) + 1
            
            register_think
gClass"SoundThink" )
            
            new 
Ent create_entity"info_target" )
            
            
entity_set_stringEntEV_SZ_classnamegClass )
            
entity_set_floatEntEV_FL_nextthinkget_gametime( ) + 15.0 )
            
            break
        }
    }
    
    
fclose)
}

public 
SoundThinkEnt )
{
    if( !
is_valid_entEnt ) )
        return 
PLUGIN_CONTINUE
    
    
if( gSoundFormat )
    {
        
client_cmd0"mp3 stop" )
        
client_cmd0"mp3 play sound/%s"gSound )
    }
    
    else
        
client_cmd0"spk sound/%s"gSound )
    
    
    
entity_set_floatEntEV_FL_nextthinkget_gametime( ) + gDuration )
    
    return 
PLUGIN_CONTINUE


Last edited by Jon; 11-05-2009 at 15:22.
Jon is offline
drumzplaya13
Senior Member
Join Date: Feb 2008
Location: TEXAS
Old 11-05-2009 , 12:53   Re: Ambience Sound + Loop
Reply With Quote #2

Quote:
Originally Posted by Jon View Post
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 gSoundFormatFloat:gDurationgSound32 ]

public 
plugin_init( )
{
    
register_pluginPLUGINVERSIONAUTHOR )
    
    new 
Data96 ]
    
get_configsdirData95 )
    
addData95"/ambience_sounds.ini" )
    
    new 
CurMap32 ], Map32 ], Duration], fopenData"rt" )
    
get_mapnameCurMap31 )
    
    while( !
feof) )
    {
        
fgetsfData95 )
        
trimData )
        
        if( !
Data] || Data] == ';' || Data] == '/' && Data] == '/' )
            continue
        
        
parseDataMap31gSound31Duration)
        
        if( 
equalCurMapMap ) )
        {
            if( 
containigSound".mp3" ) != -)
            {
                
gSoundFormat true
            
}
            
            
gDuration str_to_floatDuration ) + 1
            
            register_think
gClass"SoundThink" )
            
            new 
Ent create_entity"info_target" )
            
            
entity_set_stringEntEV_SZ_classnamegClass )
            
entity_set_floatEntEV_FL_nextthinkget_gametime( ) + 15.0 )
            
            break
        }
    }
    
    
fclose)
}

public 
SoundThinkEnt )
{
    if( !
is_valid_entEnt ) )
        return 
PLUGIN_CONTINUE
    
    
if( gSoundFormat )
    {
        
client_cmd0"mp3 stop" )
        
client_cmd0"mp3 play sound/%s"gSound )
    }
    
    else
        
client_cmd0"spk sound/%s"gSound )
    
    
    
entity_set_floatEntEV_FL_nextthinkget_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.
drumzplaya13 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 17:32.


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