Raised This Month: $ Target: $400
 0% 

Ambience Sound + Loop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
drumzplaya13
Senior Member
Join Date: Feb 2008
Location: TEXAS
Old 11-05-2009 , 09:15   Ambience Sound + Loop
Reply With Quote #1

I have tried variations of trying to fix this but maybe I am just not seeing something. The warning is Warning: Loose indentation on line 53

Line 53 is... fclose(f); at the end of the part of the code.

PHP Code:
{   
         new 
Data[160]         
         new 
Map[32]         
         new 
Sound[64];         
         new 
Duration[32];                 

         
fgets(fData160);         
         
parse(DataMap20Sound64Duration32); 

         if(
equali(gMapMap) && strlen(Sound) > && strlen(Duration) > 0
         {             
            
gSound Sound             
            gDuration 
Duration             
            gFoundMap 
true;                     

            return;         
         }     
     }        
     
fclose(f); 

Does that mean I have an extra } or that fclose(f); isnt in the correct place?
__________________
Think Positive - Stay Positive

Last edited by drumzplaya13; 11-05-2009 at 09:21.
drumzplaya13 is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 11-05-2009 , 09:43   Re: Warning: Loose indentation on line 53
Reply With Quote #2

PHP Code:
         }     
     }        
     
fclose(f);


PHP Code:
         }       
 
         
fclose(f);

__________________
hleV is offline
drumzplaya13
Senior Member
Join Date: Feb 2008
Location: TEXAS
Old 11-05-2009 , 09:44   Re: Warning: Loose indentation on line 53
Reply With Quote #3

I did that and it gave me 3 errors than.

Code:
Warning: Loose indentation on line 53
Warning: Loose indentation on line 56
Error: Invalid expression, assumed zero on line 56
Error: Undefined symbol "PlaySound" on line 56
Error: Expected token: "}", but found "-end of file-" on line 70
Edit: Fixed.
__________________
Think Positive - Stay Positive

Last edited by drumzplaya13; 11-05-2009 at 09:53.
drumzplaya13 is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 11-05-2009 , 10:07   Re: Warning: Loose indentation on line 53
Reply With Quote #4

Quote:
Originally Posted by drumzplaya13 View Post
I did that and it gave me 3 errors than.

Code:
Warning: Loose indentation on line 53
Warning: Loose indentation on line 56
Error: Invalid expression, assumed zero on line 56
Error: Undefined symbol "PlaySound" on line 56
Error: Expected token: "}", but found "-end of file-" on line 70
Edit: Fixed.
Error: Expected token: "}", but found "-end of file-" on line 70

Look at the end of the file and you see there is } missing. And what do you have in 56 line?
matsi is offline
drumzplaya13
Senior Member
Join Date: Feb 2008
Location: TEXAS
Old 11-05-2009 , 10:14   Re: Warning: Loose indentation on line 53
Reply With Quote #5

Quote:
Originally Posted by matsi View Post
Error: Expected token: "}", but found "-end of file-" on line 70

Look at the end of the file and you see there is } missing. And what do you have in 56 line?
I fixed the compile, the plugin doesnt seem to work as it is suppose to though. Here is the code.


PHP 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(PLUGINVERSIONAUTHOR)
    
    
gCvarMethod register_cvar("amx_ambience_method""0"
    
    
set_task(20.0"PlaySound")
    
    
get_mapname(gMap31)
}

public 
plugin_cfg()
{
    new 
configfile[96];
    
get_configsdir(configfile96);
    
add(configfile96"/ambience_sounds.ini");
    
    new 
fopen(configfile"rt");
    
    while (!
feof(f))
    {
        new 
Data[160]
        new 
Map[32]
        new 
Sound[64];
        new 
Duration[32];
        
        
fgets(fData160);
        
parse(DataMap20Sound64Duration32);
        
        if(
equali(gMapMap) && strlen(Sound) > && 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")

__________________
Think Positive - Stay Positive
drumzplaya13 is offline
drumzplaya13
Senior Member
Join Date: Feb 2008
Location: TEXAS
Old 11-05-2009 , 10:21   Re: Warning: Loose indentation on line 53
Reply With Quote #6

Quote:
Originally Posted by matsi View Post
Error: Expected token: "}", but found "-end of file-" on line 70

Look at the end of the file and you see there is } missing. And what do you have in 56 line?
I fixed the compile, the plugin doesnt seem to work as it is suppose to though. Here is the code. What I am trying to do is have a .wav file that plays as ambience and loops the whole time I am on a specific map.


PHP 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(PLUGINVERSIONAUTHOR)
    
    
gCvarMethod register_cvar("amx_ambience_method""0"
    
    
set_task(20.0"PlaySound")
    
    
get_mapname(gMap31)
}

public 
plugin_cfg()
{
    new 
configfile[96];
    
get_configsdir(configfile96);
    
add(configfile96"/ambience_sounds.ini");
    
    new 
fopen(configfile"rt");
    
    while (!
feof(f))
    {
        new 
Data[160]
        new 
Map[32]
        new 
Sound[64];
        new 
Duration[32];
        
        
fgets(fData160);
        
parse(DataMap20Sound64Duration32);
        
        if(
equali(gMapMap) && strlen(Sound) > && 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")

__________________
Think Positive - Stay Positive
drumzplaya13 is offline
Jon
Veteran Member
Join Date: Dec 2007
Old 11-05-2009 , 11:00   Re: Ambience Sound + Loop
Reply With Quote #7

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 #8

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
Jon
Veteran Member
Join Date: Dec 2007
Old 11-05-2009 , 13:15   Re: Ambience Sound + Loop
Reply With Quote #9

Show me what you put in the file. It should support .wav.

Edit: I tested it and it works.

Last edited by Jon; 11-05-2009 at 13:21.
Jon is offline
drumzplaya13
Senior Member
Join Date: Feb 2008
Location: TEXAS
Old 11-05-2009 , 13:18   Re: Ambience Sound + Loop
Reply With Quote #10

Quote:
Originally Posted by Jon View Post
Show me what you put in the file.

Old file before you fixed it.

Code:
;For mp3 files you need full path
;EXAMPLE:
;-For wavs use:
;de_dust2 ambience/ambience.wav 100
;-For mp3 use:
;de_dust2 sound/ambience/ambience.mp3 100

de_dust2_cz ambience/FaceClassicTheme.mp3 100
file now that it doesnt support .wav files it looks like...


Code:
;For mp3 files you need full path
;EXAMPLE:
;-For mp3 use:
;de_dust2 ambience/ambience.mp3 100

de_dust2_cz ambience/theme.mp3 190
my file is 3 minutes and 10 seconds so 190 seconds for the file.
__________________
Think Positive - Stay Positive
drumzplaya13 is offline
Reply


Thread Tools
Display Modes

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