There's a few things i have to say.
1. new g_streakKills[33][1]
new g_streakKills[33] Its a simple array, you don't need to say it only has one row; that is implied when created. And confused me a bit when i first read it.
2. all your sounds need to be precached and have a filetype extension (.wav .mp3 etc)
3. sounds need to be in the sounds folder. not misc (i'm pretty sure) -correct me if i'm wrong
4. There's a better way to do the check. Here it is...
Code:
new headshot = (hitplace == HIT_HEAD) ? 1 : 0;
new selfkill = (killer == victim) ? 1 : 0;
if(!TK && !selfkill && killer)
{
g_streakKills[victim][0] = 0;
g_streakKills[killer][0] += 1;
new a = g_streakKills[killer][0] - 3;
if((a > -1) && !(a % 3))
{
if(a > 9)
a = 5;
new file[32]
format(file, 31, "misc/%s", g_Sounds[a])
play_sound(file)
return
}
}
PHP Code:
g_streakKills[victim] = 0;
new a = g_streakKills[killer]++; // Immediately store your increment into the temp var
if( a % 3 == 0 ) // all you need to worry about is if it is the third kill
{
if(a/= 3 > 9)
a = 5 // int division by 3 will get you what index you want
new file[32]
formatex(file, 31, "misc/%s", g_Sounds[a]) // formatex is faster than format
play_sound(file)
return
}
5.
client_cmd(0, "spk %s", sound) Will work just fine without the loop. It'll be faster too and you won't need to check if user is alive. All around win.
6. You should also declare g_sounds as const
new const g_sounds[][] = { Its just good habbit, because that never changes. But I'd suggest putting the entire file path into those strings just to make things a bit easier. (i.e.
"sounds/multikill.wav", ) That way you can loop through g_sounds in plugin_precache and not need to add anything. Nor will you need to add anything later. All speeding up your code.
__________________