#include <amxmodx>
public plugin_init()
{
register_plugin("Player List","2.0","Richard98")
register_cvar("pl_days","7")
if(!dir_exists("addons/amxmodx/logs/playerlist"))
{
mkdir("addons/amxmodx/logs/playerlist")
}
if(get_cvar_num("pl_days")>0)
{
new dir, logname[255], dates[4],date, years[5],year
get_time("%j", dates, charsmax(dates))
date=str_to_num(dates)
get_time("%Y", years, charsmax(years))
year=str_to_num(years)
dir = open_dir("addons/amxmodx/logs/playerlist",logname,sizeof(logname)-1)
do
{
new lognamesize=strlen(logname)
if((lognamesize>11)&&equali(logname[lognamesize - 4], ".log", 4)&&equali(logname, "pllist_", 7))
{
new datefs[4],yearfs[5]
new bool
c=false
for(new i=lognamesize - 12;i<lognamesize - 4;i++)
{
if(!pc)
add(yearfs,charsmax(yearfs),logname
)
else
add(datefs,charsmax(datefs),logname)
if(logname=='_')
pc=true
}
if(is_str_num(datefs)&&is_str_num(yearfs))
{
new datef=str_to_num(datefs)
new yearf=str_to_num(yearfs)
if(datef<367)
{
new datep=date+(year-yearf)*365
if((datep-datef)>get_cvar_num("pl_days"))
{
new dirdel[255]
formatex(dirdel, charsmax(dirdel), "addons/amxmodx/logs/playerlist/%s",logname)
delete_file(dirdel)
}
}
}
}
}while(next_file(dir,logname,sizeof(logname)-1))
close_dir(dir)
}
return PLUGIN_CONTINUE
}
/*При подключении игрока к серверу*/
public client_authorized(id)
{
if(is_user_bot(id))
return PLUGIN_HANDLED
new pinfo[128],steamid[35],ip[23],username[32],time[9],date[15],dir[255]
get_user_authid(id,steamid,charsmax(steamid))
get_user_ip(id, ip, charsmax(ip),1)
get_user_name(id, username, charsmax(username))
get_time("%d.%m.%Y_%j", date, charsmax(date))
get_time("%H:%M:%S", time, charsmax(time))
formatex(pinfo,charsmax(pinfo),"%s <%s><%s><%s>",time,steamid,username,ip)
formatex(dir,charsmax(dir),"addons/amxmodx/logs/playerlist/pllist_%s.log",date)
write_file(dir,pinfo,-1)
return PLUGIN_HANDLED
}