- Ошибка
-
Error: [ReAPI]: Api minor version mismatch; expected at least 9, real 8
Ошибка: [ReAPI]: несоответствие версии Api; ожидается, по крайней мере 9, реальные 8
- Компилятор
- Локальный
- Amx Mod X
- 1.10.0
- Исходный код
-
#pragma semicolon 1
#include <amxmodx>
#include <reapi>
#define BAN_TYPE 1
#define MAX_CMD_LENGTH 256
#define MAX_REASON_LENGTH 128
#define WAID_TASK_ID 100
enum CommandType {
CMD_IGNORE,
CMD_EXECUTE,
CMD_WAIT
}
new file;
new Trie:reasons;
new Float:waitTime = 5.0;
new defaultBanTime = 1440;
new defaultBanReason[MAX_REASON_LENGTH] = "Cheater";
public plugin_init() {
register_plugin("Advanced Rechecker", "0.4", "F@nt0M");
RegisterHookChain(RC_CmdExec, "CmdExec", false);
register_srvcmd("rc_add_reason", "CmdAddReason");
new pcvar;
pcvar = create_cvar("rc_wait_time", "5.0", FCVAR_NONE, "Time for waiting user ban", true, 0.0);
bind_pcvar_float(pcvar, waitTime);
pcvar = create_cvar("rc_default_ban_time", "1440", FCVAR_NONE, "Time ban time if reason not configured", true, 0.0);
bind_pcvar_num(pcvar, defaultBanTime);
pcvar = create_cvar("rc_default_ban_reason", "Cheater", FCVAR_NONE, "Time ban reason if reason not set");
bind_pcvar_string(pcvar, defaultBanReason, charsmax(defaultBanReason));
reasons = TrieCreate();
new path[128];
get_localinfo("amxx_configsdir", path, charsmax(path));
server_cmd("exec %s/rechecker.cfg", path);
server_exec();
get_localinfo("amxx_logs", path, charsmax(path));
add(path, charsmax(path), "/rc_log");
if (!dir_exists(path)) {
mkdir(path);
}
add(path, charsmax(path), "/L%Y%m%d.log");
format_time(path, charsmax(path), path);
file = fopen(path, "a");
if (!file) {
log_amx("Could not open %s for write", path);
}
}
public plugin_end() {
fclose(file);
TrieDestroy(reasons);
}
public client_disconnected(id) {
if (task_exists(WAID_TASK_ID + id)) {
remove_task(WAID_TASK_ID + id);
new hour, minute, second;
time(hour, minute, second);
new nick[32], authid[24], ip[15];
get_user_name(id, nick, charsmax(nick));
get_user_authid(id, authid, charsmax(authid));
get_user_ip(id, ip, charsmax(ip), 1);
fprintf(
file,
"%02d:%02d:%02d: <%s><%s><%s> user disconnect before task executed^n",
hour, minute, second, nick, authid, ip
);
fflush(file);
}
}
public CmdAddReason() {
if (read_argc() < 2) {
return PLUGIN_HANDLED;
}
new reason[MAX_REASON_LENGTH], rtime[64];
read_argv(1, reason, charsmax(reason));
read_argv(2, rtime, charsmax(rtime));
TrieSetCell(reasons, reason, parseBanTime(rtime));
return PLUGIN_HANDLED;
}
public CmdExec(const id, const filename[], command[], const hash) {
trim(command);
new cmd[MAX_CMD_LENGTH];
new CommandType:type = getCommand(id, command, cmd, charsmax(cmd));
new hour, minute, second;
time(hour, minute, second);
new nick[32], authid[24], ip[15];
get_user_name(id, nick, charsmax(nick));
get_user_authid(id, authid, charsmax(authid));
get_user_ip(id, ip, charsmax(ip), 1);
fprintf(
file,
"%02d:%02d:%02d: <%s><%s><%s> found '%s' with hash %s.^n^tExecuteCMD: %s^n",
hour, minute, second, nick, authid, ip, filename, hash2Hex(hash), cmd
);
fflush(file);
if (type == CMD_WAIT && waitTime <= 0.0) {
set_task(waitTime, "TaskExecute", WAID_TASK_ID + id, cmd, sizeof cmd);
} else {
server_cmd(cmd);
}
return HC_SUPERCEDE;
}
public TaskExecute(const cmd[], id) {
id -= WAID_TASK_ID;
if (!is_user_connected(id)) {
return;
}
server_cmd(cmd);
}
CommandType:getCommand(const id, const command[], cmd[], len) {
new type[10], reason[MAX_REASON_LENGTH];
new found = argparse(command, 0, type, charsmax(type));
if (found != -1) {
copy(reason, charsmax(reason), command[found]);
trim(reason);
remove_quotes(reason);
}
if (reason[0] == EOS) {
copy(reason, charsmax(reason), defaultBanReason);
found = 0;
} else {
found = 1;
}
if (equal(type, "kick")) {
if (found == -1) {
formatex(cmd, len, "kick #%d ^"%s^"", get_user_userid(id), reason);
} else {
formatex(cmd, len, "kick #%d", get_user_userid(id));
}
return CMD_EXECUTE;
} else if (equal(type, "ban")) {
new time;
if (found == 1 && !TrieGetCell(reasons, reason, time)) {
time = defaultBanTime;
}
#if BAN_TYPE == 1
formatex(cmd, len, "fb_ban %d #%d ^"%s^"", time, get_user_userid(id), reason);
#else
formatex(cmd, len, "amx_ban #%d %d ^"%s^"", get_user_userid(id), time, reason);
#endif
return CMD_WAIT;
} else {
copy(cmd, len, command);
return CMD_IGNORE;
}
}
hash2Hex(hash) {
new result[9];
for(new i = 0, mask, bit, k; i < 32; i+= 4) {
mask = (1 << i) | (1 << (i+1)) | (1 << (i+2)) | (1 << (i+3));
bit = (hash & mask) >> i;
if (bit < 0) {
bit &= 0xF;
}
k = 7 - (i / 4);
result[k] = bit <= 9 ? bit + 48 : bit + 55;
}
result[8] = EOS;
return result;
}
parseBanTime(const value[]) {
new i, t, k;
while (value[i] != EOS) {
switch (value[i]) {
case '0'..'9': {
t = (t * 10) + (value[i] - '0');
}
case 'h': {
k += t * 60;
t = 0;
}
case 'd': {
k += t * 1440;
t = 0;
}
case 'w': {
k += t * 10080;
t = 0;
}
case 'm': {
k += t * 43200;
t = 0;
}
case 'y': {
k += t * 518400;
t = 0;
}
default: {
return k + t;
}
}
i++;
}
return k + t;
}
Помогите после установки в консоли это пишет.
В этой теме было размещено решение! Перейти к решению.
Вложения
-
5.8 KB Просмотры: 317