I'm trying to create a mod for TF2 that switches your class' VO with a different class' (I.e., a Heavy will call out for medic using the scout's audio), and it was all going well until the game was claiming that the switched VO wasn't precached, so to test if I could do it myself I added
but the sound still won't play, and is outputting:
Code:
SV_StartSound: sound/vo/engineer_medic02.mp3 not precached (0)
to the console. I'm using FileExists to check that the target audio does exist, and if not it won't try to play it, so I'd only get this error if the game found the file, but isn't precached.
What else am I missing with this?
Here's the main block of code if it helps:
Spoiler
Code:
public Action Hook_EntitySound(int clients[64], int &numClients, char sample[PLATFORM_MAX_PATH],
int &client, int &channel, float &volume, int &level, int &pitch,
int &flags, char soundEntry[PLATFORM_MAX_PATH], int &seed)
{
new TFClassType:SoundClass = TFClass_Unknown;
if(StrContains(sample, "vo/", false) != -1)
{
if(StrContains(sample, "vo/scout", false) != -1)
SoundClass = TFClass_Scout;
else if (StrContains(sample, "vo/sniper", false) != -1)
SoundClass = TFClass_Sniper;
else if (StrContains(sample, "vo/soldier", false) != -1)
SoundClass = TFClass_Soldier;
else if (StrContains(sample, "vo/demoman", false) != -1)
SoundClass = TFClass_DemoMan;
else if (StrContains(sample, "vo/medic", false) != -1)
SoundClass = TFClass_Medic;
else if (StrContains(sample, "vo/heavy", false) != -1)
SoundClass = TFClass_Heavy;
else if (StrContains(sample, "vo/pyro", false) != -1)
SoundClass = TFClass_Pyro;
else if (StrContains(sample, "vo/spy", false) != -1)
SoundClass = TFClass_Spy;
else if (StrContains(sample, "vo/engineer", false) != -1)
SoundClass = TFClass_Engineer;
}
if(SoundClass != TFClass_Unknown)
{
new TFClassType:NewClass = TFClass_Unknown;
if(TF2_GetPlayerClass(client) == SoundClass)
{
for(new i = 0; i<=MAX_RANDOM_ITERATIONS; i++)
{
NewClass = GetRandomClass();
if(SoundClass != NewClass)
break;
}
ReplaceString(sample, sizeof(sample), ClassToString(TF2_GetPlayerClass(client)), ClassToString(NewClass));
StrToLower(sample, sample, sizeof(sample));
ReplaceString(sample, sizeof(sample), "vo/", "sound/vo/");
if(FileExists(sample, true))
{
EmitSound(clients, numClients, sample, client, channel, level, flags, volume, pitch, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
return Plugin_Stop;
}
return Plugin_Continue;
}
}
return Plugin_Continue;
}
Nvm I figured it out, I needed to add "sound/" to the file path for the FileExists check, but I wasn't removing it for the path to the sound in EmitSound so it was looking for "sound/sound/vo/...".