Raised This Month: $ Target: $400
 0% 

Help with Knife Menu Sounds!!!


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
shadow.hk
Senior Member
Join Date: Dec 2008
Location: WA, Australia
Old 03-07-2009 , 23:13  
Reply With Quote #1

I've been using this plugin for my knife-arena server and the models seem to work fine, but some of the sounds don't work, and for no obvious reason as well. The topic on the plugin is riddled with complaints about this, and the author hasn't fixed it, so I'm presuming he doesn't know how. I was seeing if anyone else can see a problem with the script that would cause this?

PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#define TOTAL_MODELS 50
#if !defined charsmax 
 #define charsmax(%1) sizeof %1 - 1
#endif
#define ADMIN_LEVEL ADMIN_KICK
#define MODEL_PLAYER 0
#define MODEL_ADMIN 1
#define VERSION "1.5"
enum knife_sounds 
{
 
deploy,
 
hit1,
 
hit2,
 
hit3,
 
hit4,
 
hitwall,
 
slash1,
 
slash2,
 
stab
}
enum  ( += 32 )
{
 
TASK_SHOWKNIFE
}
new 
model_names[TOTAL_MODELS][32] ;
new 
v_models[TOTAL_MODELS][48] ;
new 
p_models[TOTAL_MODELS][48] ;
new 
admin_models[TOTAL_MODELS] ;
new 
modelcount=-;
new 
PlayerModel[33];
new 
model_sounds[TOTAL_MODELS][knife_sounds] ;
new 
bool:model_hassound[TOTAL_MODELS] ;
new 
default_model[2] = {-1,-1} ;
public 
plugin_init() 
{
 
register_plugin("Knife Model Mod"VERSION"Pixie") ;
 
register_event("CurWeapon","on_weaponevent","be","1=1") ;
 
register_clcmd("say /knife","on_sayknife") ;
 
register_clcmd("admin_knife","admin_giveknife",ADMIN_LEVEL,"<target> <knife index> gives a knife model to target player")
 
register_clcmd("admin_showknives","admin_showknives",ADMIN_LEVEL)
 
register_forward(FM_EmitSound,"on_emitsound")
 
register_cvar("pixie","1",FCVAR_SERVER)
 
register_cvar("pixie_knife_replacer_version",VERSION)
}
public 
plugin_precache()
{
 new 
file[400],file2[400];
 
get_configsdir(file,charsmax(file)) ;
 
get_mapname(file2,charsmax(file2))
 
format(file2,charsmax(file2),"%s/knife replacer/%s.ini",file,file2)
 if ( !
file_exists(file2) )
  
format(file2,charsmax(file2),"%s/knife replacer/knives.ini",file)
 new 
line,text[128],text2[128],;
 while ( ( 
line read_file(file2,line,text,sizeof text 1,i) ) ) 
 {
  if ( 
text[0] == '/' && text[1] == '/' 
   continue ;
  if ( 
text[0] == ';' )
   continue ;
  if ( 
text[0] == '[' )
  {
   

   while ( 
text[++i] != ']') { }
   
text[i] = ;
   
copy(model_names[++modelcount],charsmax(model_names[]),text[1])
   if ( 
containi(text[i+1],"default") )
    
default_model[containi(text[i+8],"_admin")?MODEL_PLAYER:MODEL_ADMIN] = modelcount
   
continue ;
  }
  if ( 
modelcount == -)
   continue ;
  
strtok(text,text,charsmax(text),text2,charsmax(text2),'=',1)
  if ( 
equal(text,"admin") )
  {
   
admin_models[modelcount] = str_to_num(text2)
   continue;
  }
  if ( !
file_exists(text2) )
  {
   
formatex(file,charsmax(file),"sound/%s",text2)
   if ( !
file_exists(file) )
   {
    
log_amx("[Knife Replacer]file does not exist: %s ... skipped",(contain(text2,".wav")!=-1)?file:text2)
    continue ;
   }
  }
  if ( 
equal(text,"p_model") )
  {
   
copy(p_models[modelcount],charsmax(p_models[]),text2)
   
precache_model(text2)
   continue ;
  }
  if ( 
equal(text,"v_model") )
  {
   
copy(v_models[modelcount],charsmax(v_models[]),text2)
   
precache_model(text2)
   continue ;
  }
  if ( 
equal(text,"deploy") )
  {
   
model_sounds[modelcount][deploy] = makestring(text2) ;
   
model_hassound[modelcount] = true ;
   
precache_sound(text2)
   continue ;
  }
  if ( 
equal(text,"hit1") )
  {
   
model_sounds[modelcount][hit1] = makestring(text2) ;
   
model_hassound[modelcount] = true ;
   
precache_sound(text2)
   continue ;
  }
  if ( 
equal(text,"hit2") )
  {
   
model_sounds[modelcount][hit2] = makestring(text2) ;
   
model_hassound[modelcount] = true ;
   
precache_sound(text2)
   continue ;
  }
  if ( 
equal(text,"hit3") )
  {
   
model_sounds[modelcount][hit3] = makestring(text2) ;
   
model_hassound[modelcount] = true ;
   
precache_sound(text2)
   continue ;
  }
  if ( 
equal(text,"hit4") )
  {
   
model_sounds[modelcount][hit4] = makestring(text2) ;
   
model_hassound[modelcount] = true ;
   
precache_sound(text2)
   continue ;
  }
  if ( 
equal(text,"hitwall") )
  {
   
model_sounds[modelcount][hitwall] = makestring(text2) ;
   
model_hassound[modelcount] = true ;
   
precache_sound(text2)
   continue ;
  }
  if ( 
equal(text,"slash1") )
  {
   
model_sounds[modelcount][slash1] = makestring(text2) ;
   
model_hassound[modelcount] = true ;
   
precache_sound(text2)
   continue ;
  }
  if ( 
equal(text,"slash2") )
  {
   
model_sounds[modelcount][slash2] = makestring(text2) ;
   
model_hassound[modelcount] = true ;
   
precache_sound(text2)
   continue ;
  }
  if ( 
equal(text,"stab") )
  {
   
model_sounds[modelcount][stab] = makestring(text2) ;
   
model_hassound[modelcount] = true ;
   
precache_sound(text2)
   continue ;
  }
 }
 
modelcount ++ 
}
public 
on_sayknife(id)
{
 if ( 
id TASK_SHOWKNIFE )
  
id -= TASK_SHOWKNIFE ;
 new 
menu menu_create("Knife Model","on_chooseknife")
 new 
name[52];
 if ( 
PlayerModel[id] == -)
  
menu_additem(menu,"\rNormal Knife","",0,-1)
 else
  
menu_additem(menu,"Normal Knife","",0,-1)
 for ( new 
modelcount ++ )
 {
  if ( 
PlayerModel[id] == )
  {
   
format(name,sizeof name,"\r%s",model_names[i])
   
menu_additem(menu,name,"",admin_models[i]?ADMIN_LEVEL:0,-1)
  }
  else 
  
menu_additem(menu,model_names[i],"",admin_models[i]?ADMIN_LEVEL:0,-1)
 }
 
menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)
 
menu_display(id,menu,0)
 return 
PLUGIN_HANDLED ;
}
public 
on_chooseknife(id,menu,key)
{
 
//client_print(id,print_chat,"Choice: %i",key)
 
menu_destroy(menu)
 if ( 
key != MENU_EXIT )
  
PlayerModel[id] = key ;
 else return ;
 
on_weaponevent(id)
 return ;
}
public 
admin_showknives(id,level,cid)
{
 if ( !
cmd_access(id,level,cid,1) )
  return 
PLUGIN_CONTINUE ;
 
 
console_print(id,"======================================")
 
console_print(id,"        Knife Model Listings")
 for ( new 
modelcount ++ )
 {
  
console_print(id,"%i. %s%s",i,model_names[i],admin_models[i]?"  (admin)":"")
 } 
 return 
PLUGIN_HANDLED ;
}
public 
admin_giveknife(id,level,cid)
{
 if ( !
cmd_access(id,level,cid,2) )
 {
  
log_amx("No access or bad parameters")
  return 
PLUGIN_HANDLED ;
 }
 
 new 
arg[32],target,index;
 
read_argv(1,arg,sizeof arg)
 
target cmd_target(id,arg,1)
 
 if ( 
target == )
 {
  
log_amx("Could not find/target player %s",arg)
  return 
PLUGIN_HANDLED ;
 }
 
 
read_argv(2,arg,sizeof arg)
 
index str_to_num(arg)
 
 if ( 
model_names[index][0] == )
 {
  
log_amx("Invalid model index: %i",index)
  return 
PLUGIN_HANDLED ;
 }
 
 
PlayerModel[target] = index
 on_weaponevent
(target);
 
 return 
PLUGIN_HANDLED ;
}
public 
on_weaponevent(id)
{
 if ( !
is_user_alive(id) )
  return ;
 static 
dummy ;
 if ( 
PlayerModel[id] == -)
 {
  if ( 
get_user_weapon(id,dummy,dummy) == CSW_KNIFE 
   
reset_model(id)
  return ;
 }
 if ( 
get_user_weapon(id,dummy,dummy) != CSW_KNIFE )
  return ;
 if ( 
v_models[PlayerModel[id]][0] )
  
set_pev(id,pev_viewmodel2,v_models[PlayerModel[id]])
 if ( 
p_models[PlayerModel[id]][0] )
  
set_pev(id,pev_weaponmodel2,p_models[PlayerModel[id]])
 return ;
}
reset_model(id)
{
 
set_pev(id,pev_viewmodel2,"models/v_knife.mdl")
 
set_pev(id,pev_weaponmodel2,"models/p_knife.mdl")
}
public 
client_connect(id)
{
 
PlayerModel[id] = default_model[get_user_flags(id)&ADMIN_LEVEL] -;
 
 
set_task(5.0,"on_sayknife",TASK_SHOWKNIFE+id)
}
public 
on_emitsound(const id,const channel,sound[])
{
 if ( !
is_user_connected(id) )
  return 
FMRES_IGNORED ;
 if ( 
PlayerModel[id] < )
  return 
FMRES_IGNORED ;
 if ( !( 
channel == CHAN_WEAPON || channel == CHAN_ITEM) )
  return 
FMRES_IGNORED ;
 if ( !
model_hassound[PlayerModel[id]] )
  return 
FMRES_IGNORED;
 if ( 
contain(sound,"knife") == -)
  return 
FMRES_IGNORED;
 
 new 
knife_sounds:soundtype ;
 
 if ( 
equal(sound,"weapons/knife_deploy1.wav") )
 {
  
soundtype deploy
 
}
 else if ( 
equal(sound,"weapons/knife_hit1.wav") )
 {
  
soundtype hit1
 
}
 else if ( 
equal(sound,"weapons/knife_hit2.wav") )
 {
  
soundtype hit2
 
}
 else if ( 
equal(sound,"weapons/knife_hit3.wav") )
 {
  
soundtype hit3
 
}
 else if ( 
equal(sound,"weapons/knife_hit4.wav") )
 {
  
soundtype hit4
 
}
 else if ( 
equal(sound,"weapons/knife_hitwall1.wav") )
 {
  
soundtype hitwall
 
}
 else if ( 
equal(sound,"weapons/knife_slash1.wav") )
 {
  
soundtype slash1
 
}
 else if ( 
equal(sound,"weapons/knife_slash2.wav") )
 {
  
soundtype slash2
 
}
 else if ( 
equal(sound,"weapons/knife_stab.wav") )
 {
  
soundtype stab
 
}
 
 if ( !
model_sounds[PlayerModel[id]][soundtype] )
  return 
FMRES_IGNORED ;
  
 
getstring(model_sounds[PlayerModel[id]][soundtype],sound,47)
 
engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,sound,1.0,ATTN_NORM,0,PITCH_NORM)
 
 return 
FMRES_SUPERCEDE
}
makestring(const string[])
{
 return 
engfunc(EngFunc_AllocString,string)
}
getstring(const handle,output[],sizeof_output)
{
 
global_get(glb_pStringBase,handle,output,sizeof_output)

EDIT:
*Apologise for the double-post, but it freezes on clicking the edit button
Here's the link to the plugin

http://forums.alliedmods.net/showthr...=custom+knives

If you need to see the server yourself, the default.ini, the sound locations or anything else, just ask. I really need to get these sounds working.

Last edited by YamiKaitou; 03-09-2009 at 15:19.
shadow.hk is offline
Send a message via MSN to shadow.hk
 


Thread Tools
Display Modes

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 08:53.


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