AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Radio issue (https://forums.alliedmods.net/showthread.php?t=275198)

alfahad 11-24-2015 12:21

[Help] Radio issue
 
This plugin play sounds when the round start and ends it works fine but the problem when someone use the radio "Go" it plays a random sound.

round_sound_advanced.sma
PHP Code:

        #include < amxmodx >
        #include < amxmisc >
        
        #tryinclude "round_sounds_advanced.cfg"
        
        #pragma semicolon 1
        
        //Plugin registration
        
new const
                
PLUGIN_NAME     [ ] = "Round Sounds Advanced",
                
PLUGIN_VERSION  [ ] = "1.2",
                
PLUGIN_AUTHOR   [ ] = "CryWolf";
                
        
// pCvar Pointers
        
new pCvar_endsoundpCvar_beginsoundg_radiofix;
        
 
public 
plugin_precache ( )
{
        
pCvar_beginsound        register_cvar "amxx_bsounds""1" );
        
pCvar_endsound          register_cvar "amxx_esounds""1" );
        
        new 
ipath 128 ];
        
        if ( 
get_pcvar_num pCvar_beginsound ) )
        {
                for ( 
0sizeof g_begun_soundsi++ )
                {
                        if ( 
contain g_begun_sounds ], ".wav" ) > ) {
                                
precache_sound g_begun_sounds ] );
                        }
                        else if ( 
contain g_begun_sounds ], ".mp3" ) > ) {
                                
formatex pathcharsmax path ), "sound/%s"g_begun_sounds  ]);
                                
precache_generic path );
                        }
                }
        }
        
        if ( 
get_pcvar_num pCvar_endsound ) )
        {
                for ( 
0sizeof g_ct_win_soundsi++ )
                {
                        if ( 
contain g_ct_win_sounds ], ".wav" ) > ) {
                                
precache_sound g_ct_win_sounds ] );
                        }
                        else if ( 
contain g_ct_win_sounds ], ".mp3" ) > ) {
                                
formatex pathcharsmax path ), "sound/%s"g_ct_win_sounds ] );
                                
precache_generic path );
                        }
                }
                
                for ( 
0sizeof g_te_win_soundsi++ )
                {
                        if ( 
contain g_te_win_sounds ], ".wav" ) > ) {
                                
precache_sound g_te_win_sounds ] );
                        }
                        else if ( 
contain g_te_win_sounds ], ".mp3" ) > ) {
                                
formatex pathcharsmax path ), "sound/%s"g_te_win_sounds ] );
                                
precache_generic path );
                        }
                }
        }
}
 
public 
plugin_init ( )
{
        
register_plugin PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR );
        
        
register_message get_user_msgid "SendAudio" ), "FunC_MSG_SendAudio" );
}
 
public 
FunC_MSG_SendAudio msgiddestid )
{
        static 
audiocode 26 ];
        
get_msg_arg_string 2audiocodecharsmax audiocode ) );
        
        if( 
get_pcvar_num pCvar_beginsound ) )
        {
                if ( 
equal audiocode ], "MOVEOUT" ) || equal audiocode ], "LOCKNLOAD" )
                || 
equal audiocode ], "LETSGO" )  || ( equal audiocode ], "GO" ) && !g_radiofix ) )
                {
                        
set_msg_arg_string 2"%!MRAD_ELIM" ), g_radiofix false;
                        
g_radiofix false;
                        new 
random sizeof g_begun_sounds ) );
                        
PlaySoundToClients g_begun_sounds ] );
                        return 
1;
                }
        }
        if ( 
equal audiocode ], "terwin" ) && get_pcvar_num pCvar_endsound ) )
        {
                new 
random sizeof g_te_win_sounds ) );
                
PlaySoundToClients g_te_win_sounds ] );
                return 
1;
        }
        else if ( 
equal audiocode ], "ctwin" ) )
        {
                new 
random sizeof g_ct_win_sounds ) );
                
PlaySoundToClients g_ct_win_sounds ] );
                return 
1;
        }
        return 
0;
}
 
public 
cmd_fixradio ( ) {
        
g_radiofix true;
}
        
PlaySoundToClients ( const sound [ ] )
{
        if ( 
equal sound strlen sound ) -], ".mp3" ) )
                
client_cmd 0"mp3 play ^"sound/%s^""sound );
        else
                
client_cmd 0"spk ^"%s^""sound );


round_sound_advanced.cfg
PHP Code:

    /*
        Round Sounds Advanced v1.0
            by CryWolf
        
        Info:
            Pentru a adauga mai multe sunete adaugati o virgula dupa ultimele ghilimele
            si adaugati mai departe gen:
            
                new const g_begun_sounds [ ] [ ] =
                {
                    "misc/begun1.mp3",
                    "misc/begun2.wav",
                    "misc/begun3.wav",
                    "misc/begun4.wav",
                    "misc/begun5.wav",
                    "misc/begun6.wav"
                };
            
            ATENTIE! Ultimul rand nu trebuie sa aiba virgulita!
            ATENTIE! Acest fisier trebuie sa fie in folderul "scripting" langa .sma-ul "round_sounds_advanced.sma" astfel pluginul nu se va compila!
    */
    
    
    // Sunetele de la inceput de runda :)
    // Format .MP3 si .WAV
    
new const g_begun_sounds [ ] [ ] =
    {
        
"misc/begun1.mp3",
        
"misc/begun2.wav"
    
};
    
    
// Sunetele cand echipa Counter-Terrorist este castigatoarea :)
    // Format .MP3 si .WAV
    
new const g_ct_win_sounds [ ] [ ] =
    {
        
"misc/win_ct1.wav",
        
"misc/win_ct1.mp3"
    
};
    
    
// Sunetele cand echipa Terrorist este castigatoarea :)
    // Format .MP3 si .WAV
    
new const g_te_win_sounds [ ] [ ] =
    {
        
"misc/te_win1.mp3",
        
"misc/te_win1.wav"
    
}; 



All times are GMT -4. The time now is 18:16.

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