криво работает Top Killer

Сообщения
182
Реакции
9
Ошибка
ошибок в логах нету
ОС
Linux
Amx Mod X
AMX Mod X 1.9.0.5294
Билд
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.11.0.777-dev
Build date: 21:17:20 Jun 29 2022 (3000)
ReGamedll
ReGameDLL version: 5.21.0.546-dev
Build date: 15:32:48 Dec 28 2021
Версия Metamod
Metamod-r v1.3.0.130-dev, API (5:13)
Metamod-r build: 00:54:51 Jul 1 2022
Список метамодулей
[ 1] Reunion RUN - reunion_mm_i386.so v0.1.92d ini Start Never
[ 2] Rechecker RUN - rechecker_mm_i386.so v2.7 ini Chlvl ANY
[ 3] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 4] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 5] SafeNameAndChat RUN - SafeNameAndChat.so v1.2 Beta 3 ini ANY ANY
[ 6] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC3 ini ANY ANY
[ 7] ReSRDetector RUN - resrdetector_mm_i386.so v0.1.0 ini Chlvl ANY
[ 8] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5294 ini Start ANY
[ 9] WHBlocker RUN - whblocker_mm_i386.so v1.5.697 ini Chlvl ANY
[10] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5294 pl8 ANY ANY
[11] MySQL RUN - mysql_amxx_i386.so v1.9.0.5294 pl8 ANY ANY
[12] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5294 pl8 ANY ANY
[13] ReAPI RUN - reapi_amxx_i386.so v5.21.0.252-dev pl8 ANY Never
[14] Engine RUN - engine_amxx_i386.so v1.9.0.5294 pl8 ANY ANY
[15] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5294 pl8 ANY ANY
[16] SxGeo RUN - sxgeo_amxx_i386.so v2.3 pl8 ANY Never
[17] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.2 pl8 ANY Never
17 plugins, 17 running
Список плагинов
[ 1] FreshBans 1.4.0b kanagava fresh_bans.amxx running
[ 2] DopBan 3.0.8b kanagava dop_ban308-(183 running
[ 3] Admin Loader 3.5 neygomon admin_loader.am running
[ 4] CSStatsX SQL 0.7.4+2 serfreeman1337 csstatsx_sql.am running
[ 5] Admin Commands 1.9.0.5294 AMXX Dev Team admincmd.amxx running
[ 6] Players Menu 1.9.0.5294 AMXX Dev Team plmenu.amxx running
[ 7] Maps Menu 1.9.0.5294 AMXX Dev Team mapsmenu.amxx running
[ 8] AES: Bonus CSTRIKE 0.5.9 [REA serfreeman1337/s aes_bonus_cstri running
[ 9] AES: CStrike Addon 0.5.9 [REA serfreeman1337/s aes_exp_cstrike running
[ 10] Advanced Experience Sy 0.5.9 [REA serfreeman1337/s aes_main.amxx running
[ 11] AES: StatsX 0.5.9 [REA serfreeman1337/s aes_statsx_cstr running
[ 12] AES: Informer 0.5.9 [REA serfreeman1337/s aes_informer.am running
[ 13] AES: StatsX Info Rank 0.1 serfreeman1337 aes_statsx_rank running
[ 14] AES Bonus: Flags 0.2 Sonyx aes_bonus_flags running
[ 15] Say me and Say hp 1.4 neygomon sayme_reapi.amx running
[ 16] ReChecker Logging 1.0 custom rc_logging.amxx running
[ 17] AFK Control 1.4.1 [Rnd neygomon afk_control.amx running
[ 18] Demo Recorder 2.4.1 F@nt0M demo_recorder.a running
[ 19] Server Menu 1.5.0 F@nt0M server_menu.amx running
[ 20] ScreenMaker 1.1 neygomon screen_maker.am running
[ 21] Ping Kicker 0.1 Emma Jule ping.amxx running
[ 22] [ReAPI] AdminFreeLook 1.0 ReHLDS Team adminfreelook.a running
[ 23] Simple Damager 2.1.0 fl0wer simple_damager. running
[ 24] [ReAPI] Best player of 1.1.2 F@nt0M best_player_of_ running
[ 25] Advanced Kill Assists 1.3d Xelson next21_kill_ass running
[ 26] resetscore(ReAPI) 1.0 Phantom resetscore.amxx running
[ 27] Parachute Lite [ReAPI] 11.0 Leo_[BH] parachute_lite. running
[ 28] Frags Counter 1.0 CHEL74 frags_counter.a running
[ 29] SF Bets 0.1.5 serfreeman1337 sf_bets.amxx running
[ 30] C4 Timer on roundtime 0.3.3a neygomon c4timer.amxx running
[ 31] [SxGeo] Connect Info 1.0 s1lent sxgeo_connect_i running
[ 32] unknown unknown unknown connect_music.a running
[ 33] Adverts 1.0 pUzzlik adverts_message running
[ 34] Models Replacement 0.0.2+fix ConnorMcLeod | V models_replacem running
[ 35] Auto Team Balance Adva 1.5.1 Radius auto_team_balan running
[ 36] Lite VoteBan 1.4 neygomon lite_voteban.am running
[ 37] Killer ScreenFade 0.0.5 Vaqtincha reapi_killer_sc running
[ 38] [GM] VIP Test 1.2.0 [GM] NWC gm_vip_test.amx running
[ 39] Top Awards 0.11c Safety1st top_awards.amxx running
[ 40] Check Menu 1.3 mx?! check_menu.amxx running
[ 41] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a running
[ 42] Revive/Mined Die Playe 2.3.9 Emma Jule revive_teammate running
[ 43] Custom Smoke 1.09 bionext custom_smoke.am running
[ 44] [190] BonusTime RBS 20.08.08 SKAJIbnEJIb bonustime_rbs.a running
[ 45] Top killer 1.3.2.1 uMk0 topkiller.amxx running
[ 46] ChatAdditions: Core v1.9.1 Sergey Shorokhov ChatAdditions_C running
[ 47] ChatAdditions: CSBans v1.9.1 Sergey Shorokhov CA_Storage_CSBa running
[ 48] CA: Mute v1.9.1 Sergey Shorokhov CA_Mute.amxx running
[ 49] CA: VoteGAG 1.0.0-alph Sergey Shorokhov CA_Addon_VoteGa running
[ 50] CA: Gag v1.9.1 Sergey Shorokhov CA_Gag.amxx running
[ 51] Chat Manager 1.1.2-16 Mistrick chatmanager.amx running
[ 52] Custom Player Models A 0.2.3 F@nt0M & BlackSi custom_player_m running
[ 53] Custom Player Models C 0.2.2 BlackSignature custom_player_m running
[ 54] Custom Player Models T 0.2.1 BlackSignature custom_player_m running
[ 55] Map Manager: Core 3.1.4 Mistrick map_manager_cor running
[ 56] Map Manager: Scheduler 0.1.9 Mistrick map_manager_sch running
[ 57] Map Manager: Rtv 0.1.1 Mistrick map_manager_rtv running
[ 58] Map Manager: Nominatio 0.2.0 Mistrick map_manager_nom running
[ 59] Map Manager: Online so 0.0.4 Mistrick map_manager_onl running
[ 60] Map Manager: Effects 0.1.0 Mistrick map_manager_eff running
[ 61] Map Manager: Informer 0.0.5 Mistrick map_manager_inf running
[ 62] Map Manager: Sounds 0.0.1 Mistrick map_manager_sou running
62 plugins, 62 running
Автор плагина
uMk0
Версия плагина
1.3.2.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.2.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_TYPE,
CVAR_TOP_LIMIT_MOTD,
CVAR_TOP_LIMIT_CHAT,
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,
num_round = 0,
bool:gg_sql = false;

public plugin_init(){
gg_sql = false;
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 /tkme","getMe");
register_clcmd("say_team /tkme","getMe");
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 = "123",
.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 = "army_ranks",
.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 = "123",
.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 = "army_ranks",
.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 = "to",
.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 = "2",
.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_type",
.string = "0",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_TOP_TYPE"),
.has_min = true,
.min_val = 0.0,
.has_max = true,
.max_val = 2.0
), cvar[CVAR_TOP_TYPE]);
bind_pcvar_num(create_cvar(
.name = "tk_top_write_motd",
.string = "8",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_TOP_LIMIT_MOTD"),
.has_min = true,
.min_val = 1.0,
.has_max = true,
.max_val = 8.0
), cvar[CVAR_TOP_LIMIT_MOTD]);
bind_pcvar_num(create_cvar(
.name = "tk_top_write_chat",
.string = "3",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_TOP_LIMIT_CHAT"),
.has_min = true,
.min_val = 1.0,
.has_max = true,
.max_val = 5.0
), cvar[CVAR_TOP_LIMIT_CHAT]);
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();
}
forward OnConfigsExecuted();
public OnConfigsExecuted(){
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");

if(cvar[CVAR_SQL_CREATE_DB]){
new query[QUERY_LENGTH], sql_data[1];
sql_data[0] = SQL_INITDB;
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_putinserver(id){
player[id][PLAYER_LOAD_STATS] = 0;
get_user_authid(id, player[id][PLAYER_STEAMID], charsmax(player[][PLAYER_STEAMID]));
connectPlayer(id,1);
}
public connectPlayer(id, alert){
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]));
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],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,0);
}
}
public checkTableOther(){
if(gg_sql) return;
new query[QUERY_LENGTH], 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];

new sql_data[1]
sql_data[0] = SQL_ADD_OTHER_ROWS;
cvar[CVAR_TIMESTAMP] = 0;
cvar[CVAR_TIMESTAMP] = getNextDate();
cvar[CVAR_WINNER] = "none";

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],cvar[CVAR_TIMESTAMP]);
logging(logsDir, cvar[CVAR_LOG_NAME], "%L", LANG_SERVER, "TK_LOG_ADD_SETTINGS");
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
}
public killed(iVictim, iAttacker){
if(!player[iAttacker][PLAYER_LOAD_STATS] || iVictim == iAttacker || is_user_bot(iVictim))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 checkWinner(){
if(!init_table) return;
if(get_systime() > cvar[CVAR_TIMESTAMP] && cvar[CVAR_TIMESTAMP] != 0){
if(gg_sql) return;
new query[QUERY_LENGTH],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);
}

}
public savePlayer(id){
if(!player[id][PLAYER_LOAD_STATS])
return;

new query[QUERY_LENGTH], 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 savePlayerAll(){
if(num_round > 2){
checkWinner();
}
for(new i; i < 33; i++){
if(is_user_connected(i))
savePlayer(i)
}
}
public getTop(id){
if(gg_sql) return PLUGIN_HANDLED;
new query[QUERY_LENGTH],sql_data[2];

sql_data[0] = SQL_GET_TOP;
sql_data[1] = id;
new max_limit = cvar[CVAR_TOP_LIMIT_MOTD];
if(cvar[CVAR_TOP_LIMIT_MOTD] < cvar[CVAR_TOP_LIMIT_CHAT]){
max_limit = cvar[CVAR_TOP_LIMIT_CHAT];
}
formatex(query,charsmax(query),"\
SELECT * FROM `%s_stats` ORDER BY `frags` DESC, `hs` DESC, `death` ASC LIMIT 0, %d;",cvar[CVAR_SQL_TABLE_PREFIX],max_limit);
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
return PLUGIN_HANDLED;
}
public getMe(id){
if(gg_sql) return;
if(!player[id][PLAYER_LOAD_STATS])
return;
new query[QUERY_LENGTH], 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 addPlayer(id){
if(gg_sql) return;
if(!player[id][PLAYER_LOAD_STATS])
return;
new query[QUERY_LENGTH], 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) < 1){
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) > 0){
new player_name[32], frags, hs, death, count_chat = 0,count_motd = 0, max_limit = cvar[CVAR_TOP_LIMIT_MOTD], templateFile[96], iFileID, template[1220], len, bufferTpl[700], Float:kd = 0.0, Float:hs_percentage = 0.0;
if(max_limit < cvar[CVAR_TOP_LIMIT_CHAT]){
max_limit = cvar[CVAR_TOP_LIMIT_CHAT];
}
if(max_limit > SQL_NumResults(sqlQue)){
max_limit = SQL_NumResults(sqlQue);
}
if(cvar[CVAR_TOP_TYPE] == 0 || cvar[CVAR_TOP_TYPE] == 2){
formatex(templateFile, charsmax(templateFile), "%s/tk_template.html", dataDir);
iFileID = fopen(templateFile, "rt");
}
for(new i = 0; i < max_limit; i++){
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);
if((cvar[CVAR_TOP_TYPE] == 0 || cvar[CVAR_TOP_TYPE] == 2) && count_motd < cvar[CVAR_TOP_LIMIT_MOTD]){
hs_percentage = 0.0;
if(death > 0 && frags > 0){
kd = float(frags/death);
}
if(frags > 0 && hs > 0){
hs_percentage = float(hs*100/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)
count_motd++;
}
if((cvar[CVAR_TOP_TYPE] == 1 || cvar[CVAR_TOP_TYPE] == 2) && count_chat < cvar[CVAR_TOP_LIMIT_CHAT]){
client_print_color(data[1],print_team_default,"%L %L",LANG_SERVER,"TK_TAG",LANG_SERVER,"TK_TOP_CHAT", (i+1), player_name, frags, hs, death);
count_chat++;
}
}
if(cvar[CVAR_TOP_TYPE] == 0 || cvar[CVAR_TOP_TYPE] == 2){
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,PLUGIN);
}
}
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: {
init_table = false;
if(SQL_NumResults(sqlQue) > 0){
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_LOG_WINNER", player_name, 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");
}
cvar[CVAR_WINNER] = 0;
}
}else{
cvar[CVAR_WINNER] = 0;
}
new query[QUERY_LENGTH],sql_data[2];

sql_data[0] = SQL_UPDATE_OTHER_ROWS;
sql_data[1] = getNextDate();
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], sql_data[1]);

SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
return PLUGIN_HANDLED;
}
case SQL_UPDATE_OTHER_ROWS: {
cvar[CVAR_TIMESTAMP] = data[1];
new query[QUERY_LENGTH],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: {
init_table = true;
for(new i; i < 33; i++){
if(is_user_connected(i)) connectPlayer(i,0);
}
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED
}
public endRound(){
set_task(0.5,"savePlayerAll");
num_round++;
}
public plugin_end() savePlayerAll();
public client_disconnected(id) savePlayer(id);
stock getNextDate(){
if(cvar[CVAR_TIMESTAMP] > 0){
return cvar[CVAR_TIMESTAMP]+(cvar[CVAR_HOW_MANY_HOURS]*3600);
}else{
new date[32];
get_time("%m/%d/%Y 00:00:01", date, charsmax(date));
return (parse_time(date, "%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], 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;
}
Розыгрыш заканчиваеться почему-то в 22-00 хоть стоит время конкурса 24 часа и пояс +2, а начинаеться около 00-40.между этим временем motd даже не открываеться
Победителя заносит в базу данных в winner, но вип не прописываеться нигде
 
Сообщения
893
Реакции
149
Помог
25 раз(а)
Время сервера какое? Если я не ошибаюсь - get_time получает время сервера. Если не прав - поправьте пожалуйста.
 
Сообщения
182
Реакции
9
ImmortalAmxx, gmt +2, там все равно не понятный пробел в два с половиной часа
3 Авг 2022
а и еще команда /tkme не работает
 
Сообщения
893
Реакции
149
Помог
25 раз(а)
Попробуй добавить дебаги в код, к примеру, выводи время через server_print во время розыгрыша, что-бы посмотреть какое время тебе выведет.
 
Сообщения
58
Реакции
49
Помог
2 раз(а)
asla4ok, Попробуй в базе поменять вручную timestamp на нужное время подсчета победителя. Я подумаю как в след. версии исправить данный момент. Если не понятно можешь написать мне в тг @umk0of
 
Сообщения
678
Реакции
56
Помог
16 раз(а)
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
asla4ok, просто, где стоит сам серв, нужно поправить date на сервере и указать нужную временную зону UTC.
 
Сообщения
368
Реакции
5
Предупреждения
5
Помог
1 раз(а)
Скрытое содержимое для пользователей: uMk0
 

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

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