Yes.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#pragma semicolon 1
#pragma ctrlchar '\'
new Handle:g_mysql;
new g_loaded_admins[][32];
new g_count;
new const g_table[] = "banned_ids";
public plugin_init()
{
register_plugin("amx_banid", "1.0", "Radiance");
register_concmd("amx_current", "cmd_current", ADMIN_BAN, "[shows info about banned players]");
//register_concmd("amx_unbanid", "cmd_unbanid", ADMIN_BAN, "<name or #steamid>");
server_print("test-print: %s", g_table); // here i got: test-print: banned_ids
}
public plugin_cfg()
{
_sql_init();
_load_admins();
}
_sql_init()
{
new cvars[4][16];
new error[64];
new errcode;
get_cvar_string("amx_sql_host", cvars[0], 16);
get_cvar_string("amx_sql_user", cvars[1], 16);
get_cvar_string("amx_sql_pass", cvars[2], 16);
get_cvar_string("amx_sql_db", cvars[3], 16);
new Handle:cn_tuple = SQL_MakeDbTuple(cvars[0], cvars[1], cvars[2], cvars[3]);
if ((g_mysql = SQL_Connect(cn_tuple, errcode, error, sizeof (error))) == Empty_Handle)
{
server_print("[amx_banid.amxx] %s(#%i)", error, errcode);
pause("a");
}
}
_load_admins()
{
new file[64];
get_configsdir(file, sizeof (file));
format(file, sizeof (file), "%s/admins.ini", file);
if (!file_exists(file))
{
return;
}
for (new i; i < file_size(file, 1); i++)
{
new nick[32];
new ln;
read_file(file, i, nick, sizeof (nick), ln);
if ((nick[0] != ';') && ln)
{
g_loaded_admins[g_count++] = nick;
}
}
}
bool:_is_priority_admin(id)
{
new nick[32];
get_user_name(id, nick, sizeof (nick));
for (new i; i < g_count; i++)
{
if (equal(nick, g_loaded_admins[i]))
{
return true;
}
}
return false;
}
public cmd_current(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
{
return 1;
}
new Handle:q[2];
q[0] = SQL_PrepareQuery(g_mysql, "SELECT `id` FROM `%s`", g_table);
q[1] = SQL_PrepareQuery(g_mysql, "SELECT `id` FROM `%s` WHERE `unban` = '0'", g_table);
if (!SQL_Execute(q[0]) || !SQL_Execute(q[1])) // as i said after 3 or 4 successfull calls of this function plugin started passing through this condition everytime and i started print for test arguments..
{
//set_fail_state("SQL_Execute() failed.");
client_print(id, print_console, "test-print: %s", g_table); // here i got: test-print:
}
new i[2];
i[0] = SQL_NumResults(q[0]);
i[1] = SQL_NumResults(q[1]);
SQL_FreeHandle(q[0]);
SQL_FreeHandle(q[1]);
new fmt[128];
if (!i[0])
{
formatex(fmt, sizeof (fmt), "[AMXX] There are no banned players.");
}
else
{
if (i[0] == 1)
{
if (i[1])
{
formatex(fmt, sizeof (fmt), "[AMXX] There is a player banned permanently.");
}
else
{
formatex(fmt, sizeof (fmt), "[AMXX] There is a player banned.");
}
}
else
{
if (i[1])
{
formatex(fmt, sizeof (fmt), "[AMXX] There are %i players banned. %i of them banned permanently.", i[0], i[1]);
}
else
{
formatex(fmt, sizeof (fmt), "[AMXX] There are %i players banned.", i[0]);
}
}
}
client_print(id, print_console, fmt);
return 1;
}