Raised This Month: $51 Target: $400
 12% 

How to make every Knife class have different sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
king999
Member
Join Date: Feb 2015
Location: Mars
Old 02-28-2015 , 18:29   How to make every Knife class have different sound
Reply With Quote #1

How to make every Knife class have different sound
hi you guys may know about my project i am making VIP menu
and the problem is there are 2 knifes
hammer
and axe
when hammer sounds work
they work for both
and when i add
Code:
public fw_emitsound(id, channel, const sound[])
{
if(!is_user_alive(id)|| get_user_weapon(id) != CSW_KNIFE || !g_knife_cclass[id] == WOLF)
	return FMRES_IGNORED
	
	for(new i = 0; i < sizeof oldknife_sounds; i++)
	{
		if(equal(sound, oldknife_sounds[i]))
		{
			emit_sound(id, channel, knife_sounds[i], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
			
			return FMRES_SUPERCEDE
		}
	}
	
	return FMRES_IGNORED
}
twice it still dont work how to make every class have different sounds

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fun>
#include <hamsandwich>
#include <nvault>
#include <fakemeta>
#include <dhudmessage>
#include <fakemeta_util> 

#define r random_num(1,255)
#define g random_num(1,255)
#define b random_num(1,255)
#define is_true_player(%1) (1 <= %1 <= 32)
new g_knife_cclass[33]
enum
{
WOLF
AXE
}
new const oldknife_sounds[][] =
{
"weapons/knife_deploy1.wav",
"weapons/knife_hit1.wav",
"weapons/knife_hit2.wav",
"weapons/knife_hit3.wav",
"weapons/knife_hit4.wav",
"weapons/knife_hitwall1.wav",
"weapons/knife_stab.wav"
}

new const knife_sounds[][] =
{
"weapons/ham_draw.wav",
"weapons/ham_hit_01.wav",
"weapons/ham_hit_02.wav",
"weapons/ham_hit_01.wav",
"weapons/ham_hit_02.wav",
"weapons/ham_miss.wav",
"weapons/ham_stb.wav"
}

new const knife_soundsaxe[][] =
{
"weapons/ha_draw.wav",
"weapons/ha_attack_01.wav",
"weapons/ha_attack_02.wav",
"weapons/ha_attack_01.wav",
"weapons/ha_attack_02.wav",
"weapons/ha_miss_wall_01.wav",
"weapons/ha_stb.wav"
}
new const VIP_ACCESS = ADMIN_LEVEL_H 
new gMsgScreenFade
public plugin_init()
{
RegisterHam(Ham_TakeDamage, "player", "fwdTakeDamage", 0)
register_clcmd("say /hammer", "work", _, "");
gMsgScreenFade = get_user_msgid("ScreenFade");
register_forward(FM_EmitSound, "fw_emitsound")
register_forward(FM_EmitSound, "fw_emitsound1")
}
public plugin_precache()
{
precache_model("models/mega/v_hamaxe.mdl")
precache_model("models/mega/p_hamaxe.mdl")
for(new i;i<sizeof knife_sounds;i++)
precache_sound(knife_sounds[i])
for(new a;a<sizeof knife_soundsaxe;a++)
precache_sound(knife_soundsaxe[a])
} 

public fw_emitsound(id, channel, const sound[])
{
if(!is_user_alive(id)|| get_user_weapon(id) != CSW_KNIFE || !g_knife_cclass[id] == WOLF)
	return FMRES_IGNORED
	
	for(new i = 0; i < sizeof oldknife_sounds; i++)
	{
		if(equal(sound, oldknife_sounds[i]))
		{
			emit_sound(id, channel, knife_sounds[i], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
			
			return FMRES_SUPERCEDE
		}
	}
	
	return FMRES_IGNORED
}
public work(id)
{
g_knife_cclass[id] = WOLF
ham_strip_weapon(id, "weapon_knife");
give_item(id, "weapon_knife")
if(get_user_flags(id) & VIP_ACCESS) 
	entity_set_string(id, EV_SZ_viewmodel, "models/mega/chucky_knife.mdl")
	entity_set_string(id, EV_SZ_weaponmodel, "models/mega/chucky_knife1.mdl")
	set_task(20.0,"Remove1",id)
	
}
public Remove1(id) 
{
	cs_reset_user_model(id)
	set_user_rendering(id, _, 0, 0, 0, _, 0)
	set_user_gravity( id, 1.0 )
	set_user_noclip(id)
	set_dhudmessage(r, g, b, -1.0, 0.22, 1, 5.0, 0.1, 0.2, 0.9, true)
	show_dhudmessage(id,"GAME OVER Hammer no MORE")
}
public fwdTakeDamage(victim, inflictor, attacker, Float:damage, damage_bits)
{
	if(is_true_player(attacker) && get_user_weapon(attacker) == CSW_KNIFE && g_knife_cclass[attacker] == WOLF && victim != attacker)	
	{
		SetHamParamFloat(4, 150.0)
	}
}
stock ham_strip_weapon(id,weapon[])
{
	if(!equal(weapon,"weapon_",7)) return 0;
	
	new wId = get_weaponid(weapon);
	if(!wId) return 0;
	
	new wEnt;
	while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
	if(!wEnt) return 0;
	
	if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
	
	if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
	ExecuteHamB(Ham_Item_Kill,wEnt);
	
	set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
	
	return 1;
}
king999 is offline
Send a message via Skype™ to king999
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-28-2015 , 19:23   Re: How to make every Knife class have different sound
Reply With Quote #2

I recommend reading a few scripting tutorials and looking over some existing plugins to get a better understanding of how to script. There are plenty of people to assist you with any questions you may come up with.

Try this: Remove knife_sounds and knife_soundsaxe arrays and replace with:
PHP Code:
new const knife_sounds[][] =
{
    { 
"weapons/ham_draw.wav"   "weapons/ha_draw.wav" },
    { 
"weapons/ham_hit_01.wav" "weapons/ha_attack_01.wav" },
    { 
"weapons/ham_hit_02.wav" "weapons/ha_attack_02.wav" },
    { 
"weapons/ham_hit_01.wav" "weapons/ha_attack_01.wav" },
    { 
"weapons/ham_hit_02.wav" "weapons/ha_attack_02.wav" },
    { 
"weapons/ham_miss.wav"   "weapons/ha_miss_wall_01.wav" },
    { 
"weapons/ham_stb.wav"    "weapons/ha_stb.wav" }
}; 
Then change
PHP Code:
emit_sound(idchannelknife_sounds[i], VOL_NORMATTN_NORM0PITCH_NORM)
//   to 
emit_sound(idchannelknife_sounds[i][ g_knife_cclassid ] ], VOL_NORMATTN_NORM0PITCH_NORM
You also need to make sure you are setting the player to the AXE mode. You are only setting to WOLF currently with this: g_knife_cclass[id] = WOLF. You will not get the alternate sound unless he is set to AXE.

Your code needs a lot of work that I don't have time to fix. This needs fixing too:
PHP Code:
if( !is_user_alive(id) || get_user_weapon(id) != CSW_KNIFE || g_knife_cclass[id] != WOLF 
__________________

Last edited by Bugsy; 02-28-2015 at 19:24.
Bugsy is offline
king999
Member
Join Date: Feb 2015
Location: Mars
Old 02-28-2015 , 19:30   Re: How to make every Knife class have different sound
Reply With Quote #3

but bugsy brow you are always helping me man thanks alot i am not lieing nobody help me here
but you always thanks alot brow
you rock
brow but 1 thing
i didnt get
emit_sound(id, channel, knife_sounds[i][ g_knife_cclass[ id ] ], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

Last edited by king999; 02-28-2015 at 19:33.
king999 is offline
Send a message via Skype™ to king999
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-28-2015 , 19:36   Re: How to make every Knife class have different sound
Reply With Quote #4

Quote:
Originally Posted by king999 View Post
but bugsy brow you are always helping me man thanks alot i am not lieing nobody help me here
but you always thanks alot brow
you rock
brow but 1 thing
i didnt get
emit_sound(id, channel, knife_sounds[i][ g_knife_cclass[ id ] ], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
emit_sound(id, channel, knife_sounds[i][ g_knife_cclass[ id ] ], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

g_knife_cclass[ id ] holds the knife type (WOLF or AXE). WOLF=0, AXE=1 per enum definition. That array I posted is a 3-dimension array. Index 1 is the index in the list, index 2 is WOLF or AXE, index 3 is the string itself. This is why I recommend reading some tutorials and not depending on others to script for you. You need to grasp these simple concepts if you want to make something on your own.
__________________
Bugsy is offline
king999
Member
Join Date: Feb 2015
Location: Mars
Old 02-28-2015 , 19:40   Re: How to make every Knife class have different sound
Reply With Quote #5

ho ok
also brow thanks man you always give me your time
i am new scripter

Last edited by king999; 02-28-2015 at 19:40.
king999 is offline
Send a message via Skype™ to king999
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-28-2015 , 19:41   Re: How to make every Knife class have different sound
Reply With Quote #6

It's no problem, everyone starts somewhere but you need to put some effort into learning.
__________________
Bugsy is offline
king999
Member
Join Date: Feb 2015
Location: Mars
Old 02-28-2015 , 19:43   Re: How to make every Knife class have different sound
Reply With Quote #7

brow sorry to say its nto working its giving same sounds for both
king999 is offline
Send a message via Skype™ to king999
Old 02-28-2015, 19:45
king999
This message has been deleted by hornet. Reason: Please use the edit button
Old 02-28-2015, 19:47
king999
This message has been deleted by hornet. Reason: Please use the edit button
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 02-28-2015 , 19:47   Re: How to make every Knife class have different sound
Reply With Quote #8

Quote:
Originally Posted by king999 View Post
brow check pm please i sent you the real codes that is my VIP
please
You should get used to posting your real code here if you want to get help. After all this is a public help forum.
hornet is offline
king999
Member
Join Date: Feb 2015
Location: Mars
Old 02-28-2015 , 19:49   Re: How to make every Knife class have different sound
Reply With Quote #9

brow hornet i didnt know that
king999 is offline
Send a message via Skype™ to king999
king999
Member
Join Date: Feb 2015
Location: Mars
Old 02-28-2015 , 19:50   Re: How to make every Knife class have different sound
Reply With Quote #10

ok brow bugsy the code is giving
the sounds for both knifes the same
king999 is offline
Send a message via Skype™ to king999
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 23:06.


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