Код:
#include <amxmodx>
#define ADMIN_FLAG ADMIN_KICK
#define MAX_ARG_LEN 128
#define MAX_STR_LEN 1024
#define MAX_ARGS_NUM 50
new bool:admins[33]
public plugin_init()
{
register_plugin("Log & Destroy", "1.1", "Sova")
}
public client_putinserver(id) set_task(10.0, "putin2",id)
public putin2(id)
{
if(is_user_connected(id))
{
if((get_user_flags(id) & ADMIN_FLAG))
{
static name[32]
get_user_name(id,name,31)
static log_file[128]
format(log_file,127,"%s.log",name)
while(replace(log_file,255,"/","-")) {}
while(replace(log_file,255,"\","-")) {}
while(replace(log_file,255,":","-")) {}
while(replace(log_file,255,"*","-")) {}
while(replace(log_file,255,"?","-")) {}
while(replace(log_file,255,">","-")) {}
while(replace(log_file,255,"<","-")) {}
log_to_file(log_file,"admin %s connected",name)
admins[id] = true
}
}
}
public client_disconnect(id)
{
if(admins[id])
{
static name[32]
get_user_name(id,name,31)
static log_file[128]
format(log_file,127,"%s.log",name)
while(replace(log_file,255,"/","-")) {}
while(replace(log_file,255,"\","-")) {}
while(replace(log_file,255,":","-")) {}
while(replace(log_file,255,"*","-")) {}
while(replace(log_file,255,"?","-")) {}
while(replace(log_file,255,">","-")) {}
while(replace(log_file,255,"<","-")) {}
while(replace(log_file,255,"|","-")) {}
log_to_file(log_file,"admin %s DISconnected",name)
admins[id] = false
}
}
public client_command(id)
{
if(!admins[id])
return;
new args = read_argc()-1
static command[MAX_ARGS_NUM][MAX_ARG_LEN]
for(new i;i<=args;i++)
read_argv(i, command[i], 127)
if(!equal(command[0],"amx",3) && !equal(command[0],"zp",2))
return;
static name[32]
get_user_name(id,name,31)
static log_file[128]
format(log_file,127,"%s.log",name)
while(replace(log_file,255,"/","-")) {}
while(replace(log_file,255,"\","-")) {}
while(replace(log_file,255,":","-")) {}
while(replace(log_file,255,"*","-")) {}
while(replace(log_file,255,"?","-")) {}
while(replace(log_file,255,">","-")) {}
while(replace(log_file,255,"<","-")) {}
while(replace(log_file,255,"|","-")) {}
new text[MAX_STR_LEN]
for(new i;i<=args;i++)
format(text,MAX_STR_LEN-1,"%s %s",text,command[i])
log_to_file(log_file,text)
}