AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to play a sound so everyone hear? (https://forums.alliedmods.net/showthread.php?t=94208)

Frozen Usp 06-08-2009 03:49

how to play a sound so everyone hear?
 
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 .

Sylwester 06-08-2009 04:01

Re: how to play a sound so everyone hear?
 
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



Frozen Usp 06-08-2009 04:05

Re: how to play a sound so everyone hear?
 
¨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?

Sylwester 06-08-2009 04:09

Re: how to play a sound so everyone hear?
 
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.

Frozen Usp 06-08-2009 04:12

Re: how to play a sound so everyone hear?
 
Thank you,
Another question,
how do you do so that if a player died it will play the scream sound??

Sylwester 06-08-2009 04:40

Re: how to play a sound so everyone hear?
 
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

Frozen Usp 06-08-2009 04:49

Re: how to play a sound so everyone hear?
 
can you give an example`?

Sylwester 06-08-2009 05:32

Re: how to play a sound so everyone hear?
 
Use Search
Search in suggestions/requests and scripting forums.
There are loads of examples.

xPaw 06-08-2009 06:11

Re: how to play a sound so everyone hear?
 
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



Frozen Usp 06-08-2009 07:59

Re: how to play a sound so everyone hear?
 
the sound isn't being played :S


All times are GMT -4. The time now is 23:34.

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