Code:
#include <amxmodx>
#include <amxmisc>
new g_szCfgsDir[64];
new g_szFile[] = "authid.ini";
public plugin_init()
{
// ...
get_configsdir(g_szCfgsDir, 63);
}
public WriteIt( id )
{
new szAuthID[33];
get_user_authid(id, szAuthID, 32);
new szFileStr[64];
format(szFileStr, 63, "%s/%s", g_szCfgsDir, g_szFile);
new szText[64]
format(szText, 63, "^n^"%s^"", szAuthID);
if(file_exists(szFileStr))
{
write_file(szFileStr, szText, -1);
console_print(id, "Added %s", szAuthID);
}
else
{
log_amx("File not found: %s", szFileStr);
}
return PLUGIN_HANDLED;
}
public client_putinserver( id )
{
get_configsdir(g_szCfgsDir, 63);
new szFileStr[64];
format(szFileStr, 63, "%s/%s", g_szCfgsDir, g_szFile);
if(file_exists(szFileStr))
{
new szAuthID[64];
get_user_authid(id, szAuthID, 63);
new szText[164];
new nLen=0, nLine=0;
while(read_file(szFileStr, nLine++, szText, 163, nLen))
{
if(szText[0] == ';') continue;
remove_quotes(szText);
new szUserName[33];
get_user_name(id, szUserName, 32);
if(equali(szAuthID,szText))
{
FoundID(id);
server_print("Found positive match for %s", szAuthID);
}
else
{
server_print("No match for %s", szAuthID);
}
}
}
else
{
log_amx("File not found: %s", szFileStr);
}
}
public FoundID( id )
{
// Hooray! We found it!
}