AlliedModders

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

Voi 08-29-2008 14:41

delaying a sound
 
i want to daley custom sound from vens plugin hostage voices:

Code:

public forward_emit_sound(ent, channel, const sample[], Float:volume, Float:attenuation, flags, pitch) {
    static mode
    mode = get_pcvar_num(g_pcvar_mode)
    // if plugin is disabled or entity isn't valid do not go further
    if (!mode || !pev_valid(ent))
        return FMRES_IGNORED

    static bool:is_headshot
    is_headshot = false
    // if it's a headshot sound
    if (equali(sample, g_headshot_sound_prefix, sizeof g_headshot_sound_prefix - 1)) {
        is_headshot = true

        // if custom voice on headshot feature is disbaled do not go further
        if (mode < 2)
            return FMRES_IGNORED
    }

    // if "disable hostage voices" mode is enabled
    if (mode < 0) {
        if (is_headshot)
            return FMRES_IGNORED

        static classname[32]
        pev(ent, pev_classname, classname, sizeof classname - 1)
        static hostage_entity[] = "hostage_entity"
        // if it's a hostage
        if (equal(classname, hostage_entity))
            // disable hostage voice
            return FMRES_SUPERCEDE
    }
        static i
    // if it isn't one of the custom hostages do not go further
    if ((i = get_hostageent_arrayelem_index(ent)) == -1)
        return FMRES_IGNORED

    static loaded_phrases_num
    // if no loaded phrases for this hostage do not go further
    if ((loaded_phrases_num = g_loaded_phrases_num[i]) == 0)
        return FMRES_IGNORED

    static j
    // retrieve a random phrase index
    j = random(loaded_phrases_num)

    static phrase_start_char
    phrase_start_char = g_hostages_phrases[i][j][0]
    // if empty phrase
    if (phrase_start_char == '^0')
        // disable hostage voice
        return FMRES_SUPERCEDE
    else if (phrase_start_char == '*')
        // allow original hostage voice
        return FMRES_IGNORED

    new params[7]
    params[0]=channel
    params[1]=g_hostages_phrases[i][j]
    params[2]=volume
    params[3]=attenuation
    params[4]=flags
    params[5]=pitch
    params[6]=ent
    set_task(0.1, "gadaj", 6666+ent, params, 6)

    // supercede original voice
    return FMRES_SUPERCEDE
}

public gadaj(params[])
{
   

    // emit our custom voice
    engfunc(EngFunc_EmitSound, params[6], params[0], params[1], params[2], params[3], params[4], params[5])

}

params[1]=g_hostages_phrases[i][j]

gives me Error: Must be assigned to an array on line 185

how to correct it ?

anakin_cstrike 08-29-2008 15:36

Re: delaying a sound
 
You must make a two-dimensional array.

ConnorMcLeod 08-29-2008 16:20

Re: delaying a sound
 
I think that all you have to pass is hostage id and the sound (pithc, channel, flags etc... should be the same each time so you can hardcode them).
Retrieve 'j' in the task so you don't need to pass it in set_task.
PHP Code:

    new params[2]
    
params[0]=ent
    params
[1]=i

    set_task
(0.1"gadaj"6666+entparams2)

    
// supercede original voice
    
return FMRES_SUPERCEDE
}

public 
gadaj(params[])
{
    
    new 
szSound[]
    
// here put the code to retrieve a random sound

    
engfunc(EngFunc_EmitSoundparams[0], chanszSound[], volattnflagspitch)





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

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