1st of all, im a newbie when it comes to plugin coding, so i need help with something here. The target of my plugin is to save, in a text file, the list of players playing on the server, so i can retrieve it with another script somewhere else. The problem is that apparently (and excuse my ignorance) get_players doesnt actually return the names of the players but some kind of index.
My problem is that im saving these indexes in the file instead of the names, and i have no idea whats the function to get the playernames. Can anyone give me a hand here?
Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Unline^^ Server Stats"
#define VERSION "1.0"
#define AUTHOR "Onyx"
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
set_task(5.0, "SavePlayers", 33,_,_,"b");
}
public SavePlayers(id) {
new file[129];
new iPlayers[32];
new iNum;
new message[100];
get_datadir(file, 128);
format(file, 128, "%2/playerlist.txt", file);
if (file_exists(file)) {
delete_file(file);
}
iNum = get_playersnum();
get_players(iPlayers, iNum);
for(new i=0;i<iNum;i++) {
format(message, 50, "%s", iPlayers[i]);
write_file(file, message);
}
}
Thanks in advanced
Bruno