|
Senior Member
Join Date: Dec 2008
Location: WA, Australia
|

01-30-2009
, 05:01
Knife Menu Help!!!
|
#1
|
Hey, I'm not too good at scripting so I'll explain this as best I can  .
http://forums.alliedmods.net/showthr...light=%2Fknife
This plugin defines two folders to use cstrike/models/ and cstrike/sound/weapons by default. In the .ini folder you specify what model and sounds it is like so...
[Trout]
admin=0
p_model=models/p_trout_knife.mdl
v_model=models/v_trout_knife.mdl
hitwall=weapons/melee_hitwall.wav
hit1=weapons/melee_hit1.wav
hit2=weapons/melee_hit2.wav
hit3=weapons/melee_hit3.wav
hit4=weapons/melee_hit4.wav
slash1=weapons/melee_miss.wav
slash2=weapons/melee_miss.wav
stab=weapons/melee_stab1.wav
Which works fine, but when I change it to...
[Trout]
admin=0
p_model=models/CZ_KA/p_trout_knife.mdl
v_model=models/CZ_KA/v_trout_knife.mdl
hitwall=weapons/CZ_KA/melee_hitwall.wav
hit1=weapons/CZ_KA/melee_hit1.wav
hit2=weapons/CZ_KA/melee_hit2.wav
hit3=weapons/CZ_KA/melee_hit3.wav
hit4=weapons/CZ_KA/melee_hit4.wav
slash1=weapons/CZ_KA/melee_miss.wav
slash2=weapons/CZ_KA/melee_miss.wav
stab=weapons/CZ_KA/melee_stab1.wav
The models seem to work fine (however they require you to select it twice for some reason. i.e it's dodgey) but the sounds don't work at all. I get this error...
SV_StartSound: weapons/MD_KA/melee_miss.d not precached <0>
SV_StartSound: weapons/MD_KA/melee_miss.d not precached <0>
SV_StartSound: weapons/MD_KA/melee_miss.d not precached <0>
SV_StartSound: weapons/MD_KA/melee_miss.d not precached <0>
So changing the sound causes the plugin to fail, I'm presuming it can be fixed somewhere in the .SMA file. So I'm asking if anyone can precache (I think) that particular folder. Any help would be greatly appreciated!!!
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=-1 ; 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],i ; while ( ( line = read_file(file2,line,text,sizeof text - 1,i) ) ) { if ( text[0] == '/' && text[1] == '/' ) continue ; if ( text[0] == ';' ) continue ; if ( text[0] == '[' ) { i = 0 ; while ( text[++i] != ']') { } text[i] = 0 ; 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 == -1 ) 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("Czone# Knife Menu","on_chooseknife") new name[52]; if ( PlayerModel[id] == -1 ) menu_additem(menu,"\rNormal Knife","",0,-1) else menu_additem(menu,"Normal Knife","",0,-1) for ( new i ; i < modelcount ; i ++ ) { if ( PlayerModel[id] == i ) { 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 - 1 ; 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 i ; i < modelcount ; i ++ ) { 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 == 0 ) { 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] == 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] == -1 ) { 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] -1 ; 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] < 0 ) 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") == -1 ) 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) }
|
|