Raised This Month: $ Target: $400
 0% 

Sound File


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Erdener
Senior Member
Join Date: Apr 2010
Location: Turkey
Old 03-01-2013 , 06:41   Sound File
Reply With Quote #1

How can i run sound files?

PHP Code:
Slayaim(id)
{
    new 
playerbody;
    new 
szPlayerName[32];
    
get_user_aiming(idplayerbody);
    
get_user_name(playerszPlayerName32);

    if (
get_user_flags(id) & ADMIN_BAN)
    {
        if (
is_user_alive(player) && get_user_flags(player) & ADMIN_IMMUNITY)
        {
            
client_print(id"You cant slay some one with Immunity!");
        }
        else
        if (
is_user_alive(player))
        {
            
user_kill(player);
            
client_print(player"You have been Slayed!");
            
client_print(id"You just Slayed %s!"szPlayerName);
            
client_cmd(0"spk %s"sounds[random_num(0charsmax(sounds))]);
        }
    }


Last edited by Erdener; 03-01-2013 at 06:46.
Erdener is offline
xfirestorm
Member
Join Date: Mar 2012
Old 03-01-2013 , 06:53   Re: Sound File
Reply With Quote #2

precache_sound("path/to/sound/file.wav);

client_cmd(0,... change to: client_cmd(<id_of_player_to_play_sound_on>,.. .
xfirestorm is offline
Erdener
Senior Member
Join Date: Apr 2010
Location: Turkey
Old 03-01-2013 , 07:06   Re: Sound File
Reply With Quote #3

Yes, i know i add precache_sound();

but, i would like to use a random sound.

EDIT:

PHP Code:
new sounds[][] =
{
    
"filename/xxx.wav",
    
"filename/yyy.wav"
}; 

Last edited by Erdener; 03-01-2013 at 07:07.
Erdener is offline
xfirestorm
Member
Join Date: Mar 2012
Old 03-01-2013 , 07:21   Re: Sound File
Reply With Quote #4

Don't think you can precache the whole array at once, you'd probably need to precache each sound, one by one.
Then in random instead of charsmax(sounds) use sizeof(sounds)
xfirestorm is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 03-01-2013 , 07:38   Re: Sound File
Reply With Quote #5

Quote:
Originally Posted by xfirestorm View Post
Don't think you can precache the whole array at once, you'd probably need to precache each sound, one by one.
Then in random instead of charsmax(sounds) use sizeof(sounds)
An array can be precached using a loop.
And there's nothing wrong with using charsmax, apart from readability reasons, since:

PHP Code:
#define charsmax(%1) (sizeof(%1)-1) 
@Erdener what exactly is your question?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-01-2013 , 07:44   Re: Sound File
Reply With Quote #6

Quote:
Originally Posted by hornet View Post
And there's nothing wrong with using charsmax, apart from readability reasons
In this case, it is wrong to use charsmax since if used you will never get the last sound file when you precache it or attempt to randomly play it
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 03-01-2013 , 07:48   Re: Sound File
Reply With Quote #7

Quote:
Originally Posted by YamiKaitou View Post
In this case, it is wrong to use charsmax since if used you will never get the last sound file when you precache it or attempt to randomly play it
Oh whoops my bad soz :\
lol think before say ay.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 03-01-2013 at 07:49.
hornet is offline
xfirestorm
Member
Join Date: Mar 2012
Old 03-01-2013 , 07:50   Re: Sound File
Reply With Quote #8

Quote:
Originally Posted by hornet View Post
An array can be precached using a loop.
This is still precached one-by-one, since you can't pass the whole array into precache_sound.
You just don't type the same code over and over again...

Last edited by xfirestorm; 03-01-2013 at 07:51.
xfirestorm is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-01-2013 , 08:57   Re: Sound File
Reply With Quote #9

Code:
new const c_SoundsToPlay[ ][ ] = {     "sound/sound1.wav",     "sound/sound2.wav",     "sound/sound3.wav" } public plugin_precache( ) {     for( new iCnt; iCnt < sizeof c_SoundsToPlay; iCnt ++ )         precache_generic( c_SoundsToPlay[ iCnt ] ) } client_cmd( 0, "spk %s", c_SoundsToPlay[ random( sizeof c_SoundsToPlay ) ] )
Backstabnoob is offline
Erdener
Senior Member
Join Date: Apr 2010
Location: Turkey
Old 03-01-2013 , 12:15   Re: Sound File
Reply With Quote #10

hmmm, nice thnx
Erdener 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 21:36.


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