RH_SV_StartSound Problem

Сообщения
278
Реакции
137
Hey everybody,
I was trying something and I got a problem. I couldn't block sound or change. What is wrong with that?

rh_emit_sound2 is working but the original stepsound keeps playing. And also I tried to make flVolume 0.0, didn't work. Why SetHookChainArg doesn't work and also HC_SUPERCEDE?

Код:
new const soundfile[] = "try/try.wav";  //sound/try/try.wav
RegisterHookChain(RH_SV_StartSound, "@SV_StartSound", .post = false);

@SV_StartSound(const iRecipients, const iEntity, const iChannel, const szSample[], const flVolume, Float:flAttenuation, const fFlags, const iPitch) {
    switch(szSample[10]) {
        case 's': {
            //player/pl_step
            rh_emit_sound2(iEntity, iEntity, CHAN_BODY, soundfile, VOL_NORM, ATTN_STATIC, 0, PITCH_NORM);
            SetHookChainArg(4, ATYPE_STRING, soundfile);
            return HC_SUPERCEDE;
        }
        case 'w': {
            //player/pl_wade
            SetHookChainArg(5, ATYPE_INTEGER, 0);
        }
    }
    return HC_CONTINUE;
}
Even it's not working.
Код:
@SV_StartSound(const iRecipients, const iEntity, const iChannel, const szSample[], const flVolume, Float:flAttenuation, const fFlags, const iPitch) {
         return HC_SUPERCEDE;
}
 
Последнее редактирование:
Сообщения
28
Реакции
183
Помог
1 раз(а)
How about blocking pl_wade1-2-3-4.wav sounds or any sounds in StartSound public? Why Supercede does not work? All of these is client-side?
The client has a movement prediction code, these sounds will be played on client-side only for him.
Using StartSound these sounds pl_* that coming from other players can still be blocked for recipients, but not for invoker.
 
Сообщения
278
Реакции
137
Everything is OK now, thank you.
 
Последнее редактирование:
Сообщения
278
Реакции
137
I think everything is not alright. Stepsound is working well but sounds cause a lot of trouble. I hear all stepsounds except me several times per second.
For example;

Sound = T
My step sound I hear T---T---T---T
My step sound They hear TTTTTTTTTT

Код:
new Float:g_flNextSoundTime[MAX_CLIENTS + 1];

@SV_StartSound(const iRecipients, const iEntity, const iChannel, const szSample[], const flVolume, Float:flAttenuation, const fFlags, const iPitch) {
    if(!is_user_alive(iEntity) || !iRecipients || szSample[10] != 's') {
        return;
    }

    if(g_flNextSoundTime[iEntity] > get_gametime()) {
        return;
    }

    g_flNextSoundTime[iEntity] = get_gametime() + 0.3;

    rh_emit_sound2(iEntity, iEntity, CHAN_BODY, stepsound, 0.5, ATTN_STATIC, 0, PITCH_NORM);
}
 
Последнее редактирование:
Сообщения
24
Реакции
0
C++:
#include <amxmodx>
#include <fakemeta>

new Float:fG_NextTime[33];

new const sG_StepSounds[][] = {
    "csgo_footstep2/normal1.wav",
    "csgo_footstep2/normal2.wav",
    "csgo_footstep2/normal3.wav",
    "csgo_footstep2/normal4.wav",
    "csgo_footstep2/toprak1.wav",
    "csgo_footstep2/toprak2.wav",
    "csgo_footstep2/toprak3.wav",
    "csgo_footstep2/toprak4.wav",
    "csgo_footstep2/metal1.wav",
    "csgo_footstep2/metal2.wav",
    "csgo_footstep2/metal3.wav",
    "csgo_footstep2/metal4.wav",
    "csgo_footstep2/kar1.wav",
    "csgo_footstep2/kar2.wav",
    "csgo_footstep2/kar3.wav",
    "csgo_footstep2/kar4.wav",
    "csgo_footstep2/havalandirma1.wav",
    "csgo_footstep2/havalandirma2.wav",
    "csgo_footstep2/havalandirma3.wav",
    "csgo_footstep2/havalandirma4.wav",
    "csgo_footstep2/tahta1.wav",
    "csgo_footstep2/tahta2.wav",
    "csgo_footstep2/tahta3.wav",
    "csgo_footstep2/tahta4.wav"
};
public plugin_precache(){
    for(new i = 0; i < 24; i++){
        precache_sound(sG_StepSounds[i]);
    }
}
public plugin_init(){
    register_plugin
    ("Ayak Sesleri",
    "1.3",
    "Berk");
   
    register_forward(FM_PlayerPreThink,"pPreThink",0);
}
public pPreThink(iP_ID){
    if(!is_user_alive(iP_ID))
        return FMRES_IGNORED;
    set_pev(iP_ID,pev_flTimeStepSound,999);  
    new Float:fL_GameTime = get_gametime();
   
    if(fL_GameTime > fG_NextTime[iP_ID]){
        new Float:fL_Velo[3],Float:fL_Speed,iL_Flags = pev(iP_ID, pev_flags);
        pev(iP_ID,pev_velocity,fL_Velo);
        fL_Speed = vector_length(fL_Velo);
        if(fL_Speed > 190 && (iL_Flags & FL_ONGROUND)){
            new Float:fL_Start[3],Float:fL_End[3],sL_Texture[46],iL_TextureType,iL_Choosen;
            pev(iP_ID, pev_origin,fL_Start);
            fL_Start[2] -= 30;
            fL_End[0] = fL_Start[0]
            fL_End[1] = fL_Start[1];
            fL_End[2] = fL_Start[2]-10;
            engfunc(EngFunc_TraceTexture,0,fL_Start,fL_End,sL_Texture,45);
            iL_TextureType = dllfunc(DLLFunc_PM_FindTextureType,sL_Texture);
            switch(iL_TextureType){
                case 68 : { // Toprak
                    iL_Choosen = random_num(4,7);
                }
                case 77 : { // Metal
                    iL_Choosen = random_num(8,11);
                }
                case 78 : { // Kar
                    iL_Choosen = random_num(12,15);
                }
                case 86 : { // Havalandirma
                    iL_Choosen = random_num(16,19);
                }
                case 87 : { // Tahta
                    iL_Choosen = random_num(20,23);
                }
                default : { // Diđer
                    iL_Choosen = random_num(0,3)
                }
            }
            emit_sound(iP_ID,CHAN_BODY,sG_StepSounds[iL_Choosen],VOL_NORM,ATTN_STATIC,0,PITCH_NORM);
            fG_NextTime[iP_ID] = fL_GameTime+0.3;
        }
    }
    return FMRES_IGNORED;
}
not using regamedll, works.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу