Raised This Month: $51 Target: $400
 12% 

How to play random sound?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r14170
Veteran Member
Join Date: Dec 2009
Old 11-08-2010 , 16:14   How to play random sound?
Reply With Quote #1

How do i play random sounds?
i tryed that way:
for plugin_precache:
PHP Code:
    for(new 0sizeof(bGzMusic); a++)
    
precache_sound(bGzMusic[a]); 
the const:
PHP Code:
new const bGzMusic[][] =
{
    
"bGzSounds/test1.wav",
    
"bGzSounds/test2.wav",
    
"bGzSounds/test3.wav"
}; 
and action:
PHP Code:
actionMusic(id)
{
    if (
is_user_alive(id))
    {
        
//client_cmd(0, "spk ^"%s^"", bGzMusic[random(sizeof(bGzMusic))]);
        
new random_num(0sizeof(bGzMusic) - 1);
        
client_cmd(0"spk ^"%s^""bGzMusic[a]);
    }

and i still cant run them in game any help?
r14170 is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 11-08-2010 , 16:58   Re: How to play random sound?
Reply With Quote #2

you can do it maybe like this


PHP Code:
public actionMusic(id)
{
    if(
is_user_alive(id))
    {
        switch(
random_num(0,2)) 
        {
            case 
0client_cmd(id"spk bGzSounds/test1.wav")
                
            case 
1client_cmd(id"spk bGzSounds/test2.wav")
                
            case 
2client_cmd(id"spk bGzSounds/test3.wav")
                
        }
    }

__________________
vato loco [GE-S] is offline
r14170
Veteran Member
Join Date: Dec 2009
Old 11-08-2010 , 17:01   Re: How to play random sound?
Reply With Quote #3

i made everything but i get this spammed in console when i step on the block:

S_LoadSound: Couldn't load /bGzSounds/test1.wav
S_LoadSound: Couldn't load /bGzSounds/test2.wav
S_LoadSound: Couldn't load /bGzSounds/test3.wav
r14170 is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 11-08-2010 , 17:10   Re: How to play random sound?
Reply With Quote #4

PHP Code:
#define MAX_SOUNDS 3

new my_sounds[MAX_SOUNDS][] = {
    
"bGzSounds/test1.wav",
    
"bGzSounds/test2.wav",
    
"bGzSounds/test3.wav"
}

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
}

public 
plugin_precache() 
{
    for(new 
0MAX_SOUNDSi++)
        
precache_sound(my_sounds[i])

or

PHP Code:
public plugin_precache() 
{
    
precache_sound("bGzSounds/test1.wav")
    
precache_sound("bGzSounds/test2.wav")
    
precache_sound("bGzSounds/test3.wav")

__________________
vato loco [GE-S] is offline
r14170
Veteran Member
Join Date: Dec 2009
Old 11-08-2010 , 17:26   Re: How to play random sound?
Reply With Quote #5

i tryed the two ways .. still same
r14170 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-08-2010 , 18:09   Re: How to play random sound?
Reply With Quote #6

Do you download the sounds when you enter the server ?

Check if the sounds exist on the server, and check the path for typo's
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
r14170
Veteran Member
Join Date: Dec 2009
Old 11-09-2010 , 00:13   Re: How to play random sound?
Reply With Quote #7

i get this in console:
Failed to transmit file: bGzSounds/test1.wav
Failed to transmit file: bGzSounds/test2.wav
Failed to transmit file: bGzSounds/test3.wav
r14170 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-09-2010 , 00:23   Re: How to play random sound?
Reply With Quote #8

Well, there's your first problem.
__________________
fysiks is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 11-09-2010 , 03:02   Re: How to play random sound?
Reply With Quote #9

always check ur console for errors when something doesnt work or play
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
r14170
Veteran Member
Join Date: Dec 2009
Old 11-09-2010 , 08:12   Re: How to play random sound?
Reply With Quote #10

i fixed the problems however.. now how do i play mp3 sound?

client_cmd(id, "mp3 play bGzSounds/test1.mp3"); ?
r14170 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 19:20.


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