Top killer v1.3.1

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
26
Реакции
0
Ошибка
"09.08.2021 - 02:09:56" SQL connection failed
"09.08.2021 - 02:09:56" [ 2002 ] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ОС
Linux
Amx Mod X
AMX Mod X 1.9.0.5263
Билд
3.10.0.761-dev
ReGamedll
ReGameDLL version: 5.20.0.525-dev
Версия Metamod
Metamod-r v1.3.0.128, API
Список метамодулей
meta list
Currently loaded plugins:
description stat pend file vers src load unload
[ 1] Reunion RUN - reunion.so v0.1.92d ini Start Never
[ 2] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC5 ini ANY
[ 3] ReSemiclip RUN - resemiclip.so v2.3.9 ini ANY
[ 4] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5263 ini Start ANY
[ 5] WHBlocker RUN - whblocker.so v1.5.697 ini ANY
[ 6] ReSRDetector RUN - resrdetector.so v0.1.0 ini ANY
[ 7] Rechecker RUN - rechecker.so v2.7 ini ANY
[ 8] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5263 pl4 ANY
[ 9] CSX RUN - csx_amxx_i386.so v1.9.0.5263 pl4 ANY
[10] ReAPI RUN - reapi_amxx_i386.so v5.19.0.211-dev pl4 ANY Never
[11] MySQL RUN - mysql_amxx_i386.so v1.9.0.5263 pl4 ANY ANY
[12] VTC AMXX API RUN - VtcApi_amxx_i386.so v2017 RC pl4 ANY ANY
[13] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5263 pl4 ANY ANY
[14] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5263 pl4 ANY ANY
[15] Engine RUN - engine_amxx_i386.so v1.9.0.5263 pl4 ANY ANY
[16] SxGeo RUN - sxgeo_amxx_i386.so v2.2 pl4 ANY Never
[17] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.2 pl4 ANY Never
[18] Fun RUN - fun_amxx_i386.so v1.9.0.5263 pl4 ANY ANY
[19] AddToFullPack Manager RUN - addtofullpack_manager_amxx_i386.so v1.0.1 pl4 ANY ANY
19 plugins, 19 running
Список плагинов
amxx plugins
Currently loaded plugins:
name version author file status
[ 1] GameCMS_API v5.4.9 zhorzh78 gamecms_api.amx running
[ 2] GameCMS_GagManager v2.2.3 Vtc_ zhorzh78 gagmanager.amxx running
[ 3] FreshBans v1.4.5b kanagava fresh_bans.amxx running
[ 4] Plugins Core v1.0.5 Radius plugins_core.am running
[ 5] DopBan v3.0.3b kanagava dop_ban.amxx running
[ 6] [190] Chat Controller v20.06.06 SKAJIbnEJIb chat_controller running
[ 7] [190] Army Ranks Ultim v20.06.06 SKAJIbnEJIb army_ranks_ulti running
[ 8] [183] Ad From Server v19.08.29 SKAJIbnEJIb ad_from_server. running
[ 9] [190] Skill ELO v20.06.06 SKAJIbnEJIb skill_elo.amxx running
[ 10] [190] AdminChat RBS v20.06.06 SKAJIbnEJIb adminchat_rbs.a running
[ 11] [190] AdminCmd RBS v20.06.06 SKAJIbnEJIb & AM admincmd_rbs.am running
[ 12] AmxSwapTeam v1.1 b0t. AmxxSwapTeam.am running
[ 13] [190] CsStats MySQL v20.06.06 SKAJIbnEJIb csstats_mysql.a running
[ 14] [190] Stats Configurat v20.06.06 SKAJIbnEJIb & AM statscfg_rbs.am running
[ 15] [190] StatsX RBS v21.03.23 SKAJIbnEJIb & AM statsx_rbs.amxx running
[ 16] [190] CsStats ResetSco v20.06.06 SKAJIbnEJIb csstats_resetsc running
[ 17] [190] CsStats Editor v20.06.06 SKAJIbnEJIb csstats_editor. running
[ 18] [190] VIP RBS v20.07.20 SKAJIbnEJIb vip_rbs.amxx running
[ 19] [190] Ultimate Flags v21.03.24BE SKAJIbnEJIb ultimate_flags. running
[ 20] [190] Ultimate Informe v21.03.23 SKAJIbnEJIb ultimate_inform running
[ 21] [190] Kill Assist RBS v20.06.06 SKAJIbnEJIb & Di killassist_rbs. running
[ 22] [190] Chat RBS v20.10.24BE SKAJIbnEJIb chat_rbs.amxx running
[ 23] [182] DemoRecorder RBS v20.06.06 SKAJIbnEJIb demorecorder_rb running
[ 24] ReAimDetector API v0.2.2 ReHLDS Team reaimdetector.a running
[ 25] Menus Front-End v20.06.06 SKAJIbnEJIb & AM amxmodmenu_rbs. running
[ 26] [190] Top Award RBS v20.06.06 SKAJIbnEJIb topaward_rbs.am running
[ 27] [190] AfkKicker RBS v20.08.02 SKAJIbnEJIb afkkicker_rbs.a running
[ 28] [190] High Ping Kicker v20.06.06 SKAJIbnEJIb hpk_rbs.amxx running
[ 29] [190] Radio RBS v20.06.06 SKAJIbnEJIb radio_rbs.amxx running
[ 30] AWP Restrictions v1.5.1 Radius awp_restriction running
[ 31] Bullet Damage COLORed v0.0.3 ConnorMcLeod / L bullet_damage3. running
[ 32] Team Control v1.6.8 Radius team_control.am running
[ 33] [ReAPI] Hint blocker v0.1.0 F@tn0M reapi_hint_bloc running
[ 34] Block 'Fire in the hol v0.1 Safety1st block_fire_in_t running
[ 35] [182] Parachute RBS v20.06.06 SKAJIbnEJIb & KR parachute_rbs.a running
[ 36] ReChecker Logging v1.0 custom rc_logging.amxx running
[ 37] Aliases checker v1.0.6 kanagava alias_checker.a running
[ 38] [HR] MapStart Random G v0.2 Hellr0ck hr_mapstart_ran running
[ 39] AntiFlash v2.1 Jack Daniel`s antiflash.amxx running
[ 40] Block Name Spam v0.1 s1lent block_name_spam running
[ 41] best_gamer v1.0 Got Milk? best_gamer.amxx running
[ 42] [190] Chat Addons v20.06.06 SKAJIbnEJIb chat_addons.amx running
[ 43] [190] BuyMenu RBS v21.03.23 SKAJIbnEJIb buymenu_rbs.amx running
[ 44] [190] RestMenu RBS v17.09.14 SKAJIbnEJIb & AM restmenu_rbs.am running
[ 45] Admin ESP Mini v1.5 KoST admin_esp_mini. running
[ 46] [190] Whois RBS v20.06.06 SKAJIbnEJIb whois_rbs.amxx running
[ 47] [183] Fast Hack Detect v19.03.12 Valer4 fast_hack_detec running
[ 48] [190] VoteBan RBS v20.06.06 SKAJIbnEJIb voteban_rbs.amx running
[ 49] Mode 2x2 v2.5re s1lent mode_2x2.amxx running
[ 50] AmxRegistryPlayers v1.3 b0t. AmxRegistryPlay running
[ 51] Top killer v1.3.1 uMk0 top_killer.amxx running
[ 52] Color Flash Screen v1.6.7 Radius (Stimul i color_flash_scr running
[ 53] From Rock to Ban v1.02 Safety1st++ rock2gag.amxx running
Автор плагина
uMk0
Версия плагина
Top killer v1.3.1
Исходный код
/*
[EN] Save nerve cells. You better look at cats https://youtu.be/hY7m5jjJ9mM I love you my friend, the best programmer 💋
[RU] Сохраните нервные клетки. Вы лучше посмотрите на кошек https://youtu.be/hY7m5jjJ9mM Люблю тебя мой друг, лучший программист 💋
[UA] Збережіть нервові клітини. Ви краще подивіться на кішок https://youtu.be/hY7m5jjJ9mM Люблю тебе мій друг, кращий програміст 💋
*/
#include <amxmodx>
#include <reapi>
#include <sqlx>
#define PLUGIN "Top killer"
#define VERSION "1.3.1"
#define AUTHOR "uMk0"
#define MULTI_LANGUAGE(%0) fmt("%L", LANG_SERVER, %0)
enum _:cvars{
CVAR_SQL_TYPE[10],
CVAR_SQL_HOST[128],
CVAR_SQL_USER[64],
CVAR_SQL_PASS[64],
CVAR_SQL_DB[64],
CVAR_SQL_TABLE_PREFIX[16],
CVAR_SQL_CREATE_DB,
CVAR_SQL_MAXFAIL,

CVAR_FLAG[32],
CVAR_MIN_FRAGS,
CVAR_HOW_MANY_HOURS,
CVAR_GMT,
CVAR_TOP_LIMIT,
CVAR_USE_AD,
CVAR_LOG_WIN,
CVAR_LOG_DIR[32],
CVAR_LOG_NAME[32],
CVAR_LOG_IS_SINGLE_FILE,
CVAR_WINNER_RE_PARTICIPATE,

CVAR_WINNER[64],
CVAR_TIMESTAMP
}
enum _:sql_que_type{
SQL_INITDB,
SQL_CHECK_TABLE_OTHER,
SQL_ADD_OTHER_ROWS,
SQL_GET_PLAYER,
SQL_ADD_PLAYER,
SQL_UPDATE_PLAYER,
SQL_GET_TOP,
SQL_GET_ME,
SQL_GET_MAX_FRAGS,
SQL_UPDATE_OTHER_ROWS,
SQL_CLEAR_CURRENT_DAY,
SQL_REMOVE_PLAYER
}
enum _:player_data_struct {
PLAYER_STEAMID[64],
PLAYER_NAME[32],
PLAYER_NAME_SQL[32],
PLAYER_FRAGS,
PLAYER_HS,
PLAYER_DEATH,
PLAYER_LOAD_STATS
}

const QUERY_LENGTH = 1472;
new cvar[cvars],
Handle:sql,
player[MAX_PLAYERS+1][player_data_struct],
bool:init_table = false,
logsDir[64],
dataDir[64],
cnt_sqlfail,
bool:gg_sql = false;
public plugin_init(){
register_plugin(PLUGIN,VERSION,AUTHOR);
RegisterHookChain(RG_CBasePlayer_Killed, "killed", true);
RegisterHookChain(RG_RoundEnd, "endRound", true);
register_clcmd("say /tk","getTop");
register_clcmd("say_team /tk","getTop");
register_clcmd("say /tame","getMe");
register_clcmd("say_team /tame","getMe");
set_task(60.0,"timer",0,_,_,"b");
register_dictionary("tk.txt");
register_dictionary("tk_cvars.txt");
create_cvar("tk", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY, MULTI_LANGUAGE("TK_CVAR_VERSION"));
bind_pcvar_string(create_cvar(
.name = "tk_sql_driver",
.string = "mysql",
.flags = FCVAR_UNLOGGED|FCVAR_PROTECTED,
.description = MULTI_LANGUAGE("TK_CVAR_SQL_DRIVER")
), cvar[CVAR_SQL_TYPE], charsmax(cvar[CVAR_SQL_TYPE]));
bind_pcvar_string(create_cvar(
.name = "tk_sql_host",
.string = "localhost",
.flags = FCVAR_UNLOGGED|FCVAR_PROTECTED,
.description = MULTI_LANGUAGE("TK_CVAR_SQL_HOST")
), cvar[CVAR_SQL_HOST], charsmax(cvar[CVAR_SQL_HOST]));
bind_pcvar_string(create_cvar(
.name = "tk_sql_user",
.string = "root",
.flags = FCVAR_UNLOGGED|FCVAR_PROTECTED,
.description = MULTI_LANGUAGE("TK_CVAR_SQL_USER")
), cvar[CVAR_SQL_USER], charsmax(cvar[CVAR_SQL_USER]));
bind_pcvar_string(create_cvar(
.name = "tk_sql_pass",
.string = "",
.flags = FCVAR_UNLOGGED|FCVAR_PROTECTED,
.description = MULTI_LANGUAGE("TK_CVAR_SQL_PASS")
), cvar[CVAR_SQL_PASS], charsmax(cvar[CVAR_SQL_PASS]));
bind_pcvar_string(create_cvar(
.name = "tk_sql_name",
.string = "amxx",
.flags = FCVAR_UNLOGGED|FCVAR_PROTECTED,
.description = MULTI_LANGUAGE("TK_CVAR_SQL_DB")
), cvar[CVAR_SQL_DB], charsmax(cvar[CVAR_SQL_DB]));
bind_pcvar_string(create_cvar(
.name = "tk_sql_table_prefix",
.string = "tk",
.flags = FCVAR_UNLOGGED|FCVAR_PROTECTED,
.description = MULTI_LANGUAGE("TK_CVAR_SQL_PREFIX")
), cvar[CVAR_SQL_TABLE_PREFIX], charsmax(cvar[CVAR_SQL_TABLE_PREFIX]));
bind_pcvar_num(create_cvar(
.name = "tk_sql_maxfail",
.string = "10",
.flags = FCVAR_UNLOGGED|FCVAR_PROTECTED,
.description = MULTI_LANGUAGE("TK_CVAR_SQL_MAXFAIL"),
.has_min = true,
.min_val = 0.0
), cvar[CVAR_SQL_MAXFAIL]);
bind_pcvar_num(create_cvar(
.name = "tk_sql_create_db",
.string = "1",
.flags = FCVAR_UNLOGGED|FCVAR_PROTECTED,
.description = MULTI_LANGUAGE("TK_CVAR_SQL_CREATE_DB"),
.has_min = true,
.min_val = 0.0,
.has_max = true,
.max_val = 1.0
), cvar[CVAR_SQL_CREATE_DB]);


bind_pcvar_string(create_cvar(
.name = "tk_flags",
.string = "t",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_FLAG")
), cvar[CVAR_FLAG], charsmax(cvar[CVAR_FLAG]));
bind_pcvar_num(create_cvar(
.name = "tk_min_frags",
.string = "100",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_MIN_FRAGS"),
.has_min = true,
.min_val = 1.0
), cvar[CVAR_MIN_FRAGS]);
bind_pcvar_num(create_cvar(
.name = "tk_how_many_hours",
.string = "24",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_HOW_MANY_HOURS"),
.has_min = true,
.min_val = 1.0
), cvar[CVAR_HOW_MANY_HOURS]);
bind_pcvar_num(create_cvar(
.name = "tk_gmt",
.string = "3",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_GMT"),
.has_min = true,
.min_val = -12.0,
.has_max = true,
.max_val = 12.0
), cvar[CVAR_GMT]);
bind_pcvar_num(create_cvar(
.name = "tk_top_write",
.string = "8",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_TOP_LIMIT"),
.has_min = true,
.min_val = 1.0,
.has_max = true,
.max_val = 8.0
), cvar[CVAR_TOP_LIMIT]);
bind_pcvar_num(create_cvar(
.name = "tk_use_ad",
.string = "1",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_USE_AD"),
.has_min = true,
.min_val = 0.0,
.has_max = true,
.max_val = 1.0
), cvar[CVAR_USE_AD]);
bind_pcvar_num(create_cvar(
.name = "tk_log_win",
.string = "1",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_LOG_WIN"),
.has_min = true,
.min_val = 0.0,
.has_max = true,
.max_val = 1.0
), cvar[CVAR_LOG_WIN]);
bind_pcvar_string(create_cvar(
.name = "tk_log_dir",
.string = "tk",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_LOG_DIR")
), cvar[CVAR_LOG_DIR], charsmax(cvar[CVAR_LOG_DIR]));
bind_pcvar_string(create_cvar(
.name = "tk_log_name",
.string = "topkiller",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_LOG_NAME")
), cvar[CVAR_LOG_NAME], charsmax(cvar[CVAR_LOG_NAME]));
bind_pcvar_num(create_cvar(
.name = "tk_winner_re_participate",
.string = "1",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_WINNER_RE_PARTICIPATE"),
.has_min = true,
.min_val = 0.0,
.has_max = true,
.max_val = 1.0
), cvar[CVAR_WINNER_RE_PARTICIPATE]);
AutoExecConfig();

}
public plugin_cfg(){
get_localinfo("amxx_logs", logsDir, charsmax(logsDir));
get_localinfo("amxx_datadir",dataDir,charsmax(dataDir));
formatex(logsDir, charsmax(logsDir), "%s/%s", logsDir, cvar[CVAR_LOG_DIR]);
if(!dir_exists(logsDir)){
mkdir(logsDir);
}
if(!SQL_SetAffinity(cvar[CVAR_SQL_TYPE])){// Hi wopox3
new error_msg[128];
formatex(error_msg,charsmax(error_msg),"failed to use ^"%s^" for db driver",cvar[CVAR_SQL_TYPE]);
set_fail_state(error_msg);
return;
}
sql = SQL_MakeDbTuple(cvar[CVAR_SQL_HOST],cvar[CVAR_SQL_USER],cvar[CVAR_SQL_PASS],cvar[CVAR_SQL_DB])
SQL_SetCharset(sql,"utf8");
new query[QUERY_LENGTH * 2], sql_data[1];

sql_data[0] = SQL_INITDB;
if(cvar[CVAR_SQL_CREATE_DB]){
if(strcmp(cvar[CVAR_SQL_TYPE],"mysql") == 0){
formatex(query,charsmax(query),"\
CREATE TABLE IF NOT EXISTS `%s_stats` (\
`steamid` varchar(64) NOT NULL,\
`frags` int(11) NOT NULL DEFAULT '0',\
`name` varchar(32) NOT NULL,\
`hs` int(11) NOT NULL DEFAULT '0',\
`death` int(11) NOT NULL DEFAULT '0',\
PRIMARY KEY (`steamid`)) DEFAULT CHARSET=utf8;\
CREATE TABLE IF NOT EXISTS `%s_settings` (\
`key` varchar(32) NOT NULL,\
`param` varchar(64) NOT NULL\
);",cvar[CVAR_SQL_TABLE_PREFIX],cvar[CVAR_SQL_TABLE_PREFIX]);
}else if(strcmp(cvar[CVAR_SQL_TYPE],"sqlite") == 0){
formatex(query,charsmax(query),"\
CREATE TABLE IF NOT EXISTS `%s_stats` (\
`steamid` TEXT NOT NULL UNIQUE,\
`frags` INTEGER NOT NULL,\
`name` TEXT NOT NULL,\
`hs` INTEGER NOT NULL,\
`death` INTEGER NOT NULL\
);\
CREATE TABLE IF NOT EXISTS `%s_settings` (\
`key` TEXT NOT NULL UNIQUE,\
`param` TEXT NOT NULL\
);",cvar[CVAR_SQL_TABLE_PREFIX],cvar[CVAR_SQL_TABLE_PREFIX]);
}else{
set_fail_state("invalid ^"tk_sql_driver^" cvar value")
}
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
}else{
checkTableOther();
}
}
public client_disconnected(id){
savePlayer(id);
}
public client_putinserver(id){
player[id][PLAYER_LOAD_STATS] = 0;
get_user_authid(id, player[id][PLAYER_STEAMID], charsmax(player[][PLAYER_STEAMID]));
connectPlayer(id);
}
public connectPlayer(id){
if(!checkAccess(id) || !init_table || gg_sql)
return;

get_user_name(id, player[id][PLAYER_NAME], charsmax(player[][PLAYER_NAME]));
get_user_name(id, player[id][PLAYER_NAME_SQL], charsmax(player[][PLAYER_NAME_SQL]));
mysql_escape_string(player[id][PLAYER_NAME_SQL],charsmax(player[][PLAYER_NAME_SQL]));

if(strcmp(player[id][PLAYER_STEAMID],cvar[CVAR_WINNER]) == 0){
remove_user_flags(id, ADMIN_USER);
set_user_flags(id, read_flags(cvar[CVAR_FLAG]) | get_user_flags(id));
client_print_color(0,print_team_default,"%L %L",LANG_SERVER,"TK_TAG",LANG_SERVER,"TK_CONNECT_WINNER",player[id][PLAYER_NAME]);
}
new query[QUERY_LENGTH * 2],sql_data[2];
sql_data[0] = SQL_GET_PLAYER;
sql_data[1] = id;
formatex(query,charsmax(query),"\
SELECT * FROM `%s_stats` WHERE `steamid` LIKE '%s'",cvar[CVAR_SQL_TABLE_PREFIX],player[id][PLAYER_STEAMID]);

SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
}
public finishInitDB(){
for(new i; i < 33; i++){
if(is_user_connected(i))
connectPlayer(i);
}
}
public checkTableOther(){
if(gg_sql) return;
new query[QUERY_LENGTH * 2], sql_data[1];

sql_data[0] = SQL_CHECK_TABLE_OTHER;

formatex(query,charsmax(query),"\
SELECT * FROM `%s_settings`",cvar[CVAR_SQL_TABLE_PREFIX]);

SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
}
public addOtherRows(){
if(gg_sql) return;
new query[QUERY_LENGTH * 2];

new sql_data[1]
sql_data[0] = SQL_ADD_OTHER_ROWS;

formatex(query,charsmax(query),"\
INSERT INTO `%s_settings` (`key`, `param`) VALUES ('winner', '0');\
INSERT INTO `%s_settings` (`key`, `param`) VALUES ('timestamp', '%d');",cvar[CVAR_SQL_TABLE_PREFIX],cvar[CVAR_SQL_TABLE_PREFIX],getNextDate());

SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);

cvar[CVAR_WINNER] = "0";
cvar[CVAR_TIMESTAMP] = getNextDate();

}
public killed(iVictim, iAttacker){
if(!player[iAttacker][PLAYER_LOAD_STATS] || iVictim == iAttacker)return;

player[iAttacker][PLAYER_FRAGS]++;

if(get_member(iVictim, m_bHeadshotKilled)){
player[iAttacker][PLAYER_HS]++;
}
if(player[iVictim][PLAYER_LOAD_STATS]){
player[iVictim][PLAYER_DEATH]++;
}
}
public timer(){
if(!init_table) return;
if(get_systime() > cvar[CVAR_TIMESTAMP]){
if(gg_sql) return;
cvar[CVAR_TIMESTAMP] = getNextDate();
new query[QUERY_LENGTH * 2],sql_data[1];

sql_data[0] = SQL_GET_MAX_FRAGS;
formatex(query,charsmax(query),"\
SELECT * FROM `%s_stats` ORDER BY `frags` DESC, `hs` DESC, `death` ASC LIMIT 0, 1;",cvar[CVAR_SQL_TABLE_PREFIX]);
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
}
if(cvar[CVAR_USE_AD] == 1){
client_print_color(0,print_team_default,"%L %L",LANG_SERVER,"TK_TAG",LANG_SERVER,"TK_AD");
client_print_color(0,print_team_default,"%L Узнать кто в топе можно ^4командой /tk",LANG_SERVER,"TK_TAG");
}
}
public endRound() set_task(0.5,"savePlayerAll");
public savePlayerAll(){
for(new i; i < 33; i++){
if(is_user_connected(i))
savePlayer(i)
}
}
public savePlayer(id){
if(!player[id][PLAYER_LOAD_STATS])
return;

new query[QUERY_LENGTH * 2], sql_data[1];
sql_data[0] = SQL_UPDATE_PLAYER;

formatex(query,charsmax(query),"\
UPDATE `%s_stats` SET `frags` = '%d', `name` = '%s', `hs` = '%d', `death` = '%d' WHERE `steamid` LIKE '%s';",
cvar[CVAR_SQL_TABLE_PREFIX],player[id][PLAYER_FRAGS],player[id][PLAYER_NAME_SQL],player[id][PLAYER_HS],player[id][PLAYER_DEATH],player[id][PLAYER_STEAMID]);
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
}
public getTop(id){
if(gg_sql) return;
new query[QUERY_LENGTH * 2],sql_data[2];

sql_data[0] = SQL_GET_TOP;
sql_data[1] = id;
formatex(query,charsmax(query),"\
SELECT * FROM `%s_stats` ORDER BY `frags` DESC, `hs` DESC, `death` ASC LIMIT 0, %d;",cvar[CVAR_SQL_TABLE_PREFIX],cvar[CVAR_TOP_LIMIT]);
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
}
public getMe(id){
if(gg_sql) return;
if(!player[id][PLAYER_LOAD_STATS])
return;
new query[QUERY_LENGTH * 2], sql_data[2];

sql_data[0] = SQL_GET_ME;
sql_data[1] = id;
formatex(query,charsmax(query),"\
SELECT * FROM `%s_stats` ORDER BY `frags` DESC, `hs` DESC, `death` ASC;",cvar[CVAR_SQL_TABLE_PREFIX]);

SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
}
public addPlayerAll(){
for(new i; i < 33; i++){
if(is_user_connected(i))
addPlayer(i)
}
}
public addPlayer(id){
if(gg_sql) return;
if(!player[id][PLAYER_LOAD_STATS])
return;
new query[QUERY_LENGTH * 2], sql_data[1];
sql_data[0] = SQL_ADD_PLAYER;

formatex(query,charsmax(query),"\
INSERT INTO `%s_stats` (`steamid`, `frags`, `name`, `hs`, `death`) VALUES ('%s', '0', '%s', '0', '0');",
cvar[CVAR_SQL_TABLE_PREFIX],player[id][PLAYER_STEAMID],player[id][PLAYER_NAME_SQL]);
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
player[id][PLAYER_FRAGS] = 0;
player[id][PLAYER_HS] = 0;
player[id][PLAYER_DEATH] = 0;
}
public SQL_Handler(failstate,Handle:sqlQue,err[],errNum,data[],dataSize){
switch(failstate){
case TQUERY_CONNECT_FAILED:{
logging(logsDir, cvar[CVAR_LOG_NAME],"SQL connection failed");
logging(logsDir, cvar[CVAR_LOG_NAME],"[ %d ] %s",errNum,err);
cnt_sqlfail++;
if(cnt_sqlfail >= cvar[CVAR_SQL_MAXFAIL] && !gg_sql){
logging(logsDir, cvar[CVAR_LOG_NAME],"db query is disabled for this map")
gg_sql = true
}
return PLUGIN_HANDLED
}
case TQUERY_QUERY_FAILED:{
new lastQue[QUERY_LENGTH]
SQL_GetQueryString(sqlQue,lastQue,charsmax(lastQue)) // find out the last SQL query
logging(logsDir, cvar[CVAR_LOG_NAME],"SQL query failed");
logging(logsDir, cvar[CVAR_LOG_NAME],"[ %d ] %s",errNum,err);
logging(logsDir, cvar[CVAR_LOG_NAME],"[ SQL ] %s",lastQue);
cnt_sqlfail++;
if(cnt_sqlfail >= cvar[CVAR_SQL_MAXFAIL] && !gg_sql){
logging(logsDir, cvar[CVAR_LOG_NAME],"db query is disabled for this map")
gg_sql = true
}
return PLUGIN_HANDLED
}
}
switch(data[0]){
case SQL_INITDB:{
checkTableOther();
return PLUGIN_HANDLED;
}
case SQL_CHECK_TABLE_OTHER:{
if(!SQL_NumResults(sqlQue)){
addOtherRows();
}else{
SQL_ReadResult(sqlQue, 1, cvar[CVAR_WINNER], charsmax(cvar[CVAR_WINNER]));
SQL_NextRow(sqlQue)
cvar[CVAR_TIMESTAMP] = SQL_ReadResult(sqlQue, 1)
}
init_table = true;
finishInitDB();
return PLUGIN_HANDLED;
}
case SQL_GET_PLAYER:{

player[data[1]][PLAYER_LOAD_STATS] = 1;
if(!SQL_NumResults(sqlQue)){
addPlayer(data[1]);
}else{
player[data[1]][PLAYER_FRAGS] = SQL_ReadResult(sqlQue,1);
player[data[1]][PLAYER_HS] = SQL_ReadResult(sqlQue,3);
player[data[1]][PLAYER_DEATH] = SQL_ReadResult(sqlQue,4);
}
return PLUGIN_HANDLED;
}
case SQL_GET_TOP: {
if(SQL_NumResults(sqlQue)){
new templateFile[96], iFileID, template[1220], len, bufferTpl[700];
formatex(templateFile, charsmax(templateFile), "%s/tk_template.html", dataDir);
iFileID = fopen(templateFile, "rt");
for(new i = 0; i < SQL_NumResults(sqlQue); i++){
new player_name[32], frags, hs, death;
frags = SQL_ReadResult(sqlQue, 1);
hs = SQL_ReadResult(sqlQue, 3);
death = SQL_ReadResult(sqlQue, 4);
SQL_ReadResult(sqlQue, 2, player_name, charsmax(player_name));
SQL_NextRow(sqlQue);
new Float:kd = float(frags), Float:hs_percentage = 0.0;
if(death > 0 && frags > 0){
kd = float(frags)/float(death);
}
if(frags > 0 && hs > 0){
hs_percentage = (float(hs)*100)/float(frags);
}
len += formatex(template[len],charsmax(template) - len,"<tr><td>%d</td><td>%s</td><td>%d</td><td>%d (%.1f%%)</td><td>%d</td><td>%.2f</td>",(i+1), player_name, frags, hs, hs_percentage, death, kd)
}
fread_blocks(iFileID, bufferTpl, charsmax(bufferTpl), BLOCK_CHAR);
fclose(iFileID);
new resultTpl[charsmax(template)+charsmax(bufferTpl)+1];
formatex(resultTpl,charsmax(resultTpl),bufferTpl,LANG_SERVER,"TK_TPL_NAME",LANG_SERVER,"TK_TPL_FRAGS",LANG_SERVER,"TK_TPL_HS",LANG_SERVER,"TK_TPL_DEATH",template);
show_motd(data[1],resultTpl,"TopKiller");
}
return PLUGIN_HANDLED;
}
case SQL_GET_ME: {
for(new i = 0; i < SQL_NumResults(sqlQue); i++){
new steamid[64];
SQL_ReadResult(sqlQue, 0, steamid, charsmax(steamid));
if(strcmp(player[data[1]][PLAYER_STEAMID],steamid) == 0){
client_print_color(data[1],print_team_default,"%L %L",LANG_SERVER,"TK_TAG",LANG_SERVER,"TK_ME", (i+1), player[data[1]][PLAYER_FRAGS], player[data[1]][PLAYER_HS], player[data[1]][PLAYER_DEATH]);
break;
}
SQL_NextRow(sqlQue);
}
return PLUGIN_HANDLED;
}
case SQL_GET_MAX_FRAGS: {
if(SQL_NumResults(sqlQue)){
new frags;
frags = SQL_ReadResult(sqlQue, 1);
if(frags >= cvar[CVAR_MIN_FRAGS]){
new player_name[32], hs, death;
SQL_ReadResult(sqlQue, 0, cvar[CVAR_WINNER], charsmax(cvar[CVAR_WINNER]));
SQL_ReadResult(sqlQue, 2, player_name, charsmax(player_name));
hs = SQL_ReadResult(sqlQue, 3);
death = SQL_ReadResult(sqlQue, 4);
client_print_color(0,print_team_default,"%L %L",LANG_SERVER,"TK_TAG",LANG_SERVER,"TK_WINNER", player_name, frags, hs, death);
if(cvar[CVAR_LOG_WIN]){
logging(logsDir, cvar[CVAR_LOG_NAME], "%L", LANG_SERVER, "TK_WINNER_LOG", player_name, frags, cvar[CVAR_WINNER]);
}
}else{
client_print_color(0,print_team_default,"%L %L",LANG_SERVER,"TK_TAG",LANG_SERVER,"TK_NOT_WINNER");
if(cvar[CVAR_LOG_WIN]){
logging(logsDir, cvar[CVAR_LOG_NAME], "%L", LANG_SERVER,"TK_NOT_WINNER");
}
}
}else{
cvar[CVAR_WINNER] = 0;
}
new query[QUERY_LENGTH * 2],sql_data[1];

sql_data[0] = SQL_UPDATE_OTHER_ROWS;
formatex(query,charsmax(query),"\
UPDATE `%s_settings` SET `param` = '%s' WHERE `key` LIKE 'winner';\
UPDATE `%s_settings` SET `param` = '%d' WHERE `key` LIKE 'timestamp';",cvar[CVAR_SQL_TABLE_PREFIX],cvar[CVAR_WINNER],cvar[CVAR_SQL_TABLE_PREFIX], cvar[CVAR_TIMESTAMP]);
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
return PLUGIN_HANDLED;
}
case SQL_UPDATE_OTHER_ROWS: {
new query[QUERY_LENGTH * 2],sql_data[1];

sql_data[0] = SQL_CLEAR_CURRENT_DAY;
formatex(query,charsmax(query),"\
DELETE FROM `%s_stats` WHERE `frags` >= 0;",cvar[CVAR_SQL_TABLE_PREFIX]);
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
return PLUGIN_HANDLED;
}
case SQL_CLEAR_CURRENT_DAY: {
addPlayerAll();
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED
}
stock getNextDate(){
new currentDate[32];
format_time(currentDate, charsmax(currentDate), "%m/%d/%Y 00:00:01", get_systime()+(cvar[CVAR_GMT]*3600));
return (parse_time(currentDate, "%m/%d/%Y %H:%M:%S")-(cvar[CVAR_GMT]*3600)+(cvar[CVAR_HOW_MANY_HOURS]*3600));
}
stock checkAccess(id){
if(strcmp(player[id][PLAYER_STEAMID],cvar[CVAR_WINNER]) == 0) return cvar[CVAR_WINNER_RE_PARTICIPATE];

if(is_user_hltv(id) || is_user_bot(id) || get_user_flags(id) & read_flags(cvar[CVAR_FLAG])) return false;
return true;
}
stock logging(const sLogsDir[], const sFileName[], const sMessage[], any:... ){
new sFmtMsg[512], sLogFile[96], sRecordTime[32], iFileID;
vformat(sFmtMsg, charsmax(sFmtMsg), sMessage, 4);

if(cvar[CVAR_LOG_IS_SINGLE_FILE] < 1){
new sFileTime[32];
get_time("%d.%m.%Y", sFileTime, charsmax(sFileTime));
formatex(sLogFile, charsmax(sLogFile), "%s/%s_%s.log", sLogsDir, sFileName, sFileTime);
}else{
formatex(sLogFile, charsmax(sLogFile), "%s/%s.log", sLogsDir, sFileName);
}

iFileID = fopen(sLogFile, "at");
get_time("%d.%m.%Y - %H:%M:%S", sRecordTime, charsmax(sRecordTime));
fprintf(iFileID, "^"%s^" %s^n", sRecordTime, sFmtMsg);
fclose(iFileID);
}
stock mysql_escape_string(dest[],len){
replace_all(dest,len,"\\","\\\\");
replace_all(dest,len,"\0","\\0");
replace_all(dest,len,"\n","\\n");
replace_all(dest,len,"\r","\\r");
replace_all(dest,len,"\x1a","\Z");
replace_all(dest,len,"'","''");
replace_all(dest,len,"^"","^"^"");
}
public plugin_natives(){
register_native("tk_check_win_player", "_check_win_player", 1);
register_native("tk_get_frags", "_get_frags", 1);
register_native("tk_get_hs", "_get_frags", 1);
register_native("tk_get_death", "_get_frags", 1);
}
public _check_win_player(id){
if(is_user_hltv(id) || is_user_bot(id)) return false;
if(strcmp(player[id][PLAYER_STEAMID],cvar[CVAR_WINNER]) == 0) return true;
return false;
}
public _get_frags(id){
if(player[id][PLAYER_LOAD_STATS] == 0) return false;
return player[id][PLAYER_FRAGS];
}
public _get_hs(id){
if(player[id][PLAYER_LOAD_STATS] == 0) return false;
return player[id][PLAYER_HS];
}
public _get_death(id){
if(player[id][PLAYER_LOAD_STATS] == 0) return false;
return player[id][PLAYER_DEATH];
}
forward fbans_player_banned_pre(const id, const userid, const steamid[],
const ip[], const name[], const admin_ip[],
const admin_steamid[], const admin_name[], const ban_type[],
const reason[], const bantime);
public fbans_player_banned_pre(const id, const userid, const steamid[],
const ip[], const name[], const admin_ip[],
const admin_steamid[], const admin_name[], const ban_type[],
const reason[], const bantime){
if(!id || !is_user_connected(id) || get_user_userid(id)!=userid || !player[id][PLAYER_LOAD_STATS] || ((bantime + get_systime()) <= cvar[CVAR_TIMESTAMP] && bantime != 0)) return;

new query[QUERY_LENGTH * 2], sql_data[1];
sql_data[0] = SQL_REMOVE_PLAYER;
formatex(query,charsmax(query),"\
DELETE FROM `%s_stats` WHERE `steamid` = '%s'",
cvar[CVAR_SQL_TABLE_PREFIX],player[id][PLAYER_STEAMID]);
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
return;
}
Он то работает, то нет, при перезагрузки выбивает такое постоянно, но при смене карты вроде стабилизируется
 
В этой теме было размещено решение! Перейти к решению.

RockTheStreet

Саппорт года
Сообщения
1,743
Реакции
344
Помог
40 раз(а)
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
Конфиг плагина в студию.
 

RockTheStreet

Саппорт года
Сообщения
1,743
Реакции
344
Помог
40 раз(а)
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
Apollon, В tk_sql_host что указано?
 
Сообщения
26
Реакции
0
RockTheStreet, Адрес сервера БД,потом я пробовал как ты и советовал 127.0.0.1 не то и не то не подходит
 

RockTheStreet

Саппорт года
Сообщения
1,743
Реакции
344
Помог
40 раз(а)
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
Указать в конфиге, перезагрузить полностью сервер и посмотреть что выводит tk_sql_host из под консоли. Также проверить, логи те же самые или уже другие ошибки идут.
 
Сообщения
26
Реакции
0
RockTheStreet,
"09.08.2021 - 13:54:01" SQL connection failed
"09.08.2021 - 13:54:01" [ 2002 ] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
"09.08.2021 - 13:54:13" SQL connection failed
"09.08.2021 - 13:54:13" [ 2003 ] Can't connect to MySQL server on '127.0.0.1' (111)

кроме этого у него нет не каких больше ошибок
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
@Apollon,сервер где стоит?
 
Сообщения
775
Реакции
293
Помог
11 раз(а)
Apollon, ты к какой базе данных подключаешься? если та что вместе с сервером идет, то там вроде ip сервера (без порта)
 

RockTheStreet

Саппорт года
Сообщения
1,743
Реакции
344
Помог
40 раз(а)
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
"09.08.2021 - 13:54:13" [ 2003 ] Can't connect to MySQL server on '127.0.0.1' (111)
Ну так ошибка другая уже, а не точно такая же. Так зачем было вводить в заблуждение, когда я спрашивал в теме плагина?
Вероятнее всего БД находится не на локальном сервере, а на удалённом. Тем не менее, проблема не в плагине, а в отсутствии знаний по подключению БД у Владельца сервера.
 
Сообщения
26
Реакции
0
@RockTheStreet,разница то в чем?мне ваши ответы не помогли исправить причину.
 
Сообщения
391
Реакции
106
Помог
2 раз(а)
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
Apollon, в панели управления csserver у тебя указан ip адрес БД...Какой?
 
Сообщения
103
Реакции
4
@Apollon,такая же
"09.08.2021 - 02:09:56" SQL connection failed
"09.08.2021 - 02:09:56" [ 2002 ] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
но випку выдает, прям в тех же логах написано кто победитель, проверьте лог файлы, может всё таки работает плагин...
10 Авг 2021
RockTheStreet, как модт окно настроить? ато сплошные иероглифы если написать /tk :sad:
 
Сообщения
391
Реакции
106
Помог
2 раз(а)
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
Lady,
Видимо автор не хочет обновлять ресурс. Мне в личке давал исправление. Кодировку править надо...

Код:
<meta charset=UTF-8><style>body{color:#ddd;background:#111}table{border:0}table thead th{font-weight:bold;text-align:left;border:0;padding:10px 15px;background:#333;font-size:14px}table thead tr th:first-child{border-radius:8px 0 0 8px}table thead tr th:last-child{border-radius:0 8px 8px 0}table tbody td{text-align:left;border:0;padding:10px 15px;font-size:14px;vertical-align:top}table tbody tr:nth-child(even){background:#222}table tbody tr td:first-child{border-radius:8px 0 0 8px}table tbody tr td:last-child{border-radius:0 8px 8px 0}</style></head><body><table width=100%%><thead><th>#</th><th>%L</th><th>%L</th><th>%L</th><th>%L</th><th>K:D</th></thead><tbody>%s</tbody></table><body>


в tk_template.html вместо текущего содержимого
 
Сообщения
26
Реакции
0
@Lady,Ошибки всеровно не должны быть, раз правильно настроен. Он тоже у меня пишет, но только не пойму почему после рестарт сервера выдает ошибку.

"09.08.2021 - 02:09:56" SQL connection failed
"09.08.2021 - 02:09:56" [ 2002 ] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
 
Статус
В этой теме нельзя размещать новые ответы.

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

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