#include <amxmodx>
#if defined client_disconnect
#define client_disconnect client_disconnected
#endif
new g_pcvarEnable, g_pcvarTimeout, g_pcvarFormat;
public plugin_init()
{
register_plugin("Auto Demo Recorder", "2.1", "F@nt0M");
register_dictionary("demo_recorder.txt");
g_pcvarEnable = register_cvar("amx_demo_enable", "1");
g_pcvarTimeout = register_cvar("amx_demo_timeout", "5.0");
g_pcvarFormat = register_cvar("amx_demo_format", "Demo-%mapname%");
}
public client_putinserver(id)
{
if (get_pcvar_num(g_pcvarEnable) && !is_user_bot(id) && !is_user_hltv(id)) {
set_task(get_pcvar_float(g_pcvarTimeout), "TaskStarRecord", id);
}
}
public client_disconnect(id)
{
remove_task(id)
}
public TaskStarRecord(id)
{
if (is_user_connected(id)) {
new demoName[64], mapName[32], date[10], time[10], steamid[24];
get_pcvar_string(g_pcvarFormat, demoName, charsmax(demoName));
get_mapname(mapName, charsmax(mapName));
get_time("%m_%d_%Y", date, charsmax(date));
get_time("%H_%M", time, charsmax(time));
get_user_authid(id, steamid, charsmax(steamid));
replace(demoName, charsmax(demoName), "%mapname%", mapName);
replace(demoName, charsmax(demoName), "%date%", date);
replace(demoName, charsmax(demoName), "%time%", time);
replace(demoName, charsmax(demoName), "%steamid%", steamid);
client_cmd(id, "stop");
client_cmd(id, "record ^"%s^"", demoName);
}
}