Hey everyone,
I worked on a modification of the ghw_ctf plugin to add some sound effects when a player takes the flag and when he scores.
The script includes 3 sounds:
- CT takes the flag
- T takes the flag
- Score sound
Heres how it works :
--------------------------------
First of all, modify the plugin_precache function like this:
Code:
public plugin_precache()
{
beamsprite = precache_model("sprites/dot.spr")
precache_sound("misc/tflag.wav")
precache_sound("misc/ctflag.wav")
precache_sound("misc/alert.wav")
if(file_exists(CTFLAGMODEL) && file_exists(TFLAGMODEL))
{
flag_exists=true
precache_model(CTFLAGMODEL)
precache_model(TFLAGMODEL)
ctflagent = create_flag_entities(2)
tflagent = create_flag_entities(1)
}
}
Then, those 2 emitters:
Code:
if(!TFlag_holder || TFlag_holder==-1)
{
emit_sound(0,CHAN_AUTO, "misc/ctflag.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
TFlag_holder=id
client_print(0,print_chat,"%L",LANG_PLAYER,"GRABT",name)
}
Code:
if(!CTFlag_holder || CTFlag_holder==-1)
{
emit_sound(0,CHAN_AUTO, "misc/tflag.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
CTFlag_holder=id
client_print(0,print_chat,"%L",LANG_PLAYER,"GRABCT",name)
}
And finally,
Code:
if(TFlag_holder==id && !CTFlag_holder && get_distance(idorigin,CTFlag_stand)<=40)
{
emit_sound(0,CHAN_AUTO, "misc/alert.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
//client_cmd(0,"spk misc/alert")
TFlag_holder=0
client_print(0,print_chat,"%L",LANG_PLAYER,"CAPTURET",name)
client_print(id,print_chat,"%L",id,"CAPTUREREWARDED",get_cvar_num(cvar_ctf_capture_reward))
cs_set_user_money(id,cs_get_user_money(id) + get_cvar_num(cvar_ctf_capture_reward))
CTcount++
check_scores()
}
Code:
if(CTFlag_holder==id && !TFlag_holder && get_distance(idorigin,TFlag_stand)<=40)
{
emit_sound(0,CHAN_AUTO, "misc/alert.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
CTFlag_holder=0
client_print(0,print_chat,"%L",LANG_PLAYER,"CAPTURECT",name)
client_print(id,print_chat,"%L",id,"CAPTUREREWARDED",get_cvar_num(cvar_ctf_capture_reward))
client_cmd(0,"spk misc/alert")
cs_set_user_money(id,cs_get_user_money(id) + get_cvar_num(cvar_ctf_capture_reward))
Tcount++
check_scores()
}
Note that for the 2 last emitters, you can use two different sounds instead of 1 (alarm.wav). Just don't forget to add your other sound in the precache list!
Put the sound files of the zip file in the sound/misc folder.