Hi all. I need help with this code. It gives false detection on g_InList if the steamid is not on line 1 inside names.ini file. Also, i think this code need more optimization and cvars for country name. This plugin is actually for dumping players name from certain country. I use "error" country because im testing it on my home server.
Код:
#include <amxmodx>
#include <amxmisc>
#include <geoip>
new name[33], authid[33], country[33], ip[33]
new bool:g_InList[33] = true
new filename[256]
public plugin_init()
{
register_plugin("Dump LAN player name", "1.0", "")
get_datadir(filename, 255)
format(filename, 255, "%s/names.ini", filename)
register_clcmd("say z", "check")
}
public check(id)
{
client_print(id, print_chat, "InList: %s", ((g_InList[id] = true) ? "YES":"NO"))
}
public client_putinserver(id)
{
get_user_name(id, name, 32)
get_user_authid(id, authid, 32)
get_user_ip(id, ip, 32)
geoip_country(ip, country)
check_steamid(id)
if(!is_user_bot(id) && equali(country, "error") && !g_InList[id])
{
write_name(id)
}
}
public write_name(id)
{
new filepointer = fopen(filename,"a+")
get_user_name(id, name, 32)
get_user_authid(id, authid, 32)
if(filepointer)
{
fprintf(filepointer,"%s^t//^t%s^n", authid, name)
fclose(filepointer)
}
}
public check_steamid(id)
{
new filepointer = fopen(filename, "r")
get_user_authid(id, authid, 32)
if(filepointer)
{
new readdata[128], parsedsteamid[32]
while(fgets(filepointer, readdata, 127))
{
parse(readdata, parsedsteamid, 32)
if(equal(authid, parsedsteamid))
{
g_InList[id] = true
}
else
{
g_InList[id] = false
}
break
}
fclose(filepointer)
}
}