Участник
Пользователь
- Сообщения
- 93
- Реакции
- 12
- Ошибка
-
L 09/02/2022 - 08:05:41: [MySQL] Invalid info tuple handle: 0
L 09/02/2022 - 08:05:41: [AMXX] Displaying debug trace (plugin "topkiller.amxx", version "1.4.0")
L 09/02/2022 - 08:05:41: [AMXX] Run time error 10: native error (native "SQL_ThreadQuery")
L 09/02/2022 - 08:05:41: [AMXX] [0] topkiller.sma::getTop (line 424)
- ОС
- Linux
- Amx Mod X
-
AMX Mod X 1.9.0.5271
- Билд
-
ReHLDS version: 3.11.0.779-dev
- ReGamedll
-
ReGameDLL version: 5.21.0.556-dev
- Версия Metamod
-
Metamod v1.21p37 2013/05/30
- Список метамодулей
-
[ 1] Reunion RUN - reunion_mm_i386. v0.1.92d ini Start Never
[ 2] Rechecker RUN - rechecker_mm_i38 v2.5 ini Chlvl ANY
[ 3] AMX Mod X RUN - amxmodx_mm_i386. v1.9.0.5 ini Start ANY
[ 4] Revoice RUN - revoice_mm_i386. v0.1.0.3 ini Start Never
[ 5] ReSRDetector RUN - resrdetector_mm_ v0.1.0 ini Chlvl ANY
[ 6] ReAuthCheck RUN - reauthcheck_mm_i v0.1.6 ini Start Never
[ 7] WHBlocker RUN - whblocker_mm_i38 v1.5.697 ini Chlvl ANY
[ 8] ReSemiclip RUN - resemiclip_mm_i3 v2.3.9 ini Chlvl ANY
[ 9] YaPB RUN - yapb.so v4.2.598 ini Chlvl ANY
[10] MySQL RUN - mysql_amxx_i386. v1.9.0.5 pl3 ANY ANY
[11] SQLite RUN - sqlite_amxx_i386 v1.9.0.5 pl3 ANY ANY
[12] Fun RUN - fun_amxx_i386.so v1.9.0.5 pl3 ANY ANY
[13] Engine RUN - engine_amxx_i386 v1.9.0.5 pl3 ANY ANY
[14] FakeMeta RUN - fakemeta_amxx_i3 v1.9.0.5 pl3 ANY ANY
[15] CStrike RUN - cstrike_amxx_i38 v1.9.0.5 pl3 ANY ANY
[16] CSX RUN - csx_amxx_i386.so v1.9.0.5 pl3 ANY ANY
[17] Ham Sandwich RUN - hamsandwich_amxx v1.9.0.5 pl3 ANY ANY
[18] ReAimDetector RUN - reaimdetector_am v0.2.2 pl3 ANY Never
[19] GeoIP RUN - geoip_amxx_i386. v1.9.0.5 pl3 ANY ANY
[20] AuthEmu RUN - authemu_amxx_i38 v5.2.12. pl3 ANY Never
[21] ReAPI RUN - reapi_amxx_i386. v5.21.0. pl3 ANY Never
- Список плагинов
-
Currently loaded plugins:
name version author file status
[ 1] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a running
[ 2] GameCMS_API 5.4.9 zhorzh78 gamecms_api_5.4 running
[ 3] [182] VoteBan L4D 17.10.30 Sanlerus voteban_l4d.amx running
[ 4] FreshBans 1.4.3b kanagava fresh_bans_143_ running
[ 5] [190] Cvar On Map 20.06.06 SKAJIbnEJIb cvar_on_map.amx running
[ 6] [190] Screen Player 20.06.06 SKAJIbnEJIb screen_player.a running
[ 7] Uber Sounds 1.1 kz4fun uber_sounds.amx running
[ 8] Advanced Kill Assists 1.3c Xelson next21_kill_ass running
[ 9] [190] Army Ranks Ultim 20.06.06 SKAJIbnEJIb army_ranks_ulti running
[ 10] [190] CsStats MySQL 20.06.06 SKAJIbnEJIb csstats_mysql.a running
[ 11] AR Double 14.12.02 SKAJIbnEJIb ar_double.amxx running
[ 12] [190] AR Bets 20.06.06 SKAJIbnEJIb ar_bets.amxx running
[ 13] Pause Plugins 1.9.0.5271 AMXX Dev Team pausecfg.amxx running
[ 14] [182] Stats Configurat 20.06.06 SKAJIbnEJIb & AM statscfg_rbs.am running
[ 15] [182] StatsX RBS 21.03.23 SKAJIbnEJIb & AM statsx_rbs.amxx running
[ 16] No Players Map 1.03 neygomon noplayers_map.a running
[ 17] Admin Commands 1.9.0.5271 AMXX Dev Team admincmd.amxx running
[ 18] Slots Reservation 1.9.0.5271 AMXX Dev Team adminslots.amxx running
[ 19] Menus Front-End 20.06.06 SKAJIbnEJIb & AM amxmodmenu_rbs. running
[ 20] Commands Menu 1.9.0.5271 AMXX Dev Team cmdmenu.amxx running
[ 21] Players Menu 1.7 neugomon players_menu.am running
[ 22] Teleport Menu 1.9.0.5271 AMXX Dev Team telemenu.amxx running
[ 23] Maps Menu 1.9.0.5271 AMXX Dev Team mapsmenu.amxx running
[ 24] Plugin Menu 1.9.0.5271 AMXX Dev Team pluginmenu.amxx running
[ 25] Restrict Weapons 1.9.0.5271 AMXX Dev Team restmenu.amxx running
[ 26] Admin Chat 1.9.0.5271 AMXX Dev Team adminchat.amxx running
[ 27] [190] Chat Controller 20.06.06 SKAJIbnEJIb chat_controller running
[ 28] Scrolling Message 1.9.0.5271 AMXX Dev Team scrollmsg.amxx running
[ 29] Info. Messages 1.9.0.5271 AMXX Dev Team imessage.amxx running
[ 30] Admin Votes 1.9.0.5271 Wildness Team adminvote.amxx running
[ 31] Autoresponder/Advertis 0.5 MaximusBrood ad_manager.amxx running
[ 32] Lite MapChooser 2.6 neygomon lite_mapchooser running
[ 33] ReChecker Logging freesrv AMXX rc_logging.amxx running
[ 34] RC BaseChanger freesrv AMXX rc_basechanger. running
[ 35] Master Servers Check 2.0 Javekson ms_check.amxx running
[ 36] AntiSpam FlashLight 1.0 Leo_[BH] flashlight_no_s running
[ 37] [190] High Ping Kicker 20.06.06 SKAJIbnEJIb hpk_rbs.amxx running
[ 38] AFK Control ReNew 1.2(a) neygomon afk_control.amx running
[ 39] Spect Bot 1.2 SKAJIbnEJIb & Bo SpectBot.amxx running
[ 40] C4_Block 1.0 SNauPeR C4_Block.amxx paused
[ 41] FPS Meter 1.1 neygomon fps.amxx running
[ 42] Flashbang Ban 0.3 mx?! flashbang_ban.a running
[ 43] Auto recording demo 2.0 IzI | Bonaqua (R amx_autodemorec running
[ 44] [ReAPI] Advanced Team 0.1.0 Vaqtincha AdvancedTeamCho running
[ 45] GameName Changer 1.0 neugomon gamename_change running
[ 46] Advanced Ultimate Weap 0.1.0b steelzzz auw.amxx running
[ 47] unknown unknown unknown ultimate_weapon running
[ 48] [190] VIP RBS 20.07.20 SKAJIbnEJIb vip_rbs.amxx running
[ 49] [AUW] Addon: Weapon Ma 0.0.3 xxx auw_addon_maps. running
[ 50] [190] AR Vampire 20.06.06 SKAJIbnEJIb ar_vampire.amxx running
[ 51] [190] Ultimate Models 21.03.23 SKAJIbnEJIb ultimate_models running
[ 52] [ReAPI] Healthnade 0.0.2 F@nt0M reapi_healthnad running
[ 53] Map Spawns Editor 1.0.16 iG_os map_spawns_edit running
[ 54] [182] PTB RBS 20.06.06 SKAJIbnEJIb ptb_rbs.amxx running
[ 55] Parachute 1.0 maeStro parachute.amxx running
[ 56] Mode 2x2 2.5re s1lent mode.amxx paused
[ 57] [ReAPI] AWPoff 1.4.3 PAffAEJIkA :3 awp_off.amxx running
[ 58] [ReAPI] TopRoundDamage 1.0.6 Dager* *.* -G- damage_round.am running
[ 59] Damager 0.0.5 steelzzz damager.amxx running
[ 60] ResetScore 1.0 Leo_[BH] resetscore_reap running
[ 61] [182] Crux Ansata 17.10.30 Sanlerus crux_ansata.amx running
[ 62] Nade Messages 1.0 v3x nademessages.am running
[ 63] Death Gift 2.0.0 ArKaNeMaN DeathGift.amxx running
[ 64] [DG] More Bonuses 2.0.0 ArKaNeMaN DG_MoreBonuses. running
[ 65] [DG] More Funcs 2.0.0 ArKaNeMaN DG_MoreFuncs.am running
[ 66] [DG] ARU Ext. 1.0.0 ArKaNeMaN DG_Aru.amxx running
[ 67] [DG] AUW Ext. 1.0.0 ArKaNeMaN DG_Auw.amxx running
[ 68] [DG] Misc Bonuses 1.0.0 ArKaNeMaN DG_Misc.amxx running
[ 69] [190] Hostage Mod 20.08.08 SKAJIbnEJIb hostage_mod.amx stopped
[ 70] [190] Real Hostages 20.06.06 SKAJIbnEJIb & Av real_hostages.a stopped
[ 71] GameCMS_Achievs_Core 1.3 zhorzh78 gamecms_achievs running
[ 72] GameCMS_Player_Achievs 1.3 zhorzh78 player_achievs_ running
[ 73] GameCMS_Special_Achiev 1.3 zhorzh78 special_achievs running
[ 74] GameCMS_Bomb_Achievs 1.2 zhorzh78 bomb_achievs_1. running
[ 75] CMS Achevs Reward 3.0 ApXuTekToR CMSAchevs_Rewar running
[ 76] GameCMS BonusSystem 1.1 +- DUKKHAZ0R gamecms_bonus.a running
[ 77] Top killer 1.4.0 uMk0 topkiller.amxx debug
[ 78] Win Team 1.0 maFFyoZZyk win_team.amxx running
[ 79] Knife Duel with Telepo 1.2 neygomon knife_duel.amxx running
[ 80] CMSGive_RegFlags 1.0 ApXuTekToR CMSGive_RegFlag running
[ 81] CT Bomb Cracker 0.0.4 Vaqtincha re_ct_bomb_crac debug
[ 82] ChatAdditions: Core v1.5.0 Sergey Shorokhov ChatAdditions_C running
[ 83] ChatAdditions: GameCMS v1.5.0 Sergey Shorokhov CA_Storage_Game running
[ 84] CA: Mute v1.5.0 Sergey Shorokhov CA_Mute.amxx running
[ 85] CA Addon: Death mute v1.5.0 Sergey Shorokhov CA_Addon_DeathM running
[ 86] CA: Gag v1.5.0 Sergey Shorokhov CA_Gag.amxx running
[ 87] [190] Chat RBS 20.06.06 SKAJIbnEJIb chat_rbs.amxx running
- Автор плагина
- uMk0
- Версия плагина
- 1.4.0
- Исходный код
-
#include <amxmodx>
#include <reapi>
#include <sqlx>
#define PLUGIN "Top killer"
#define VERSION "1.4.0"
#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_HOURS_CHECK[1024],
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[MAX_NAME_LENGTH * 3],
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,
LastTimeAndDay[6] = "0_00";
public plugin_init(){
gg_sql = false;
register_plugin(PLUGIN,VERSION,AUTHOR);
register_event("Damage","E_Damage","b","2!0")
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", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY, MULTI_LANGUAGE("TK_CVAR_VERSION"));
bind_pcvar_string(create_cvar(
.name = "tk_sql_driver",
.string = "sqlite",
.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_string(create_cvar(
.name = "tk_hours_check",
.string = "23",
.flags = FCVAR_NONE,
.description = MULTI_LANGUAGE("TK_CVAR_HOURS_CHECK")
), cvar[CVAR_HOURS_CHECK], charsmax(cvar[CVAR_HOURS_CHECK]));
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,\
PRIMARY KEY (`key`));",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_tk(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_WINNER] = "none";
formatex(query,charsmax(query),"\
INSERT INTO `%s_settings` (`key`, `param`) VALUES ('winner', '0');\
INSERT INTO `%s_settings` (`key`, `param`) VALUES ('lastDayAndHourCheck', '0_00'); ",cvar[CVAR_SQL_TABLE_PREFIX],cvar[CVAR_SQL_TABLE_PREFIX]);
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 E_Damage(player){
// thanks voed
static weapon_id,last_hit,attacker,bool:alive
attacker = get_user_attacker(player,weapon_id,last_hit)
alive = (is_user_alive(player) ? true : false)
if(!alive) {
if(!is_user_connected(attacker)) {
killed(0,player,0,0)
}else{
killed(attacker,player,weapon_id,last_hit)
}
}
}
public killed(iAttacker, iVictim,wpn_id,hit_place){
if(player[iAttacker][PLAYER_LOAD_STATS] == 0
|| iVictim == iAttacker
|| is_user_bot(iVictim)
|| !is_user_connected(iVictim)
|| !is_user_connected(iAttacker))
return;
player[iAttacker][PLAYER_FRAGS]++;
if(hit_place == HIT_HEAD){
player[iAttacker][PLAYER_HS]++;
}
if(player[iVictim][PLAYER_LOAD_STATS]){
player[iVictim][PLAYER_DEATH]++;
}
}
public checkWinner(){
if(!init_table || gg_sql) return;
new buffer[512][3],CurrentTime[3], i,CurrentTimeAndDay[6];
explode_string(cvar[CVAR_HOURS_CHECK],",",buffer,512,3);
get_time("%H",CurrentTime,2);
get_time("%d_%H",CurrentTimeAndDay,5);
for(i = 0; i < sizeof(buffer); i++){
if(equali(CurrentTime,buffer[i]) && !equali(CurrentTimeAndDay,LastTimeAndDay)){
LastTimeAndDay = CurrentTimeAndDay;
new query[QUERY_LENGTH],sql_data[2];
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{
new key[64];
SQL_ReadResult(sqlQue, 0, key, charsmax(key));
if(equali("lastDayAndHourCheck",key)){
SQL_ReadResult(sqlQue, 1, LastTimeAndDay, charsmax(LastTimeAndDay));
SQL_NextRow(sqlQue)
SQL_ReadResult(sqlQue, 1, cvar[CVAR_WINNER], charsmax(cvar[CVAR_WINNER]));
}else{
SQL_ReadResult(sqlQue, 1, cvar[CVAR_WINNER], charsmax(cvar[CVAR_WINNER]));
SQL_NextRow(sqlQue)
SQL_ReadResult(sqlQue, 1, LastTimeAndDay, charsmax(LastTimeAndDay));
}
}
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;
new CurrentTimeAndDay[6];
get_time("%d_%H",CurrentTimeAndDay,5);
formatex(query,charsmax(query),"\
UPDATE `%s_settings` SET `param` = '%s' WHERE `key` LIKE 'winner';\
UPDATE `%s_settings` SET `param` = '%s' WHERE `key` LIKE 'lastDayAndHourCheck';",cvar[CVAR_SQL_TABLE_PREFIX],cvar[CVAR_WINNER],cvar[CVAR_SQL_TABLE_PREFIX],CurrentTimeAndDay);
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data);
return PLUGIN_HANDLED;
}
case SQL_UPDATE_OTHER_ROWS: {
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 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("%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);
}
mysql_escape_string_tk(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_hs", 1);
register_native("tk_get_death", "_get_death", 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];
}
что сним не так ?