Raised This Month: $ Target: $400
 0% 

playing sound does not work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
proffs
Senior Member
Join Date: Jul 2013
Old 05-24-2014 , 13:15   playing sound does not work
Reply With Quote #1

I have this on my BM but it wont play or preache any sound file.


PHP Code:
new g_sound_music[][] =
{      
        
"sound/misc/sg1.mp3",
        
"sound/misc/sg2.mp3",
        
"sound/misc/sg3.mp3",
        
"sound/misc/sg4.mp3",
        
"sound/misc/sg5.mp3"
 
};

new 
bool:g_BlockMusic;


public 
plugin_precache()
{

        for(new 
i=0i<sizeof(g_sound_music); i++)
        {
                
precache_generic(g_sound_music[i]);
        }
}



public 
ActionMusic()
{
        if(!
g_BlockMusic)
        {
                new 
rand random(sizeof(g_sound_music));
                new 
command[128];
                
format(commandcharsmax(command), "mp3 play %s"g_sound_music[rand]);
                new 
iPlayers[32], iNum;
                
get_players(iPlayersiNum);
                for(new 
i=0;i<=iNum;i++)
                {
                        new 
id iPlayers[i];
                        if(
is_user_connected(id))
                        {
                                
client_cmd(idcommand);
                        }
                }
                
g_BlockMusic true;
                
set_task(40.0"AllowMusic");
        }
}
 
public 
AllowMusic()
{
        
g_BlockMusic true;


Last edited by proffs; 05-24-2014 at 13:16.
proffs is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 05-24-2014 , 13:29   Re: playing sound does not work
Reply With Quote #2

Code:
format(command, charsmax(command), "mp3 play %s", g_sound_music[rand]);

Code:
format(command, charsmax(command), "mp3 play ^"%s^"", g_sound_music[rand]);
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
proffs
Senior Member
Join Date: Jul 2013
Old 05-24-2014 , 13:40   Re: playing sound does not work
Reply With Quote #3

Quote:
Originally Posted by Fuck For Fun View Post
Code:
format(command, charsmax(command), "mp3 play %s", g_sound_music[rand]);

Code:
format(command, charsmax(command), "mp3 play ^"%s^"", g_sound_music[rand]);
Still not working, It doesn't even preache the sounds!
proffs is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 05-24-2014 , 14:02   Re: playing sound does not work
Reply With Quote #4

It's so weird, I'm not used to working with such a messy code
Try this:

Code:
new g_sound_music[][] =
{      
        "misc/sg1.mp3",
        "misc/sg2.mp3",
        "misc/sg3.mp3",
        "misc/sg4.mp3",
        "misc/sg5.mp3"
 
};

new bool:g_BlockMusic;


public plugin_precache()
{
    
        for ( new i = 0; i < sizeof g_sound_music; i++ )
        precache_sound( g_sound_music[ i ] );    
}



public ActionMusic()
{
        if(!g_BlockMusic)
        {
                new rand = random(sizeof(g_sound_music));
                new command[128];
                format(command, charsmax(command), "mp3 play ^"sound/%s^"", g_sound_music[rand]);
                new iPlayers[32], iNum;
                get_players(iPlayers, iNum);
                for(new i=0;i<=iNum;i++)
                {
                        new id = iPlayers[i];
                        if(is_user_connected(id))
                        {
                                client_cmd(id, command);
                        }
                }
                g_BlockMusic = true;
                set_task(40.0, "AllowMusic");
        }
}
 
public AllowMusic()
{
        g_BlockMusic = true;
}
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-24-2014 , 16:37   Re: playing sound does not work
Reply With Quote #5

Hahaha, bros! Really funny!
Just the bool in the task should become FALSE. Repeat - false! Because in the function the check is for false, and it's setted on true. Therefore, to work second time and play song again after 40 secs, the bool should be false in the task. Funny, yeah That's why it's playing only one song.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
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 09:37.


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