AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ambient (https://forums.alliedmods.net/showthread.php?t=28831)

NewUser 05-23-2006 19:27

Ambient
 
Could someone explain how I would use this?

Quote:

Originally Posted by AMXX Funcwiki
EF_EmitAmbientSound -
Syntax:
EF_EmitAmbientSound ( const ENTITY, Float:pos[3], const SAMPLE[], Float:volume, Float:attenuation, fFlags, pitch )
Type:
Stock
Notes:

My thoughts are:
Code:
new entity[33]; new position1[33][3] = {origin, origin, origin} EF_EmitAmbientSound(entity, position1, NotSureAtAllHere, 1.0, NotSureATAllHere);

May I please have an explanatory example?

Hawk552 05-23-2006 20:21

Code:
emit_sound ( id, CHAN_AUTO, g_szSound, 1.0, ATTN_NORM, 0, PITCH_NORM )

What is this?

id - entity to emit from
CHAN_AUTO - the channel to emit from. More details here: http://www.amxmodx.org/funcwiki.php?...=1#const_sound
g_szSound - any sound file, like "mysound.wav"
1.0 - volume
ATTN_NORM - attenuation level
0 - flags, not generally needed
PITCH_NORM - You can modify the pitch with this sound it sounds more high or low.

NewUser 05-24-2006 18:43

I know how to use emit_sound. I was looking for the thing closest to "ambient_generic" that I could find. I don't want the sound to be emitted on a player. At an origin. Then again, emit sound might work at an origin?

Code:
new position[33][3] {origin, origin, origin} emit_sound(position, CHAN_AUTO, "mysound.wav", ATTN_NORM, 0, PITCH_NORM);

Hawk552 05-24-2006 18:52

Here's what you can do:

Case 1: You want to emit it on all players. Just client_cmd(0,"spk sound.wav")

Case 2: You want to emit it from an ambient generic.

Steps:

1) Create an ambient_generic (create_entity)
2) Set its origin and whatever other properties (entity_set_x, DispatchSpawn)
3) emit_sound on it

I'm not quite sure how to use EF_EmitAmbientSound, I'm guessing it's very similar if not the same as emit_sound.

NewUser 05-24-2006 19:53

One last thing, how would I "replay" the sound after the file was finished playing. Other than an infinite set_task loop until it ends to execute it again.

Hawk552 05-24-2006 19:55

Quote:

Originally Posted by NewUser
One last thing, how would I "replay" the sound after the file was finished playing. Other than an infinite set_task loop until it ends to execute it again.

Set EV_FL_nextthink on the ent to the end of the sound, and then play it on each think (using register_think)

I think there's a loop thing somewhere but I'm not sure how to do it.

VEN 05-25-2006 05:05

Quote:

Case 1: You want to emit it on all players. Just client_cmd(0,"spk sound.wav")
Normally just set attenuation to 0.0 (ATTN_NONE)

Quote:

Case 2: You want to emit it from an ambient generic.

Steps:

1) Create an ambient_generic (create_entity)
2) Set its origin and whatever other properties (entity_set_x, DispatchSpawn)
3) emit_sound on it
No: 3) use ambient_generic by other entity

Emit[Ambient]Sound flags
Code:
#define SND_SPAWNING        (1<<8)      // duplicated in protocol.h we're spawing, used in some cases for ambients #define SND_STOP        (1<<5)      // duplicated in protocol.h stop sound #define SND_CHANGE_VOL      (1<<6)      // duplicated in protocol.h change sound vol #define SND_CHANGE_PITCH    (1<<7)      // duplicated in protocol.h change sound pitch

ambient_generic spawnlags
Code:
#define AMBIENT_SOUND_STATIC            0   // medium radius attenuation #define AMBIENT_SOUND_EVERYWHERE        1 #define AMBIENT_SOUND_SMALLRADIUS       2 #define AMBIENT_SOUND_MEDIUMRADIUS      4 #define AMBIENT_SOUND_LARGERADIUS       8 #define AMBIENT_SOUND_START_SILENT      16 #define AMBIENT_SOUND_NOT_LOOPING       32

Normally ambient_generic is looping.

Also if you have an issues with ambient_generic look into Fall Scream plugin.

Zenith77 05-25-2006 16:07

I'm probably wrong about this, I don't much about the way HL handles sound, but when you set the channel to CHAN_STATIC, it seems to repeat the sound endlessly.

NewUser 05-25-2006 18:59

Would I put the ambient_generic code in public client_putinserver?

VEN 05-26-2006 09:57

Depends on what did you mean by "ambient_generic code". ;)


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

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