reading from file is easy:
PHP Code:
#include <amxmodx>
#include <amxmisc>
public func(){
new path[128], fh, cache[128]
get_configsdir(path, 127)
format(path, 127, "%s%s", path, "/myfile.ini")
//with this it will try to open file: amxmodx/configs/myfile.ini
if(!file_exists(path)){ //check if file exists
log_amx("Error: file does not exist (%s).", path)
return
}
fh = fopen(path, "rt") //open text ("t") file for reading ("r")
if(!fh){ //check if we got proper file handle
log_amx("Error: Could not open file (%s).", path)
return
}
new example_counter
while(!feof(fh)){ //loop until file handle points at the end of file
fgets(fh, cache, 127) //read next line from file and store it in "cache"
//example count lines and print them in server console using log_amx:
example_counter++
log_amx("loaded line number %d: %s", example_counter, cache)
}
fclose(fh) //close file
}
__________________