Example usage of onLocalSound() callback from the new hudbot

dopper
02-02-2007, 10:23 AM
onLocalSound( %cl, %sfx )

onLocalSound is similar to onClientMessage, except for local sounds. %cl is the client id and %sfx is the name of the .wav that will be played. If you return anything other than "True" or a non-zero value, the sound will be muted.

Is there any working example code of this being used. I'd like to mute specific voices (but not all of them). ie: *male*.wcheer*.wav, *male*.wcolor*.wav, *male*.wdoh.wav, etc.

I've tried removing them from the original Tribes\base\voices\*.vol files and also extracting them, muting them with a .wav editor and recreating new .vols. However these methods tend to mess up the audio playback after playing for 5 minutes or so. If it can be done via a script I'd appreciate an example of how someone could mute multiple specific default sounds.

Lemon
02-02-2007, 10:32 AM
function onLocalSound( %cl, %sfx ) {
if(%sfx=="wdeath" ||
%sfx=="wcheer1" ||
%sfx=="wdoh")
{
return false;
echo(Client::GetName(%cl) @" just said "@%sfx);
}
else return true;
}
Thats the basics. If you want to mute a bunch I would suggest building an array.

dopper
02-02-2007, 12:36 PM
Thanks for the example, Lemon.

I do want to mute a bunch all with similar filenames (275 muted voices total)

I'm not a coder or familiar with tribes scripting language or C++ so I'm not sure how to build an array. If anyone is willing to help me with it sometime when they have a chance, I have a list I can provide of all 275 .wav files I'd like muted and the corresponding .vol files each one is contained in. Basically it's all the taunts and useless stuff that's spammed. (The methods I've used to mute them so far give audio glitches)

*edit*
I gave it a try and I made a file mutespam.cs but it didn't seem to work and I'm not familiar with proper syntax to use in tribes. The actual file names are the same as the ones below in addition to a prefix of female1. through female5. and male1. through male5. and some have a numeric suffix as well. All the muted files contain the following text so this is what I tried (to avoid inputing all 275 file names):
function onLocalSound( %cl, %sfx ) {
if(%sfx=="wcolor" ||
%sfx=="wcheer" ||
%sfx=="wdeath" ||
%sfx=="wdoh" ||
%sfx=="wdsgst" ||
%sfx=="whitdeck" ||
%sfx=="wtakcovr" ||
%sfx=="wtaunt" ||
%sfx=="wwshoot")
{
return false;
echo(Client::GetName(%cl) @" just said "@%sfx);
}
else return true;
}

One thing I noticed in your code is you open the if statement with a "{" but I don't see a closing "}" and I'm not sure if it's required or not as I'm not familiar with the scripting language.

GreyHound
02-02-2007, 06:56 PM
One thing I noticed in your code is you open the if statement with a "{" but I don't see a closing "}" and I'm not sure if it's required or not as I'm not familiar with the scripting language.


thatīs because the else statement has only one line.

if(foo)
doFoo();
else
doBar();

Lemon
02-02-2007, 08:28 PM
What you have there should work. Put that in your autoexec.cs or exec it from there. One problem I see is that you are muting only local sounds. Do you mute the global and team says in onclientmessage() as well ?

GreyHound
02-03-2007, 05:13 AM
all of them

onClientMessage(%blubb, %blaa){return false;}

and the chathud will shut up, just the waypointing infoīs still come through

dopper
02-03-2007, 03:48 PM
That's probably my problem, I thought onLocalSound applies to all sounds that are played locally. (by locally I thought it meant clientside and everything I can hear) Now that I see onLocalSound means local to the distance of the player in game...I'd like to mute all 3 types of sounds (local voices, team voices and global voices) that contain the following text in the .wav filenames:

wcolor
wcheer
wdeath
wdoh
wdsgst
whitdeck
wtakcovr
wtaunt
wwshoot

This should mute the taunts and garbage spam but still allow me to hear voices relevant to game tactics. I tried your suggestions but was unable to make it work properly.