Hi everyone!
Here is the situation:
If you play half life: opposing force or sven co-op, you'll come across "shock trooper"s. They say something like this: "may ha hmm may he he". If you check the sound files, and the senteces.txt, you'll find this:
Code:
// SHOCK TROOPER
ST_GREN0 shocktrooper/kss kyur kiml
ST_ALERT0 shocktrooper/dit dit
ST_ALERT1 shocktrooper/dit kss kss
ST_ALERT2 shocktrooper/kss dit dit kss
ST_MONST0 shocktrooper/pur thirv pur kss kss
ST_COVER0 shocktrooper/ka ga blis blis ka
ST_THROW0 shocktrooper/kss wirt ras
ST_TAUNT0 shocktrooper/kiml kiml
ST_CHARGE0 shocktrooper/mub puh mub dit dit
ST_IDLE0 shocktrooper/ku kur ku
ST_QUEST0 shocktrooper/puh pur hyu ka
ST_ANSWER0 shocktrooper/dup dup
ST_CLEAR0 shocktrooper/dup blis dup
ST_CHECK0 shocktrooper/kss kss
You cannot use emit sound here, because most of the sound files don't last for even 1/10th of a second.
Here comes the HL console:
Code:
spk "shocktrooper/mub puh mub dit dit"
And voila, here is the sound we heard.
If we use the following code, we can emit the sound to all players:
PHP Code:
public sound_to_all(){
console_cmd(0,"spk ^"shocktrooper/mub puh mub dit dit^"");
}
The problem is, it sounds like it comes from everywhere. We could filter out the distance, so someone too far would not hear the sound at all, but all the others would still hear the sound from everywhere. We could add some parameters too for volume:
Code:
spk "shocktrooper/(v30) mub puh mub dit dit"
I bet there is a balance paramether( what is it's letter? ), but isn't there a simpler way to do this then a lot of filtering?
I've tried the following code to make a function, though it's not working:
PHP Code:
#include <amxmodx>
new maxplayers = 0;
public plugin_init(){
register_plugin("SoundTest","1.0","Lulu the hero");
}
//someone connects to the server
public client_connect(id){
maxplayers++;
if(!is_user_bot(id)){
spk("vox/dadada hello",random(40)+80,50);
}
}
//someone leaves the server
public client_disconnect(id){
maxplayers--;
if(!is_user_bot(id)){
spk("vox/dadada goodbye",random(40)+80,50);
}
}
public spk(sentence[],pitch,volume){
new parsed[100] = "";
new data[4] = "";
if(pitch!=100){
num_to_str(pitch,data,3);
if(equal(parsed,"")){
format(parsed,99,"p%s",data);
}else{
format(parsed,99,"%s p%s",parsed,data);
}
}
if(volume!=100){
num_to_str(volume,data,3);
if(equal(parsed,"")){
format(parsed,99,"v%s",data);
}else{
format(parsed,99,"%s v%s",parsed,data);
}
}
if(!equal(parsed,"")){
format(parsed,99,"/(%s) ",parsed);
replace(sentence,30,"/",parsed);
}
for(new i=1;i<maxplayers;i++){
if(!is_user_bot(i)){
client_cmd(i,"spk ^"%s^"",sentence);
}
}
}
Thanks everyone for your answers in advance.