Raised This Month: $ Target: $400
 0% 

how to play a sound so everyone hear?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 06-08-2009 , 03:49   how to play a sound so everyone hear?
Reply With Quote #1

Hello,
How do you do for example
Admin types "scream" in console
server plays sound - Scream VERY loud so that all players will hear it .
Frozen Usp is offline
Send a message via MSN to Frozen Usp
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-08-2009 , 04:01   Re: how to play a sound so everyone hear?
Reply With Quote #2

Something like this:
PHP Code:
#include <amxmodx>

new g_screamsound[] = {"misc/scream_dir/scream"}
new 
g_max_players

public plugin_init(){
    
g_max_players get_maxplayers()
    
register_clcmd("scream""play_it"ADMIN_KICK)
}


public 
plugin_precache(){
    
precache_sound(g_screamsound)
}


public 
play_it(id){
    for(new 
i=1i<=g_max_playersi++)
        if(
is_user_connected(i))
            
client_cmd(i"spk %s"g_screamsound)
    return 
PLUGIN_HANDLED

__________________
Impossible is Nothing
Sylwester is offline
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 06-08-2009 , 04:05   Re: how to play a sound so everyone hear?
Reply With Quote #3

¨shouldn't
PHP Code:
register_clcmd("scream""play_it"ADMIN_KICK
be

PHP Code:
register_concmd("scream""play_it"ADMIN_KICK
</SPAN>

and do i have to add .wav after scream in the g_screamsound?

Last edited by Frozen Usp; 06-08-2009 at 04:09.
Frozen Usp is offline
Send a message via MSN to Frozen Usp
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-08-2009 , 04:09   Re: how to play a sound so everyone hear?
Reply With Quote #4

If you use register_concmd, then you will be able to use that command also in server console, but if you want admins to be able to use it while they are in game, register_clcmd is enough.
__________________
Impossible is Nothing
Sylwester is offline
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 06-08-2009 , 04:12   Re: how to play a sound so everyone hear?
Reply With Quote #5

Thank you,
Another question,
how do you do so that if a player died it will play the scream sound??
Frozen Usp is offline
Send a message via MSN to Frozen Usp
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-08-2009 , 04:40   Re: how to play a sound so everyone hear?
Reply With Quote #6

Hook player death and call play_it function from there.
Also the code I pasted plays sound to everyone with same volume, but there is also a way to play sound somewhere in map, so if player dies in some place, other players will hear the sound coming from that place (if they are close enough).
You need to use emit_sound() function for that.
http://www.amxmodx.org/funcwiki.php?go=func&id=282
__________________
Impossible is Nothing
Sylwester is offline
Frozen Usp
Member
Join Date: Sep 2007
Location: Sweden
Old 06-08-2009 , 04:49   Re: how to play a sound so everyone hear?
Reply With Quote #7

can you give an example`?
Frozen Usp is offline
Send a message via MSN to Frozen Usp
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-08-2009 , 05:32   Re: how to play a sound so everyone hear?
Reply With Quote #8

Use Search
Search in suggestions/requests and scripting forums.
There are loads of examples.
__________________
Impossible is Nothing
Sylwester is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 06-08-2009 , 06:11   Re: how to play a sound so everyone hear?
Reply With Quote #9

Looping is useless here use this 1
PHP Code:
#include <amxmodx>

new const g_screamsound[] = "misc/scream_dir/scream";

public 
plugin_init() {
    
register_clcmd("scream""play_it"ADMIN_KICK)
}


public 
plugin_precache(){
    
precache_sound(g_screamsound)
}


public 
play_it(id){
    if( 
get_user_flagsid ) & ADMIN_KICK )
        
client_cmd(0"spk %s"g_screamsound)
    
    return 
PLUGIN_HANDLED

__________________
xPaw is offline
[X]-RayCat
Senior Member
Join Date: Sep 2006
Old 06-08-2009 , 16:50   Re: how to play a sound so everyone hear?
Reply With Quote #10

Quote:
Originally Posted by xPaw View Post
Looping is useless here use this 1
PHP Code:
#include <amxmodx>

new const g_screamsound[] = "misc/scream_dir/scream";

public 
plugin_init() {
    
register_clcmd("scream""play_it"ADMIN_KICK)
}


public 
plugin_precache(){
    
precache_sound(g_screamsound)
}


public 
play_it(id){
    if( 
get_user_flagsid ) & ADMIN_KICK )
        
client_cmd(0"spk %s"g_screamsound)
    
    return 
PLUGIN_HANDLED

Im not suggesting to use 0 as index sound can get horrible. I used 0 in my hide n seek countdown and it got really loud. (Use looping instead)
__________________

Last edited by [X]-RayCat; 06-08-2009 at 16:53.
[X]-RayCat 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 23:34.


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