Contents |
This code was used for the purpose of making a “scripted” game, where the game is customized through non-quakec means. There are other reasons this is useful though.
// You should call this function from the worldspawn() function. void() FRIK_FILE_precaches = { local float f; // file handle, basically assigns a number to whatever file is open local string ln; // ln = line of the file being read f = fopen("system/precache.txt", FILE_READ); // opens "system/precache.txt" to be read if (f != -1) // if f = -1 then the file could not be found { ln = fgets(f); // this line sets ln to the string read from the file with the file handle of f while(ln != string_null) // while there is still text to be read do the following { if(strstrofs(ln, ".wav",0) != -1) // this checks if the file extension is .wav for a sound file { precache_sound(ln); // if it is a sound, then it precaches said sound } else // if it isn't a sound, then it will most likely be a model { precache_model(ln); // so precache the model } ln = fgets(f); // get a new line from the file } } fclose(f); // when the while loop is over (no lines left in file) close file with the handle f };
Code by GiffE