Проблема с Admin loader

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
103
Реакции
5
Помог
2 раз(а)
Ошибка
L 08/12/2018 - 22:42:07: [admin_loader.amxx] [Проблемы с БД. Код ошибки: #2003] Ошибка: Can't connect to MySQL server on 'IP' (4)
ОС
Linux
Amx Mod X
AMX Mod X 1.8.3-Re (http://www.amxmodx.org)
Билд
Protocol version 48
Exe version 1.6.3.7/Stdio (cstrike)
ReHLDS version: 3.4.0.658-dev
Build date: 15:04:52 Aug 11 2018 (1582)
ReGamedll
ReGameDLL version: 5.7.0.312-dev
Build date: 07:53:34 May 31 2018
Версия Metamod
Metamod-r v1.3.0.127, API (5:13)
Metamod-r build: 10:49:17 Jun 15 2018
Список метамодулей
Currently loaded plugins:
description stat pend file vers src load unload
[ 1] SafeNameAndChat RUN - SafeNameAndChat.so v1.1 ini ANY ANY
[ 2] Reunion RUN - reunion_mm_i386.so v0.1.0.92 ini Start Never
[ 3] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 4] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 5] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC3 ini ANY ANY
[ 6] WHBlocker RUN - whblocker_mm_i386.so v1.5.695 ini Chlvl ANY
[ 7] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 8] AMX Mod X RUN - amxmodx_mm_i386.so v1.8.3-Re ini Start ANY
[ 9] MySQL RUN - mysql_amxx_i386.so v1.8.3-Re pl8 ANY ANY
[10] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.2 pl8 ANY Never
[11] ReAPI RUN - reapi_amxx_i386.so v5.6.0.155-dev pl8 ANY Never
[12] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.8.3-Re pl8 ANY ANY
[13] FakeMeta RUN - fakemeta_amxx_i386.so v1.8.3-Re pl8 ANY ANY
[14] hackdetector RUN - hackdetector_amxx_i386.so v0.15.328.lite pl8 ANY ANY
[15] CStrike RUN - cstrike_amxx_i386.so v1.8.3-Re pl8 ANY ANY
[16] Engine RUN - engine_amxx_i386.so v1.8.3-Re pl8 ANY ANY
[17] Fun RUN - fun_amxx_i386.so v1.8.3-Re pl8 ANY ANY
[18] CSX RUN - csx_amxx_i386.so v1.8.3-Re pl8 ANY ANY
18 plugins, 18 running
Список плагинов
Currently loaded plugins:
name version author file status
[ 1] Advanced Spam Nick Cha 0.2 Fullserver advanced_spam_n running
[ 2] Admin Loader 3.5 neygomon admin_loader.am running
[ 3] Rechecker Log 0.1 F@nt0M rc_log.amxx debug
[ 4] HackDetector 0.15.lite Lev @ AGHL.RU De hackdetector.am running
[ 5] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a debug
[ 6] Chat Manager 1.1.1-11 Mistrick chatmanager.amx debug
[ 7] Chat Manager: Addon 0.0.4-70 Mistrick chatmanager_add debug
[ 8] pvpru ranget t 0.2.143 kekt AntiSoundESP.am running
[ 9] New_Anti_Reconnect 3.2 JohnJ new_antireconne running
[ 10] Quit Server 1.2 Adidasman quit_server.amx running
[ 11] LogConnect 1.0 serveer_222 LogConnect.amxx running
[ 12] Night VIPs Private Racoon night_vips.amxx running
[ 13] [Reapi] Custom Models 1.6.1 neygomon custom_models.a running
[ 14] Admin Free Look 2.0 Jim admin_freelook. running
[ 15] Mode 2x2 2.5re s1lent mode.amxx running
[ 16] AFK Control 1.4.1 [Rnd neygomon afk_control.amx running
[ 17] Block Pickup Gold 0.1 Vaqtincha BlockPickupGold running
[ 18] FreshBans 1.3.8b kanagava fresh_bans.amxx running
[ 19] fb_forwards 0.1.4 Kanagava & Realu fb_forwards.amx running
[ 20] CSStatsX SQL 0.7.4 serfreeman1337 csstatsx_sql.am debug
[ 21] Advanced Experience Sy 0.5.9 [REA serfreeman1337/s aes_main.amxx debug
[ 22] AES: CStrike Addon 0.5.9 [REA serfreeman1337/s aes_exp_cstrike debug
[ 23] AES: Informer 0.5.9 [REA serfreeman1337/s aes_informer.am debug
[ 24] AES: Admin Tools 0.5.9 [REA serfreeman1337/s aes_exp_editor. debug
[ 25] AES: StatsX 0.5.9 [REA serfreeman1337/s aes_statsx_cstr debug
[ 26] AES Bonus: Flags 0.1 Sonyx aes_bonus_flags running
[ 27] AES: Bonus System 0.5.9 Vega serfreeman1337/s aes_bonus_syste running
[ 28] AES: Bonus CSTRIKE 0.5.9 [REA serfreeman1337/s aes_bonus_cstri running
[ 29] Slots Reservation 1.2 pUzzlik admin_slots.amx running
[ 30] Menus Front-End 1.5 neugomon amxmodmenu.amxx running
[ 31] Players Menu 1.7 neugomon players_menu.am running
[ 32] Maps Menu 1.4.1 neugomon mapsmenu.amxx running
[ 33] Admin Chat 1.8.3-Re AMXX Dev Team adminchat.amxx running
[ 34] Admin Votes 1.8.3-Re AMXX Dev Team adminvote.amxx running
[ 35] Map Manager 2.5.61 Mistrick mapmanager.amxx running
[ 36] Stats Configuration 1.8.3-Re AMXX Dev Team statscfg.amxx running
[ 37] Restrict Weapons 1.8.3-Re AMXX Dev Team restmenu.amxx running
[ 38] Say me and Say hp 1.4 neygomon sayme.amxx running
[ 39] Plugins Controller 1.0 neygomon plugins_control stopped
[ 40] Voice protection 0.3 AMXX.Shop voice_protectio running
[ 41] SF Warn Menu 0.1.3 serfreeman1337 sf_admin_warns. running
[ 42] Lite Admin ESP 1.0 neygomon admin_esp.amxx running
[ 43] DemoRecoder 1.1 neygomon amx_demorec.amx running
[ 44] Check Admin & Vip 2.0 Leo_[BH] ADMIN_CHECK_V0. running
[ 45] ReAPI AWP Limitter 1.9 neygomon reapi_awp_limit debug
[ 46] buy_privleges 1.0a TuMon buy_priv.amxx running
[ 47] Adverts 1.0 pUzzlik adverts_message running
[ 48] Advanced Gag 1.9.0 neygomon amx_gag.amxx running
[ 49] Knife Duel with Telepo 1.2 neygomon knf_duel.amxx running
[ 50] Server Menu [INI] 1.0 Leo_[BH] server_menu.amx running
[ 51] Slay Losers 1.1.6 [email protected] slay_losers.amx running
[ 52] Grab 1.0 Wolf228 grab.amxx running
[ 53] Steam Bonus 1.1 ill+F@nToM steam_bonus_a2. running
[ 54] [ReAPI] No Team Flash 0.0.2 Vaqtincha antiflash5.amxx running
[ 55] Hard Restrict 0.1 Vaqtincha hard_restrict.a running
[ 56] Game Namer 1.1 NeuroToxin gamename.amxx running
[ 57] [ReAPI] Random Weapons 2.4.8 neugomon/h1k3 random_weapons_ running
[ 58] Block TextMsg 1.0 AcE block_textmsg.a running
[ 59] Parachute [ReAPI] 10.0 Leo_[BH] parachute.amxx running
[ 60] Hud_info 2.1 h1k3 hud_info.amxx running
[ 61] Amx_Killer 1.1 Xhonor/asd edit amx_killer.amxx running
[ 62] Ping Checker 26.0.1 RC1 h1k3 ping_checker.am running
[ 63] Reset Score 0.0.2f wopox1337 ResetScore.amxx running
[ 64] V.I.P Custom Weapons 1.0.0 Vaqtincha vip_custom.amxx debug
[ 65] V.I.P Custom KNIFE 1.0.0 Vaqtincha custom_knife.am debug
[ 66] V.I.P Custom DEAGLE 1.0.0 Vaqtincha custom_deagle.a debug
[ 67] V.I.P Custom M4A1 1.0.0 Vaqtincha custom_m4a1.amx debug
[ 68] V.I.P Custom AK-47 1.0.0 Vaqtincha custom_ak47.amx debug
[ 69] V.I.P Custom AWP 1.0.0 Vaqtincha custom_awp.amxx debug
69 plugins, 68 running
Автор плагина
neygomon
Версия плагина
3.5
Исходный код
#include <amxmodx>
#include <sqlx>
#tryinclude <reapi>

#define CUSTOM_DEF_FLAG
// Добавляет квар amx_default_access

// #define USE_DEFAULT_AMXX_FORWARD
// Если используете fakemeta, не рекомендуется включать
// Если есть ReAPI , то будет использоваться он, независимо от этой настройки

#if !defined _reapi_included && !defined USE_DEFAULT_AMXX_FORWARD
#include <fakemeta>
#endif
#if !defined MAX_PLAYERS
#define MAX_PLAYERS 32
#endif
#if !defined MAX_NAME_LENGTH
#define MAX_NAME_LENGTH 32
#endif

enum _:UserInfo { Auth[MAX_NAME_LENGTH], Passwd[64], Nick[MAX_NAME_LENGTH], Access, Flags, Expired } // g_sUser
enum _:ServerData { IP[24] } // g_szServerData
enum _:SqlData { ServerInfo[32], Prefix[10] } // g_szSqlData

new Handle:g_hSqlTuple;
new g_Data[1], g_szQuery[512];

enum FWDS { AdminLoad, AdminLoad2 }
new g_fwdHandle[FWDS] = { INVALID_HANDLE, INVALID_HANDLE };

new g_iAdminExpired[MAX_PLAYERS + 1];

new g_szServerData[ServerData];
new g_szSqlData[SqlData];

new Array:g_aUsers;
new g_sUser[UserInfo];

new g_szPassField[5];

new g_bitDefaultAccess = ADMIN_USER;
new g_iBanSystem;

new g_szBackupAdminPath[128];

public plugin_natives()
{
register_library("Admin Loader");

register_native("admin_expired", "admin_expired_callback", true);
register_native("amxbans_get_expired", "admin_expired_callback", true); // support AmxBans RBS by SKAJIbnEJIb
register_native("adminload_get_expired", "admin_expired_callback", true); // support Admin Load by Fant0M
}

public admin_expired_callback(id)
return g_iAdminExpired[id];

public plugin_end()
{
if(g_hSqlTuple != Empty_Handle)
SQL_FreeHandle(g_hSqlTuple);

ArrayDestroy(g_aUsers);
}

public plugin_init()
{
#define PLUGIN_VERSION "3.5"
register_plugin("Admin Loader", PLUGIN_VERSION, "neygomon");
// 1.7: add compatibility with Mazdan Admin Loader Forward
// 1.8: refactoring code... Thanks Radius
// 1.9: refactoring code... Мore readable code + added exec sql.cfg for compatibility with other mysql plugins
// 2.0: refactoring code... Use Thread SQL Querys
// 2.2: Fix bug with InfoChanged datas + added define USE_FAKEMETA
// 2.3: Fix load BackUP without MySQL connection
// 2.4: Add native al_get_access
// 2.4.1: Close test connection
// 2.4.2: Add cvar for indentification plugin =)
// 2.5: Fix critical bug with access by IP
// 2.5.2: Fix #2 with IP bug
// 2.6: Add reapi hookchain for changename
// 2.6.1: Fix HookChain for reAPI
// 2.6.2: May be fix error with invalid handle :D
// 2.7: Add support field 'custom_flags'
// 2.8: Optimization SQL query's... THX sonyx (https://neugomon.ru/members/62/)
// 2.9: Fix compile on AMXX 182
// 3.0: Forced use of ReAPI if available. New #define USE_DEFAULT_AMXX_FORWARD. Refactoring code...
// 3.1: Fixed load backup if MySQL is not available

// 3.2: Add natives amxbans_get_expired and adminload_get_expired for support plugins writen for amxbans rbs/admin load
// 3.2: Removed useless native al_get_access
// 3.2: Plugin working without mysql, without bansysytem. Used users.ini in new format
// 3.2: Maybe fix register forwards - removed 'else'
// 3.2: Fix clear array pre-load backup users.ini
// 3.2: Translate errors, info messages to russian language (only amxx logs and client console)
// 3.2: Refactoring...
// 3.4: fix multiflags
// 3.5: fix invalid handle error

register_concmd("amx_reloadadmins", "cmdReload", ADMIN_CFG);
#if defined _reapi_included
RegisterHookChain(RG_CBasePlayer_SetClientUserInfoName, "SetClientUserInfoName_Post", true);
#endif
#if !defined _reapi_included && !defined USE_DEFAULT_AMXX_FORWARD
register_forward(FM_SetClientKeyValue, "SetCleintKeyValue_Post", true);
#endif
new szPath[64], szPathFile[128];
get_localinfo("amxx_configsdir", szPath, charsmax(szPath));

formatex(szPathFile, charsmax(szPathFile), "%s/fb/main.cfg", szPath);
if(file_exists(szPathFile))
RegisterFreshBans(szPathFile);
else
{
formatex(szPathFile, charsmax(szPathFile), "%s/LB/main.cfg", szPath);
if(file_exists(szPathFile))
RegisterLiteBans(szPathFile);
}

g_aUsers = ArrayCreate(UserInfo);

RegisterDefaultCvars();
ExecConfigs(szPath);
ReadCvars();
if(g_iBanSystem)
SqlInit();
else LoadBackUp(0);
RegForwards();
}

public client_putinserver(id)
UserAccess(id);
#if !defined _reapi_included && defined USE_DEFAULT_AMXX_FORWARD
public client_infochanged(id)
{
if(!is_user_connected(id))
return;

new oldname[MAX_NAME_LENGTH];
get_user_name(id, oldname, charsmax(oldname));

new newname[MAX_NAME_LENGTH];
get_user_info(id, "name", newname, charsmax(newname));

if(strcmp(oldname, newname) != 0)
UserAccess(id, newname);
}
#endif
#if defined _reapi_included
public SetClientUserInfoName_Post(const id, infobuffer[], szNewName[MAX_NAME_LENGTH])
UserAccess(id, szNewName);
#endif
#if !defined _reapi_included && !defined USE_DEFAULT_AMXX_FORWARD
public SetCleintKeyValue_Post(id, const sInfoBuffer[], const sKey[], sValue[MAX_NAME_LENGTH])
if(strcmp(sKey, "name") == 0)
UserAccess(id, sValue);
#endif
public cmdReload(id, level)
{
if(get_user_flags(id) & level)
{
if(g_iBanSystem)
adminSql(id);
else LoadBackUp(id);
}
return PLUGIN_HANDLED;
}

public SQL_Handler(failstate, Handle:query, err[], errcode, dt[], datasize)
{
switch(failstate)
{
case TQUERY_CONNECT_FAILED, TQUERY_QUERY_FAILED:
{
log_amx("[Проблемы с БД. Код ошибки: #%d] Ошибка: %s", errcode, err);
LoadBackUp(0);
return;
}
}

if(!SQL_NumResults(query))
{
log_amx("Администраторы для сервера %s не найдены в БД! Пробуем загрузить из users.ini...", g_szServerData[IP]);
LoadBackUp(0);
return;
}

if(g_aUsers == Invalid_Array)
{
log_error(AMX_ERR_NOTFOUND, "Dyn massive g_aUsers invalid!");
return;
}

new sBuffer[32];
new iLoadAdmins;
ArrayClear(g_aUsers);

while(SQL_MoreResults(query))
{
SQL_ReadResult(query, 0, g_sUser[Auth], charsmax(g_sUser[Auth]));
SQL_ReadResult(query, 1, g_sUser[Passwd], charsmax(g_sUser[Passwd]));
SQL_ReadResult(query, 2, g_sUser[Nick], charsmax(g_sUser[Nick]));

SQL_ReadResult(query, 6, sBuffer, charsmax(sBuffer)); trim(sBuffer);
if(!sBuffer[0]) SQL_ReadResult(query, 3, sBuffer, charsmax(sBuffer));
g_sUser[Access] = read_flags(sBuffer);
SQL_ReadResult(query, 4, sBuffer, charsmax(sBuffer)); g_sUser[Flags] = read_flags(sBuffer);
g_sUser[Expired] = SQL_ReadResult(query, 5);

ArrayPushArray(g_aUsers, g_sUser);
iLoadAdmins++;
SQL_NextRow(query);
}

new szText[128];
if(iLoadAdmins == 1)
formatex(szText, charsmax(szText), "Загружен 1 администратор из MySQL");
else formatex(szText, charsmax(szText), "Загружено %d администраторов из MySQL", iLoadAdmins);

if(dt[0]) console_print(dt[0], szText);
log_amx(szText);

new pNum, players[MAX_PLAYERS];
get_players(players, pNum);
for(new i; i < pNum; i++)
UserAccess(players[i]);
BackUpAdmins();
}

public KickPlayer(const account[], id)
{
new usr = get_user_userid(id);
new szName[MAX_NAME_LENGTH]; get_user_name(id, szName, charsmax(szName));
new szAuth[25]; get_user_authid(id, szAuth, charsmax(szAuth));
new szIP[16]; get_user_ip(id, szIP, charsmax(szIP), 1);

server_cmd("kick #%d Invalid password! Use setinfo ^"%s^" ^"your pass^"", usr, g_szPassField);
log_amx("Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")",
szName, usr, szAuth, account, szIP);
}

public LoadMapConfigs()
{
new amxxcfgpath[64], map[32], fmt[64], prefix[32];
get_localinfo("amxx_configsdir", amxxcfgpath, charsmax(amxxcfgpath));
get_mapname(map, charsmax(map));
formatex(fmt, charsmax(fmt), "%s/maps/%s.cfg", amxxcfgpath, map);
if(file_exists(fmt)) ExecCfg(fmt);
else
{
strtok(map, prefix, charsmax(prefix), "", 0, '_');
formatex(fmt, charsmax(fmt), "%s/maps/prefix_%s.cfg", amxxcfgpath, prefix);
if(file_exists(fmt)) ExecCfg(fmt);
}
}

adminSql(id)
{
g_Data[0] = id;

formatex(g_szQuery, charsmax(g_szQuery), "SELECT \
`a`.`steamid`, \
`a`.`password`, \
`a`.`nickname`, \
`a`.`access`, \
`a`.`flags`, \
`a`.`expired`, \
`b`.`custom_flags` \
FROM `%s_amxadmins` AS `a`, `%s_admins_servers` AS `b` \
WHERE `b`.`admin_id` = `a`.`id` \
AND `b`.`server_id` = (SELECT `id` FROM `%s` WHERE `address` = '%s') \
AND (`a`.`days` = '0' OR `a`.`expired` > UNIX_TIMESTAMP(NOW()))",
g_szSqlData[Prefix], g_szSqlData[Prefix], g_szSqlData[ServerInfo], g_szServerData[IP]
);

SQL_ThreadQuery(g_hSqlTuple, "SQL_Handler", g_szQuery, g_Data, sizeof(g_Data));
}

UserAccess(id, name[MAX_NAME_LENGTH] = "")
{
remove_user_flags(id);

new authid[25]; get_user_authid(id, authid, charsmax(authid));
new ip[16]; get_user_ip(id, ip, charsmax(ip), 1);
if(!name[0]) get_user_name(id, name, charsmax(name));
new bitsNewFlags, szName[sizeof g_sUser[Nick]], szAuth[sizeof g_sUser[Auth]];

for(new i, Hash[34], password[33], aSize = ArraySize(g_aUsers); i < aSize; i++)
{
ArrayGetArray(g_aUsers, i, g_sUser);

if(g_sUser[Flags] & FLAG_AUTHID)
{
if(strcmp(authid, g_sUser[Auth]) != 0)
continue;
}
else if(g_sUser[Flags] & FLAG_IP)
{
if(strcmp(ip, g_sUser[Auth]) != 0)
continue;
}
else if(strcmp(name, g_sUser[Auth]) != 0)
continue;

g_iAdminExpired[id] = g_sUser[Expired];

if(g_sUser[Flags] & FLAG_NOPASS)
{
bitsNewFlags |= g_sUser[Access];
copy(szName, charsmax(szName), g_sUser[Nick]);
copy(szAuth, charsmax(szAuth), g_sUser[Auth]);
}
else
{
get_user_info(id, g_szPassField, password, charsmax(password));
#if AMXX_VERSION_NUM >= 183
hash_string(password, Hash_Md5, Hash, charsmax(Hash));
#else
md5(password, Hash);
#endif
if(strcmp(Hash, g_sUser[Passwd]) == 0)
{
bitsNewFlags |= g_sUser[Access];
copy(szName, charsmax(szName), g_sUser[Nick]);
copy(szAuth, charsmax(szAuth), g_sUser[Auth]);
}
else if(g_sUser[Flags] & FLAG_KICK)
set_task(0.2, "KickPlayer", id, g_sUser[Auth], sizeof g_sUser[Auth]);
}
}

if(bitsNewFlags)
{
new sFlags[36];
set_user_flags(id, bitsNewFlags);
get_flags(bitsNewFlags, sFlags, charsmax(sFlags));
ExecuteFwd(id, bitsNewFlags, g_sUser[Expired]);
log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (nickname ^"%s^") (access ^"%s^") (address ^"%s^")",
name, get_user_userid(id), authid, szAuth, szName, sFlags, ip);
}
else
{
g_iAdminExpired[id] = -1;
set_user_flags(id, g_bitDefaultAccess);
ExecuteFwd(id, g_bitDefaultAccess, g_iAdminExpired[id]);
}
return PLUGIN_HANDLED;
}

RegisterDefaultCvars()
{
register_cvar("amx_votekick_ratio", "0.40");
register_cvar("amx_voteban_ratio", "0.40");
register_cvar("amx_votemap_ratio", "0.40");
register_cvar("amx_vote_ratio", "0.02");
register_cvar("amx_vote_time", "10");
register_cvar("amx_vote_answers", "1");
register_cvar("amx_vote_delay", "60");
register_cvar("amx_last_voting", "0");
register_cvar("amx_show_activity", "2", FCVAR_PROTECTED);
register_cvar("amx_password_field", "_pw",FCVAR_PROTECTED);
#if defined CUSTOM_DEF_FLAG
register_cvar("amx_default_access", "z", FCVAR_PROTECTED);
#endif
register_cvar("admin_loader_version", PLUGIN_VERSION, FCVAR_SERVER | FCVAR_SPONLY);
}

RegisterSqlCfg()
{
register_cvar("amx_sql_table", "admins", FCVAR_PROTECTED);
register_cvar("amx_sql_host", "127.0.0.1", FCVAR_PROTECTED);
register_cvar("amx_sql_user", "root", FCVAR_PROTECTED);
register_cvar("amx_sql_pass", "", FCVAR_PROTECTED);
register_cvar("amx_sql_db", "amx", FCVAR_PROTECTED);
register_cvar("amx_sql_type", "mysql", FCVAR_PROTECTED);
}

RegisterFreshBans(fbcfg[])
{
g_iBanSystem = 1;
register_cvar("fb_sql_host", "", FCVAR_PROTECTED);
register_cvar("fb_sql_user", "", FCVAR_PROTECTED);
register_cvar("fb_sql_pass", "", FCVAR_PROTECTED);
register_cvar("fb_sql_db", "", FCVAR_PROTECTED);
register_cvar("fb_servers_table", "", FCVAR_PROTECTED);
register_cvar("fb_server_ip", "");
register_cvar("fb_server_port", "");
ExecCfg(fbcfg);
}

RegisterLiteBans(lbcfg[])
{
g_iBanSystem = 2;
register_cvar("lb_sql_host", "", FCVAR_PROTECTED);
register_cvar("lb_sql_user", "", FCVAR_PROTECTED);
register_cvar("lb_sql_pass", "", FCVAR_PROTECTED);
register_cvar("lb_sql_db", "", FCVAR_PROTECTED);
register_cvar("lb_sql_pref", "", FCVAR_PROTECTED);
register_cvar("lb_server_ip", "");
ExecCfg(lbcfg);
}

ExecConfigs(amxxcfgdir[])
{
new szFullDir[128];
formatex(szFullDir, charsmax(szFullDir), "%s/amxx.cfg", amxxcfgdir);
ExecCfg(szFullDir);
formatex(szFullDir, charsmax(szFullDir), "%s/sql.cfg", amxxcfgdir);
RegisterSqlCfg(); ExecCfg(szFullDir);

formatex(g_szBackupAdminPath, charsmax(g_szBackupAdminPath), "%s/users.ini", amxxcfgdir);
}

ReadCvars()
{
get_cvar_string("amx_password_field", g_szPassField, charsmax(g_szPassField));
#if defined CUSTOM_DEF_FLAG
new szDefaultAccess[32];
get_cvar_string("amx_default_access", szDefaultAccess, charsmax(szDefaultAccess));
g_bitDefaultAccess = read_flags(szDefaultAccess);
#endif
set_cvar_float("amx_last_voting", 0.0);
#if AMXX_VERSION_NUM < 183
set_task(6.1, "LoadMapConfigs");
#endif
}

RegForwards()
{
for(new plId, plNum = get_pluginsnum(); plId < plNum; plId++)
{
if(g_fwdHandle[AdminLoad] == INVALID_HANDLE)
{
if(get_func_id("client_admin", plId) != -1)
g_fwdHandle[AdminLoad] = CreateMultiForward("client_admin", ET_IGNORE, FP_CELL, FP_CELL);
}
if(g_fwdHandle[AdminLoad2] == INVALID_HANDLE)
{
if(get_func_id("amxx_admin_access", plId) != -1)
g_fwdHandle[AdminLoad2] = CreateMultiForward("amxx_admin_access", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL);
}
}
}

SqlInit()
{
new sHost[32], sUser[32], sPasswd[64], sDbName[32];
switch(g_iBanSystem)
{
case 1:
{
get_cvar_string("fb_sql_host", sHost, charsmax(sHost));
get_cvar_string("fb_sql_user", sUser, charsmax(sUser));
get_cvar_string("fb_sql_pass", sPasswd, charsmax(sPasswd));
get_cvar_string("fb_sql_db", sDbName, charsmax(sDbName));

new ip[16]; get_cvar_string("fb_server_ip", ip, charsmax(ip));
new port[8]; get_cvar_string("fb_server_port", port, charsmax(port));
formatex(g_szServerData[IP], charsmax(g_szServerData[IP]), "%s:%s", ip, port);

get_cvar_string("fb_servers_table", g_szSqlData[ServerInfo], charsmax(g_szSqlData[ServerInfo]));
strtok(g_szSqlData[ServerInfo], g_szSqlData[Prefix], charsmax(g_szSqlData[Prefix]), "", 0, '_');
}
case 2:
{
get_cvar_string("lb_sql_host", sHost, charsmax(sHost));
get_cvar_string("lb_sql_user", sUser, charsmax(sUser));
get_cvar_string("lb_sql_pass", sPasswd, charsmax(sPasswd));
get_cvar_string("lb_sql_db", sDbName, charsmax(sDbName));

get_cvar_string("lb_server_ip", g_szServerData[IP], charsmax(g_szServerData[IP]));
get_cvar_string("lb_sql_pref", g_szSqlData[Prefix], charsmax(g_szSqlData[Prefix]));

formatex(g_szSqlData[ServerInfo], charsmax(g_szSqlData[ServerInfo]), "%s_serverinfo", g_szSqlData[Prefix]);
}
}

SQL_SetAffinity("mysql");
g_hSqlTuple = SQL_MakeDbTuple(sHost, sUser, sPasswd, sDbName, 1);


new errcode, errstr[128], Handle:hSqlTest = SQL_Connect(g_hSqlTuple, errcode, errstr, charsmax(errstr));
if(hSqlTest == Empty_Handle)
{
log_amx("[Проблемы с БД. Код ошибки: #%d] Ошибка: %s", errcode, errstr);
LoadBackUp(0);
}
else
{
SQL_FreeHandle(hSqlTest);
#if AMXX_VERSION_NUM >= 183
SQL_SetCharset(g_hSqlTuple, "utf8");
#endif
adminSql(0);
}
}

ExecCfg(const cfg[])
{
server_cmd("exec %s", cfg);
server_exec();
}

ExecuteFwd(id, flags, timestamp)
{
new ret;
if(g_fwdHandle[AdminLoad] != INVALID_HANDLE)
ExecuteForward(g_fwdHandle[AdminLoad], ret, id, flags);
if(g_fwdHandle[AdminLoad2] != INVALID_HANDLE)
ExecuteForward(g_fwdHandle[AdminLoad2], ret, id, flags, timestamp);
}

BackUpAdmins()
{
unlink(g_szBackupAdminPath);

new fp = fopen(g_szBackupAdminPath, "w+");
new szDate[30]; get_time("%d.%m.%Y - %H:%M:%S", szDate, charsmax(szDate));
if(!fprintf(fp, "; BackUP SQL admins. Date %s ^n^n", szDate))
{
fclose(fp);
return;
}
for(new i, sAFlags[30], sCFlags[10], szTime[25], aSize = ArraySize(g_aUsers); i < aSize; i++)
{
ArrayGetArray(g_aUsers, i, g_sUser);
get_flags(g_sUser[Access], sAFlags, charsmax(sAFlags));
get_flags(g_sUser[Flags], sCFlags, charsmax(sCFlags));

if(g_sUser[Expired])
format_time(szTime, charsmax(szTime), "%d.%m.%Y - %H:%M:%S", g_sUser[Expired]);
else formatex(szTime, charsmax(szTime), "lifetime");

fprintf(fp,
"^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",
g_sUser[Auth], g_sUser[Passwd], sAFlags, sCFlags, g_sUser[Nick], szTime
);
}
fclose(fp);
}

LoadBackUp(index)
{
new fp = fopen(g_szBackupAdminPath, "rt");
if(!fp)
{
log_amx("Файл '%s' не найден, либо невозможно прочитать! Администраторы НЕ загружены!", g_szBackupAdminPath);
return;
}
else ArrayClear(g_aUsers);

new szBuffer[200];
new szBuff[3][64];
new load, systime = get_systime();
while(!feof(fp))
{
fgets(fp, szBuffer, charsmax(szBuffer));
trim(szBuffer);

if(!szBuffer[0] || szBuffer[0] == ';')
continue;

if(parse(szBuffer,
g_sUser[Auth], charsmax(g_sUser[Auth]),
g_sUser[Passwd], charsmax(g_sUser[Passwd]),
szBuff[0], charsmax(szBuff[]),
szBuff[1], charsmax(szBuff[]),
g_sUser[Nick], charsmax(g_sUser[Nick]),
szBuff[2], charsmax(szBuff[])
) == 6
)
{
g_sUser[Access] = read_flags(szBuff[0]);
g_sUser[Flags] = read_flags(szBuff[1]);
g_sUser[Expired]= (strcmp(szBuff[2], "lifetime") == 0) ? 0 : parse_time(szBuff[2], "%d.%m.%Y - %H:%M:%S");

if(!g_sUser[Expired] || g_sUser[Expired] > systime)
{
ArrayPushArray(g_aUsers, g_sUser);
load++;
}
}
}
fclose(fp);

new szInfoMessage[190];
if(!load)
formatex(szInfoMessage, charsmax(szInfoMessage), "Ни одного администратора не найдено в users.ini или запись некорретна");
else if(load == 1)
formatex(szInfoMessage, charsmax(szInfoMessage), "Загружен 1 администратор из users.ini");
else formatex(szInfoMessage, charsmax(szInfoMessage), "Загружено %d администраторов из users.ini", load);


if(index) console_print(index, szInfoMessage);
log_amx(szInfoMessage);
}
Ситуация такая, фрешбанс конектиться к БД и с ним(вроде как) всё хорошо, но подключил я admin loader с ним ошибка такая.
В бан-листе сервер отображается, баны есть.(Вдруг пригодиться)
Подскажите куда копать?
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
2,143
Реакции
1,225
Помог
44 раз(а)
Wolf228, данный плагин берет данный подключения с плагинов бансистем. В Вашем случае - с FreshBans.
Пришлите под хайдом мне файл main.cfg из папки configs/fb без пароля в БД.
 
Сообщения
103
Реакции
5
Помог
2 раз(а)
Minni,
Скрытое содержимое для пользователей: Minni
 
Сообщения
2,143
Реакции
1,225
Помог
44 раз(а)
Wolf228, игрохост или собственный VDS/VPS?
 
Сообщения
103
Реакции
5
Помог
2 раз(а)
Minni, игрохост
Но уже не актульно, так как сделал всё на VDS, и всё отлично работает.
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу