Raised This Month: $ Target: $400
 0% 

[ Solved ] Ambience Sound what heard everywhere


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-03-2009 , 09:10   [ Solved ] Ambience Sound what heard everywhere
Reply With Quote #1

Hello, i want place ambient_generic, give it own sound, and do what it will be heard from every place in map
__________________

Last edited by xPaw; 01-04-2009 at 06:52.
xPaw is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-03-2009 , 11:54   Re: Ambience Sound what heard everywhere
Reply With Quote #2

after taking a look in Valve hammer editor
here is values
PHP Code:
"classname"        "ambient_generic"
"spawnflags"    "1"    
// Play everywhere flag
"health"        "10"
"pitch"            "100"
"pitchstart"    "100"
"message"        "mysound.wav"
"origin"        "xxx xxx xxx" 
__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-03-2009 , 12:03   Re: Ambience Sound what heard everywhere
Reply With Quote #3

Quote:
Originally Posted by TWHL

1 - Play Everywhere - Sound will be heard in the entire level.
2 - Small Radius - Sound range is about 800 units at max volume.
4 - Medium Radius - Sound range is about 1250 units at max volume.
8 - Large Radius - Sound range is about 2000 units at max volume.
16 - Start Silent - Checking this means the entity must be triggered to work.
32 - Not Toggled - Older FGDs show this as Not Looped. Specifies that the sound is to be played only once. With this flag checked, each time the entity is triggered it will play once. If it is not checked, triggering it will cause the sound to alternate between on and off.
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-03-2009 , 12:13   Re: Ambience Sound what heard everywhere
Reply With Quote #4

yep
i'm right now going test this
PHP Code:
    new entity engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"ambient_generic"));
//    engfunc(EngFunc_SetOrigin, entity, {0, 0, 0});
    
    
set_pev(entitypev_health10.0);
    
set_pev(entitypev_messageSOUND_FILE);
    
set_pev(entitypev_spawnflags, (1<<0));    // FLAG_EVERYWHERE
    
dllfunc(DLLFunc_Spawnentity); 
__________________
xPaw is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-03-2009 , 12:33   Re: Ambience Sound what heard everywhere
Reply With Quote #5

I remember i had fast tried the way you do without success, you may need to do this while precache and use set_kvd.

From HLSDK :
PHP 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 
PHP Code:
//
// ambient_generic - general-purpose user-defined static sound
//
void CAmbientGeneric :: Spawnvoid )
{
/*
        -1 : "Default"
        0  : "Everywhere"
        200 : "Small Radius"
        125 : "Medium Radius"
        80  : "Large Radius"
*/

    
if ( FBitSet pev->spawnflagsAMBIENT_SOUND_EVERYWHERE) )
    {
        
m_flAttenuation ATTN_NONE;
    }
    else if ( 
FBitSet pev->spawnflagsAMBIENT_SOUND_SMALLRADIUS) )
    {
        
m_flAttenuation ATTN_IDLE;
    }
    else if ( 
FBitSet pev->spawnflagsAMBIENT_SOUND_MEDIUMRADIUS) )
    {
        
m_flAttenuation ATTN_STATIC;
    }
    else if ( 
FBitSet pev->spawnflagsAMBIENT_SOUND_LARGERADIUS) )
    {
        
m_flAttenuation ATTN_NORM;
    }
    else 
    {
// if the designer didn't set a sound attenuation, default to one.
        
m_flAttenuation ATTN_STATIC;
    }
    
    
charszSoundFile = (char*) STRING(pev->message);

    if ( 
FStringNullpev->message ) || strlenszSoundFile ) < )
    {
        
ALERTat_error"EMPTY AMBIENT AT: %f, %f, %f\n"pev->origin.xpev->origin.ypev->origin.);
        
pev->nextthink gpGlobals->time 0.1;
        
SetThinkSUB_Remove );
        return;
    }
    
pev->solid        SOLID_NOT;
    
pev->movetype    MOVETYPE_NONE;

    
// Set up think function for dynamic modification 
    // of ambient sound's pitch or volume. Don't
    // start thinking yet.

    
SetThink(RampThink);
    
pev->nextthink 0;

    
// allow on/off switching via 'use' function.

    
SetUse ToggleUse );
    
    
m_fActive FALSE;

    if ( 
FBitSet pev->spawnflagsAMBIENT_SOUND_NOT_LOOPING ) )
        
m_fLooping FALSE;
    else
        
m_fLooping TRUE;
    
Precache( );
}


void CAmbientGeneric :: Precachevoid )
{
    
charszSoundFile = (char*) STRING(pev->message);

    if ( !
FStringNullpev->message ) && strlenszSoundFile ) > )
    {
        if (*
szSoundFile != '!')
            
PRECACHE_SOUND(szSoundFile);
    }
    
// init all dynamic modulation parms
    
InitModulationParms();

    if ( !
FBitSet (pev->spawnflagsAMBIENT_SOUND_START_SILENT ) )
    {
        
// start the sound ASAP
        
if (m_fLooping)
            
m_fActive TRUE;
    }
    if ( 
m_fActive )
    {
        
UTIL_EmitAmbientSound ENT(pev), pev->originszSoundFile
                (
m_dpv.vol 0.01), m_flAttenuationSND_SPAWNINGm_dpv.pitch);

        
pev->nextthink gpGlobals->time 0.1;
    }
}

// RampThink - Think at 5hz if we are dynamically modifying 
// pitch or volume of the playing sound.  This function will
// ramp pitch and/or volume up or down, modify pitch/volume
// with lfo if active.

void CAmbientGeneric :: RampThinkvoid )
{
    
charszSoundFile = (char*) STRING(pev->message);
    
int pitch m_dpv.pitch
    
int vol m_dpv.vol;
    
int flags 0;
    
int fChanged 0;        // FALSE if pitch and vol remain unchanged this round
    
int    prev;

    if (!
m_dpv.spinup && !m_dpv.spindown && !m_dpv.fadein && !m_dpv.fadeout && !m_dpv.lfotype)
        return;                        
// no ramps or lfo, stop thinking

    // ==============
    // pitch envelope
    // ==============
    
if (m_dpv.spinup || m_dpv.spindown)
    {
        
prev m_dpv.pitchfrac >> 8;

        if (
m_dpv.spinup 0)
            
m_dpv.pitchfrac += m_dpv.spinup;
        else if (
m_dpv.spindown 0)
            
m_dpv.pitchfrac -= m_dpv.spindown;

        
pitch m_dpv.pitchfrac >> 8;
        
        if (
pitch m_dpv.pitchrun)
        {
            
pitch m_dpv.pitchrun;
            
m_dpv.spinup 0;                // done with ramp up
        
}

        if (
pitch m_dpv.pitchstart)
        {
            
pitch m_dpv.pitchstart;
            
m_dpv.spindown 0;                // done with ramp down

            // shut sound off
            
UTIL_EmitAmbientSound(ENT(pev), pev->originszSoundFile
                    
00SND_STOP0);

            
// return without setting nextthink
            
return;
        }

        if (
pitch 255pitch 255;
        if (
pitch 1pitch 1;

        
m_dpv.pitch pitch;

        
fChanged |= (prev != pitch);
        
flags |= SND_CHANGE_PITCH;
    }

    
// ==================
    // amplitude envelope
    // ==================
    
if (m_dpv.fadein || m_dpv.fadeout)
    {
        
prev m_dpv.volfrac >> 8;

        if (
m_dpv.fadein 0)
            
m_dpv.volfrac += m_dpv.fadein;
        else if (
m_dpv.fadeout 0)
            
m_dpv.volfrac -= m_dpv.fadeout;

        
vol m_dpv.volfrac >> 8;

        if (
vol m_dpv.volrun)
        {
            
vol m_dpv.volrun;
            
m_dpv.fadein 0;                // done with ramp up
        
}

        if (
vol m_dpv.volstart)
        {
            
vol m_dpv.volstart;
            
m_dpv.fadeout 0;                // done with ramp down
            
            // shut sound off
            
UTIL_EmitAmbientSound(ENT(pev), pev->originszSoundFile
                    
00SND_STOP0);

            
// return without setting nextthink
            
return;
        }

        if (
vol 100vol 100;
        if (
vol 1vol 1;

        
m_dpv.vol vol;

        
fChanged |= (prev != vol);
        
flags |= SND_CHANGE_VOL;
    }

    
// ===================
    // pitch/amplitude LFO
    // ===================
    
if (m_dpv.lfotype)
    {
        
int pos;

        if (
m_dpv.lfofrac 0x6fffffff)
            
m_dpv.lfofrac 0;

        
// update lfo, lfofrac/255 makes a triangle wave 0-255
        
m_dpv.lfofrac += m_dpv.lforate;
        
pos m_dpv.lfofrac >> 8;

        if (
m_dpv.lfofrac 0)
        {
            
m_dpv.lfofrac 0;
            
m_dpv.lforate abs(m_dpv.lforate);
            
pos 0;
        }
        else if (
pos 255)
        {
            
pos 255;
            
m_dpv.lfofrac = (255 << 8);
            
m_dpv.lforate = -abs(m_dpv.lforate);
        }

        switch(
m_dpv.lfotype)
        {
        case 
LFO_SQUARE:
            if (
pos 128)
                
m_dpv.lfomult 255;
            else
                
m_dpv.lfomult 0;
            
            break;
        case 
LFO_RANDOM:
            if (
pos == 255)
                
m_dpv.lfomult RANDOM_LONG(0255);
            break;
        case 
LFO_TRIANGLE:
        default: 
            
m_dpv.lfomult pos;
            break;
        }

        if (
m_dpv.lfomodpitch)
        {
            
prev pitch;

            
// pitch 0-255
            
pitch += ((m_dpv.lfomult 128) * m_dpv.lfomodpitch) / 100;

            if (
pitch 255pitch 255;
            if (
pitch 1pitch 1;

            
            
fChanged |= (prev != pitch);
            
flags |= SND_CHANGE_PITCH;
        }

        if (
m_dpv.lfomodvol)
        {
            
// vol 0-100
            
prev vol;

            
vol += ((m_dpv.lfomult 128) * m_dpv.lfomodvol) / 100;

            if (
vol 100vol 100;
            if (
vol 0vol 0;
            
            
fChanged |= (prev != vol);
            
flags |= SND_CHANGE_VOL;
        }

    }

    
// Send update to playing sound only if we actually changed
    // pitch or volume in this routine.

    
if (flags && fChanged
    {
        if (
pitch == PITCH_NORM)
            
pitch PITCH_NORM 1// don't send 'no pitch' !

        
UTIL_EmitAmbientSound(ENT(pev), pev->originszSoundFile
                (
vol 0.01), m_flAttenuationflagspitch);
    }

    
// update ramps at 5hz
    
pev->nextthink gpGlobals->time 0.2;
    return;
}

// Init all ramp params in preparation to 
// play a new sound

void CAmbientGeneric :: InitModulationParms(void)
{
    
int pitchinc;

    
m_dpv.volrun pev->health 10;    // 0 - 100
    
if (m_dpv.volrun 100m_dpv.volrun 100;
    if (
m_dpv.volrun 0m_dpv.volrun 0;

    
// get presets
    
if (m_dpv.preset != && m_dpv.preset <= CDPVPRESETMAX)
    {
        
// load preset values
        
m_dpv rgdpvpreset[m_dpv.preset 1];

        
// fixup preset values, just like
        // fixups in KeyValue routine.
        
if (m_dpv.spindown 0)
            
m_dpv.spindown = (101 m_dpv.spindown) * 64;
        if (
m_dpv.spinup 0)
            
m_dpv.spinup = (101 m_dpv.spinup) * 64;

        
m_dpv.volstart *= 10;
        
m_dpv.volrun *= 10;

        if (
m_dpv.fadein 0)
            
m_dpv.fadein = (101 m_dpv.fadein) * 64;
        if (
m_dpv.fadeout 0)
            
m_dpv.fadeout = (101 m_dpv.fadeout) * 64;

        
m_dpv.lforate *= 256;

        
m_dpv.fadeinsav m_dpv.fadein;
        
m_dpv.fadeoutsav m_dpv.fadeout;
        
m_dpv.spinupsav m_dpv.spinup;
        
m_dpv.spindownsav m_dpv.spindown;
    }

    
m_dpv.fadein m_dpv.fadeinsav;
    
m_dpv.fadeout 0
    
    if (
m_dpv.fadein)
        
m_dpv.vol m_dpv.volstart;
    else
        
m_dpv.vol m_dpv.volrun;

    
m_dpv.spinup m_dpv.spinupsav;
    
m_dpv.spindown 0

    if (
m_dpv.spinup)
        
m_dpv.pitch m_dpv.pitchstart;
    else
        
m_dpv.pitch m_dpv.pitchrun;

    if (
m_dpv.pitch == 0)
        
m_dpv.pitch PITCH_NORM;

    
m_dpv.pitchfrac m_dpv.pitch << 8;
    
m_dpv.volfrac m_dpv.vol << 8;

    
m_dpv.lfofrac 0;
    
m_dpv.lforate abs(m_dpv.lforate);

    
m_dpv.cspincount 1;
    
    if (
m_dpv.cspinup
    {
        
pitchinc = (255 m_dpv.pitchstart) / m_dpv.cspinup;

        
m_dpv.pitchrun m_dpv.pitchstart pitchinc;
        if (
m_dpv.pitchrun 255m_dpv.pitchrun 255;
    }

    if ((
m_dpv.spinupsav || m_dpv.spindownsav || (m_dpv.lfotype && m_dpv.lfomodpitch))
        && (
m_dpv.pitch == PITCH_NORM))
        
m_dpv.pitch PITCH_NORM 1// must never send 'no pitch' as first pitch
                                      // if we intend to pitch shift later!
}

//
// ToggleUse - turns an ambient sound on or off.  If the 
// ambient is a looping sound, mark sound as active (m_fActive)
// if it's playing, innactive if not.  If the sound is not
// a looping sound, never mark it as active.
//
void CAmbientGeneric :: ToggleUse CBaseEntity *pActivatorCBaseEntity *pCallerUSE_TYPE useTypefloat value )
{
    
charszSoundFile = (char*) STRING(pev->message);
    
float fraction;

    if ( 
useType != USE_TOGGLE )
    {
        if ( (
m_fActive && useType == USE_ON) || (!m_fActive && useType == USE_OFF) )
            return;
    }
    
// Directly change pitch if arg passed. Only works if sound is already playing.

    
if (useType == USE_SET && m_fActive)        // Momentary buttons will pass down a float in here
    
{

        
fraction value;
        
        if ( 
fraction 1.0 )
            
fraction 1.0;
        if (
fraction 0.0)
            
fraction 0.01;

        
m_dpv.pitch fraction 255;

        
UTIL_EmitAmbientSound(ENT(pev), pev->originszSoundFile
                    
00SND_CHANGE_PITCHm_dpv.pitch);

        return;
    }

    
// Toggle

    // m_fActive is TRUE only if a looping sound is playing.
    
    
if ( m_fActive )
    {
// turn sound off

        
if (m_dpv.cspinup)
        {
            
// Don't actually shut off. Each toggle causes
            // incremental spinup to max pitch

            
if (m_dpv.cspincount <= m_dpv.cspinup)
            {    
                
int pitchinc;

                
// start a new spinup
                
m_dpv.cspincount++;
                
                
pitchinc = (255 m_dpv.pitchstart) / m_dpv.cspinup;

                
m_dpv.spinup m_dpv.spinupsav;
                
m_dpv.spindown 0;

                
m_dpv.pitchrun m_dpv.pitchstart pitchinc m_dpv.cspincount;
                if (
m_dpv.pitchrun 255m_dpv.pitchrun 255;

                
pev->nextthink gpGlobals->time 0.1;
            }
            
        }
        else
        {
            
m_fActive FALSE;
            
            
// HACKHACK - this makes the code in Precache() work properly after a save/restore
            
pev->spawnflags |= AMBIENT_SOUND_START_SILENT;

            if (
m_dpv.spindownsav || m_dpv.fadeoutsav)
            {
                
// spin it down (or fade it) before shutoff if spindown is set
                
m_dpv.spindown m_dpv.spindownsav;
                
m_dpv.spinup 0;

                
m_dpv.fadeout m_dpv.fadeoutsav;
                
m_dpv.fadein 0;
                
pev->nextthink gpGlobals->time 0.1;
            }
            else
                
UTIL_EmitAmbientSound(ENT(pev), pev->originszSoundFile
                    
00SND_STOP0);
        }
    }
    else 
    {
// turn sound on

        // only toggle if this is a looping sound.  If not looping, each
        // trigger will cause the sound to play.  If the sound is still
        // playing from a previous trigger press, it will be shut off
        // and then restarted.

        
if (m_fLooping)
            
m_fActive TRUE;
        else
            
// shut sound off now - may be interrupting a long non-looping sound
            
UTIL_EmitAmbientSound(ENT(pev), pev->originszSoundFile
                
00SND_STOP0);
            
        
// init all ramp params for startup

        
InitModulationParms();

        
UTIL_EmitAmbientSound(ENT(pev), pev->originszSoundFile
                (
m_dpv.vol 0.01), m_flAttenuation0m_dpv.pitch);
        
        
pev->nextthink gpGlobals->time 0.1;

    } 
}
// KeyValue - load keyvalue pairs into member data of the
// ambient generic. NOTE: called BEFORE spawn!

void CAmbientGeneric :: KeyValueKeyValueData *pkvd )
{
    
// NOTE: changing any of the modifiers in this code
    // NOTE: also requires changing InitModulationParms code.

    // preset
    
if (FStrEq(pkvd->szKeyName"preset"))
    {
        
m_dpv.preset atoi(pkvd->szValue);
        
pkvd->fHandled TRUE;
    }

    
// pitchrun
    
else if (FStrEq(pkvd->szKeyName"pitch"))
    {
        
m_dpv.pitchrun atoi(pkvd->szValue);
        
pkvd->fHandled TRUE;
        
        if (
m_dpv.pitchrun 255m_dpv.pitchrun 255;
        if (
m_dpv.pitchrun 0m_dpv.pitchrun 0;
    }        

    
// pitchstart
    
else if (FStrEq(pkvd->szKeyName"pitchstart"))
    {
        
m_dpv.pitchstart atoi(pkvd->szValue);
        
pkvd->fHandled TRUE;        
        
        if (
m_dpv.pitchstart 255m_dpv.pitchstart 255;
        if (
m_dpv.pitchstart 0m_dpv.pitchstart 0;
    }

    
// spinup
    
else if (FStrEq(pkvd->szKeyName"spinup"))
    {
        
m_dpv.spinup atoi(pkvd->szValue);
        
        if (
m_dpv.spinup 100m_dpv.spinup 100;
        if (
m_dpv.spinup 0m_dpv.spinup 0;

        if (
m_dpv.spinup 0)
            
m_dpv.spinup = (101 m_dpv.spinup) * 64;
        
m_dpv.spinupsav m_dpv.spinup;
        
pkvd->fHandled TRUE;
    }        

    
// spindown
    
else if (FStrEq(pkvd->szKeyName"spindown"))
    {
        
m_dpv.spindown atoi(pkvd->szValue);
        
        if (
m_dpv.spindown 100m_dpv.spindown 100;
        if (
m_dpv.spindown 0m_dpv.spindown 0;

        if (
m_dpv.spindown 0)
            
m_dpv.spindown = (101 m_dpv.spindown) * 64;
        
m_dpv.spindownsav m_dpv.spindown;
        
pkvd->fHandled TRUE;
    }

    
// volstart
    
else if (FStrEq(pkvd->szKeyName"volstart"))
    {
        
m_dpv.volstart atoi(pkvd->szValue);

        if (
m_dpv.volstart 10m_dpv.volstart 10;
        if (
m_dpv.volstart 0m_dpv.volstart 0;
        
        
m_dpv.volstart *= 10;    // 0 - 100

        
pkvd->fHandled TRUE;
    }

    
// fadein
    
else if (FStrEq(pkvd->szKeyName"fadein"))
    {
        
m_dpv.fadein atoi(pkvd->szValue);
        
        if (
m_dpv.fadein 100m_dpv.fadein 100;
        if (
m_dpv.fadein 0m_dpv.fadein 0;

        if (
m_dpv.fadein 0)
            
m_dpv.fadein = (101 m_dpv.fadein) * 64;
        
m_dpv.fadeinsav m_dpv.fadein;
        
pkvd->fHandled TRUE;
    }

    
// fadeout
    
else if (FStrEq(pkvd->szKeyName"fadeout"))
    {
        
m_dpv.fadeout atoi(pkvd->szValue);
        
        if (
m_dpv.fadeout 100m_dpv.fadeout 100;
        if (
m_dpv.fadeout 0m_dpv.fadeout 0;

        if (
m_dpv.fadeout 0)
            
m_dpv.fadeout = (101 m_dpv.fadeout) * 64;
        
m_dpv.fadeoutsav m_dpv.fadeout;
        
pkvd->fHandled TRUE;
    }

    
// lfotype
    
else if (FStrEq(pkvd->szKeyName"lfotype"))
    {
        
m_dpv.lfotype atoi(pkvd->szValue);
        if (
m_dpv.lfotype 4m_dpv.lfotype LFO_TRIANGLE;
        
pkvd->fHandled TRUE;
    }

    
// lforate
    
else if (FStrEq(pkvd->szKeyName"lforate"))
    {
        
m_dpv.lforate atoi(pkvd->szValue);
        
        if (
m_dpv.lforate 1000m_dpv.lforate 1000;
        if (
m_dpv.lforate 0m_dpv.lforate 0;

        
m_dpv.lforate *= 256;

        
pkvd->fHandled TRUE;
    }
    
// lfomodpitch
    
else if (FStrEq(pkvd->szKeyName"lfomodpitch"))
    {
        
m_dpv.lfomodpitch atoi(pkvd->szValue);
        if (
m_dpv.lfomodpitch 100m_dpv.lfomodpitch 100;
        if (
m_dpv.lfomodpitch 0m_dpv.lfomodpitch 0;
        

        
pkvd->fHandled TRUE;
    }

    
// lfomodvol
    
else if (FStrEq(pkvd->szKeyName"lfomodvol"))
    {
        
m_dpv.lfomodvol atoi(pkvd->szValue);
        if (
m_dpv.lfomodvol 100m_dpv.lfomodvol 100;
        if (
m_dpv.lfomodvol 0m_dpv.lfomodvol 0;

        
pkvd->fHandled TRUE;
    }

    
// cspinup
    
else if (FStrEq(pkvd->szKeyName"cspinup"))
    {
        
m_dpv.cspinup atoi(pkvd->szValue);
        if (
m_dpv.cspinup 100m_dpv.cspinup 100;
        if (
m_dpv.cspinup 0m_dpv.cspinup 0;

        
pkvd->fHandled TRUE;
    }
    else
        
CBaseEntity::KeyValuepkvd );

Attached Files
File Type: zip sound.cpp.zip (14.0 KB, 140 views)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-03-2009 at 12:38.
ConnorMcLeod is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-03-2009 , 12:38   Re: Ambience Sound what heard everywhere
Reply With Quote #6

and how can i use it? i'm too stupid to understand such code o.O'
__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-03-2009 , 12:42   Re: Ambience Sound what heard everywhere
Reply With Quote #7

I don't see the purpose to copy paste all from HLSDK here... He want to know just about the spawn flag.

Quote:
and how can i use it? i'm too stupid to understand such code o.O'
No need to understand. Try what you have done first.
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-03-2009 , 12:49   Re: Ambience Sound what heard everywhere
Reply With Quote #8

ok tested and it worked just fine, but how i can do random precache from these sounds?
PHP Code:
new g_Ambience[] = {
    
"DayOfDefeat/dodambience1.wav",
    
"DayOfDefeat/dodambience2.wav",
    
"DayOfDefeat/dodambience3.wav",
    
"DayOfDefeat/dodambience4.wav",
    
"DayOfDefeat/dodambience5.wav",
    
"DayOfDefeat/dodambience6.wav"
}; 
i tryed like that but it dident worked
PHP Code:
new g_PreAmbience;

    
g_PreAmbience g_Ambience[random_num(0sizeof g_Ambience 1)];
    
engfunc(EngFunc_PrecacheSoundg_PreAmbience);

    
// [...]
    
set_pev(entitypev_messageg_PreAmbience); 
__________________
xPaw is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-03-2009 , 13:04   Re: Ambience Sound what heard everywhere
Reply With Quote #9

He may find usefull keys for KeyValue, or other infos.

Quote:
Originally Posted by xPaw View Post
PHP Code:
new g_PreAmbience;

    
g_PreAmbience random_num(0sizeof g_Ambience 1);
    
precache_sound(g_Ambience[g_PreAmbience])

    
// [...]
    
set_pev(entitypev_messageg_Ambience[g_PreAmbience]); 
Use precache_sound is better.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-03-2009 at 13:06.
ConnorMcLeod is offline
FakeNick
Senior Member
Join Date: Feb 2008
Location: Poland
Old 01-03-2009 , 13:13   Re: Ambience Sound what heard everywhere
Reply With Quote #10

Maybe something like this ? ;)

PHP Code:

#include <amxmodx>
#include <fakemeta>

const OFFSET_AMBIENCE = (1<<0)

new const 
VERSION[] = "1.0"

new g_ambience[][] = { "amb/amb.wav","amb/amb2.wav" }

public 
plugin_init()
{
    
register_plugin("Ambience"VERSION"FakeNick")
}
public 
plugin_precache()
{
    for(new 
0sizeof g_ambiencei++)
        
engfunc(EngFunc_PrecacheSound,g_ambience[i])
    
    new 
entity engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"ambient_generic"))
    
set_pev(entitypev_health10.0)
    
set_pev(entitypev_messageg_ambience[random_num(0,sizeof g_ambience 1)])
    
set_pev(entitypev_spawnflagsOFFSET_AMBIENCE)
    
dllfunc(DLLFunc_Spawnentity)

__________________


[||||||||||] Snowball war v3.05

Pol
ish translations here ;) (PM me if you want one).


FakeNick is offline
Reply


Thread Tools
Display Modes

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 09:14.


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