AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Emit sound with Ham_TakeDamage? (https://forums.alliedmods.net/showthread.php?t=294273)

CrazY. 02-23-2017 18:03

[SOLVED] Emit sound with Ham_TakeDamage?
 
Hey :D

I'm trying to change the sound when we hit the zombie with my extra item, but is not sending anything. I'm using the following code:

Code:

RegisterHam(Ham_TakeDamage, "weapon_knife", "Ham_Player_TakeDamage");

public Ham_Player_TakeDamage(victim, inflictor, attacker, Float:damage)
{
        if (!is_user_alive(attacker) || get_user_weapon(attacker) != CSW_KNIFE) return HAM_IGNORED;
       
        emit_sound(id, CHAN_WEAPON, "weapons/hit.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
        client_print(attacker, print_center, "DAMAGE!");
       
        return HAM_IGNORED;
}

Taking advantage of this topic, another problem is occurring with the Ham_Item_Deploy. I put it to emit a sound when the Player use the gun, but the sound is emitting more than once. The code is as follows:

Code:

RegisterHam(Ham_Item_Deploy, "weapon_knife", "Ham_ItemDeploy_Post", 1);

public Ham_ItemDeploy_Post(iEntity)
{
        if (!pev_valid(iEntity)) return HAM_IGNORED;
       
        new id = get_pdata_cbase(iEntity, 41, 4);
       
        if (!is_user_alive(id) || g_has_item[id]) return HAM_IGNORED;
       
        emit_sound(id, CHAN_WEAPON, "weapons/draw.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
       
        return HAM_IGNORED;
}


EFFx 02-23-2017 18:14

Re: [HELP] Emit sound with Ham_TakeDamage?
 
PHP Code:

get_user_weapon(attack

??

Vê se essa boolean tá true. Se tiver, tenta sem ela pra vê se pega.

Check if the g_has_item[id] is true. If its, try without him.


Tenta fazer debugs com os seus códigos pra vê qual pode ser o problema. Usa tudo que tiver pra descobrir ele.

Try debugs for know whats the problem with your code.

CrazY. 02-23-2017 18:22

Re: [HELP] Emit sound with Ham_TakeDamage?
 
[PT-BR]
Código corrigido, haha'. Ok, vou tentar verificar.

[EN]
Corrected code, haha. OK, I'll try to check.

PRoSToTeM@ 02-23-2017 20:44

Re: [HELP] Emit sound with Ham_TakeDamage?
 
You also should check for attacker == inflictor, because damage can be done via grenade.

edon1337 02-24-2017 07:27

Re: [HELP] Emit sound with Ham_TakeDamage?
 
Remove get_user_weapon check.
There's multiple sounds because you never blocked the other sounds.

killerZM 02-24-2017 09:42

Re: [HELP] Emit sound with Ham_TakeDamage?
 
if (!is_user_alive(id) || g_has_item[id]) return HAM_IGNORED;

==>

if (!is_user_alive(id) || !g_has_item[id]) return HAM_IGNORED;

i think

edon1337 02-24-2017 09:43

Re: [HELP] Emit sound with Ham_TakeDamage?
 
Quote:

Originally Posted by killerZM (Post 2498083)
if (!is_user_alive(id) || g_has_item[id]) return HAM_IGNORED;

==>

if (!is_user_alive(id) || !g_has_item[id]) return HAM_IGNORED;

i think

You can't state that until you've seen the full code.

CrazY. 03-07-2017 08:52

Re: [HELP] Emit sound with Ham_TakeDamage?
 
Solved. Just use forward update client data..


All times are GMT -4. The time now is 20:41.

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