AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Attach a sound? (https://forums.alliedmods.net/showthread.php?t=13235)

DotNetJunkie 05-09-2005 05:01

Attach a sound?
 
How do attach a sound to a paticular player that all the other
players can hear when near that paticular player?

I tried emit_sound but it doesn't seem to work :(

Thanks for any help!

sambro 05-10-2005 01:47

emit_sound should work...

I use the voice channel (CHAN_VOICE) with normal attenuation and pitch. For e.g:

emit_sound(id, CHAN_VOICE, "bleedsample.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);

Make sure you precache your sound first though, in the plugin_precache callback.

precache_sound("bleedsample.wav");

DotNetJunkie 05-10-2005 03:07

What about new players (who've just joined the game) being unable to
hear the sound until the given player dies?

I've heard this is a problem but I don't know much about it.

DotNetJunkie 05-13-2005 01:55

Quote:

Originally Posted by sambro
emit_sound should work...

I use the voice channel (CHAN_VOICE) with normal attenuation and pitch. For e.g:

emit_sound(id, CHAN_VOICE, "bleedsample.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);

Make sure you precache your sound first though, in the plugin_precache callback.

precache_sound("bleedsample.wav");

I hate to say this, but it doesn't seem to work.
It appears that only the sound that the player is attached to can hear it.

I want everybody near the player to be able to hear it.

sambro 05-13-2005 03:33

I used that exact code in my jetpack revamp plugin mate. Everyone can hear it.

Perhaps you're doing something else wrong? I dunno :shock:

DotNetJunkie 05-13-2005 09:13

well here is my code

Code:

policeradio_resetall() {
        new query[256], players[32], num
        get_players(players,num,"ac")
        for(new i = 0; i < num; i++) {
                if(is_user_connected(players[i])) {
                        if(is_user_alive(players[i])) {
                                new name[33], authid[32]
                                get_user_name(players[i],name,sizeof(name))
                                get_user_authid(players[i],authid,31)
                            format( query, 255, "SELECT JobID FROM money WHERE steamid='%s'", authid )
                            result = dbi_query(dbc,query)
                                if( dbi_nextrow( result ) > 0 )
                                {
                                        new job[32], JobID
                                        dbi_field( result, 1, job, 31)
                                        dbi_free_result(result)
                                        JobID = str_to_num(job)
                                        if((JobID >= mcpdjobs[0] && JobID <= mcpdjobs[1]))
                                        {
                                                if(policeradio[players[i]]>0) {
                                                        policeradio_reset(players[i])
                                                }
                                        }
                                }
                                dbi_free_result(result)
                        }
                }
        }
        return 0
}

policeradio_reset(id) {
        policeradio_off(id)
        if(policeradioindex[id]==0) {
                emit_sound(id, CHAN_VOICE, "harburp/policeradiochatter_0.wav", 1.0, ATTN_NORM, SND_PLAY, PITCH_NORM)
        }       
        if(policeradioindex[id]==1) {
                emit_sound(id, CHAN_VOICE, "harburp/policeradiochatter_1.wav", 1.0, ATTN_NORM, SND_PLAY, PITCH_NORM)
        }
        return 0
}

policeradio_off(id) {
        if(policeradioindex[id]==0) {
                emit_sound(id, CHAN_VOICE, "harburp/policeradiochatter_0.wav", 0.0, ATTN_NORM, SND_STOP, PITCH_NORM)
        }
        if(policeradioindex[id]==1) {
                emit_sound(id, CHAN_VOICE, "harburp/policeradiochatter_1.wav", 0.0, ATTN_NORM, SND_STOP, PITCH_NORM)
        }
        return 0
}

policeradio_on(id) {
        policeradio_off(id)
        new policeindex = random_num(0,1)
        if(policeindex==0) {
                emit_sound(id, CHAN_VOICE, "harburp/policeradiochatter_0.wav", 1.0, ATTN_NORM, SND_PLAY, PITCH_NORM)
        }
        if(policeindex==1) {
                emit_sound(id, CHAN_VOICE, "harburp/policeradiochatter_1.wav", 1.0, ATTN_NORM, SND_PLAY, PITCH_NORM)
        }
        policeradioindex[id] = policeindex
        return 0
}

Whenever a player spawns for the first time, policeradio_resetall is called
so they can hear it.

sambro 05-13-2005 11:19

Hmm.

Have you precached the sound files?

If so, attach the full plugin and I'll take a look for you.


All times are GMT -4. The time now is 16:44.

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