Hi, I am trying to have my plugin read a sound filename from a file, then precache that sound.
Here is the code:
Code:
new saveFile[128];
new configsDir[128];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
get_configsdir(configsDir, 127);
format(saveFile, 127, "%s/mpn.ini", configsDir);
}
public plugin_precache() {
new file = fopen(saveFile, "r");
new data[256];
if(file) {
while(!feof(file)) {
fgets(file, data, 255); // Get the current line
// Break the line into 2 parts, get the 2nd part and rem quotes
new left[128], right[128];
strbreak(data, left, 127, right, 127);
remove_quotes(right);
new output[128];
if(containi(right, ".wav") > -1) {
// Precache wav file
format(output, 127, "themes/%s", right);
precache_sound(output);
} else if(containi(right, ".mp3") > -1) {
// Precache mp3 file
format(output, 127, "sound/themes/%s", right);
precache_generic(output);
}
}
}
fclose(file);
}
Here is the file it's reading from (note the steam ids are for other parts of the plugin):