AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Change footsteps sound, possible? (https://forums.alliedmods.net/showthread.php?t=77181)

Sn!ff3r 09-07-2008 04:09

Change footsteps sound, possible?
 
Hi, short question:

how to change footstep sounds (if this is possible) ?

Alka 09-07-2008 04:18

Re: Change footsteps sound, possible?
 
No.But you can make block original sound, then make a fake ent and emit custom sound with a delay(time between steps).

Sn!ff3r 09-07-2008 04:29

Re: Change footsteps sound, possible?
 
Quote:

No.But you can make block original sound, then make a fake ent and emit custom sound with a delay(time between steps).
Oh yeah :>

Maybe small example :] ?

Alka 09-07-2008 04:48

Re: Change footsteps sound, possible?
 
Code:
#include <amxmodx> #include <fakemeta>   #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Alka"   #define STEP_DELAY 0.5   new Float:g_fNextStep[33];   new const g_szStepSound[] = "custom_step_sound.wav";   public plugin_init() {    register_plugin(PLUGIN, VERSION, AUTHOR);    register_forward(FM_PlayerPreThink, "fwd_PlayerPreThink", 0); }   public plugin_precache()  precache_sound(g_szStepSound);   public fwd_PlayerPreThink(id) {  if(!is_user_alive(id))   return FMRES_IGNORED;    set_pev(id, pev_flTimeStepSound, 999);    if(g_fNextStep[id] < get_gametime())  {   if(fm_get_ent_speed(id) && (pev(id, pev_flags) & FL_ONGROUND))    emit_sound(id, CHAN_BODY, g_szStepSound, VOL_NORM, ATTN_STATIC, 0, PITCH_NORM);     g_fNextStep[id] = get_gametime() + STEP_DELAY;  }  return FMRES_IGNORED; }   stock Float:fm_get_ent_speed(id) {  if(!pev_valid(id))   return 0.0;    static Float:vVelocity[3];  pev(id, pev_velocity, vVelocity);    vVelocity[2] = 0.0;    return vector_length(vVelocity); }

TSuNaMi_ 05-28-2010 15:32

Re: Change footsteps sound, possible?
 
but there is 4 steps ??

Alka 05-28-2010 17:04

Re: Change footsteps sound, possible?
 
what 4 steps? This should block any footstep sounds.

TSuNaMi_ 05-28-2010 17:11

Re: Change footsteps sound, possible?
 
you look to into:

sound/players/ and you will see:

pl_step1.wav
pl_step2.wav
pl_step3.wav
pl_step4.wav

Alka 05-28-2010 17:13

Re: Change footsteps sound, possible?
 
Yest, they are played random...you can modify the array to 2D size, then put more custom sounds, and into emit_sound native, make it play a random step sound.

PHP Code:

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Alka"

#define STEP_DELAY 0.5

new Float:g_fNextStep[33];

#define MAX_SOUNDS 4 //Max num of sound for list below

new const g_szStepSound[MAX_SOUNDS][] = {
    
    
"custom_step_sound#1.wav",
    
"custom_step_sound#2.wav",
    
"custom_step_sound#3.wav",
    
"custom_step_sound#4.wav"
};

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_forward(FM_PlayerPreThink"fwd_PlayerPreThink"0);
}

public 
plugin_precache()
{
    new 
i;
    for(
0MAX_SOUNDS i++)
        
precache_sound(g_szStepSound[i]);
}

public 
fwd_PlayerPreThink(id)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;
    
    
set_pev(idpev_flTimeStepSound999);
    
    if(
g_fNextStep[id] < get_gametime())
    {
        if(
fm_get_ent_speed(id) && (pev(idpev_flags) & FL_ONGROUND))
            
emit_sound(idCHAN_BODYg_szStepSound[random(MAX_SOUNDS)], VOL_NORMATTN_STATIC0PITCH_NORM);
        
        
g_fNextStep[id] = get_gametime() + STEP_DELAY;
    }
    return 
FMRES_IGNORED;
}

stock Float:fm_get_ent_speed(id)
{
    if(!
pev_valid(id))
        return 
0.0;
    
    static 
Float:vVelocity[3];
    
pev(idpev_velocityvVelocity);
    
    
vVelocity[2] = 0.0;
    
    return 
vector_length(vVelocity);



TSuNaMi_ 05-28-2010 17:15

Re: Change footsteps sound, possible?
 
i did it but sounds coming to mix to players.

TSuNaMi_ 05-28-2010 17:22

Re: Change footsteps sound, possible?
 
oke thanks i will try now.


All times are GMT -4. The time now is 03:08.

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