Raised This Month: $ Target: $400
 0% 

[SOLVED] Emit sound with Ham_TakeDamage?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-23-2017 , 18:03   [SOLVED] Emit sound with Ham_TakeDamage?
Reply With Quote #1

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;
}
__________________









Last edited by CrazY.; 03-07-2017 at 08:53.
CrazY. is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-23-2017 , 18:14   Re: [HELP] Emit sound with Ham_TakeDamage?
Reply With Quote #2

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.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 02-23-2017 at 18:16.
EFFx is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-23-2017 , 18:22   Re: [HELP] Emit sound with Ham_TakeDamage?
Reply With Quote #3

[PT-BR]
Código corrigido, haha'. Ok, vou tentar verificar.

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








CrazY. is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 02-23-2017 , 20:44   Re: [HELP] Emit sound with Ham_TakeDamage?
Reply With Quote #4

You also should check for attacker == inflictor, because damage can be done via grenade.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 02-24-2017 , 07:27   Re: [HELP] Emit sound with Ham_TakeDamage?
Reply With Quote #5

Remove get_user_weapon check.
There's multiple sounds because you never blocked the other sounds.
__________________
edon1337 is offline
killerZM
Senior Member
Join Date: Sep 2016
Old 02-24-2017 , 09:42   Re: [HELP] Emit sound with Ham_TakeDamage?
Reply With Quote #6

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
killerZM is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 02-24-2017 , 09:43   Re: [HELP] Emit sound with Ham_TakeDamage?
Reply With Quote #7

Quote:
Originally Posted by killerZM View Post
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.
__________________
edon1337 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 03-07-2017 , 08:52   Re: [HELP] Emit sound with Ham_TakeDamage?
Reply With Quote #8

Solved. Just use forward update client data..
__________________








CrazY. is offline
Reply



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 20:41.


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