That's a terrible way of doing it. You should load the files on startup, then store them all in a global variable. Here, I'll show you:
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
new filestr[84];
public plugin_init()
{
register_plugin("Clan Models","0.1","Dizzy")
register_event("ResetHUD", "modelreset", "b")
new configs_dir[64]
get_configsdir(configs_dir , 63);
format(filestr, 83 , "%s/clanmodels.cfg" , configs_dir);
set_task(0.1 , "load_authids");
return PLUGIN_HANDLED
}
public plugin_precache()
{
precache_model("models/clanter/clanter.mdl")
precache_model("models/clanct/clanct.mdl")
return PLUGIN_CONTINUE
}
new bool:can_change[33];
public client_connect(id) can_change[id] = false;
public client_disconnect(id) can_change[id] = false;
public modelreset(id)
{
if(can_change[id])
{
new CsTeams:team = cs_get_user_team(id);
switch(team)
{
case CS_TEAM_T: cs_set_user_model(id , "clanter");
case CS_TEAM_CT: cs_set_user_model(id , "clanct");
}
}
}
public load_authids(id)
{
if(file_exists(filestr))
{
new output[128]
new fHandle = fopen(filestr, "rt")
if(!fHandle)
return PLUGIN_CONTINUE
for(new a = 0; !feof(fHandle); a++)
{
//Get line
fgets(fHandle, output, 511)
remove_quotes(output);
//Check if line is invalid
if(output[0] == ';' || !output[0] || output[0] == ' ' || output[0] == 10)
continue;
//Get authid
new authid[33]
get_user_authid(id, authid, 32)
//Containi is used since I'm not in the mood of stripping newlines
if(equal(authid , output))
{
can_change[id] = true;
}
}
}
else
{
log_amx("%s not found" , filestr);
}
return PLUGIN_CONTINUE;
}
__________________