error with gm bans 1.5.1, chek_player.inl and check_flag.inl

Ask questions about errors and problems related to the amxbans project.
The more details you give, the better answer you will receive, READ the sticky topics before posting!

Be sure to post in the right sub forum: Bugs and Security
Post Reply
devilchy
Posts: 1
Joined: 14 Jun 2020, 12:05

error with gm bans 1.5.1, chek_player.inl and check_flag.inl

Post by devilchy »

hi guys, Since using this plugin I have a problem with the following errors:

Code: Select all

 L 06/12/2020 - 20:12:48: [AMXX] Displaying debug trace (plugin "amxbans_main.amxx", version "Gm 1.5.1")
L 06/12/2020 - 20:12:48: [AMXX] Run time error 10: native error (native "SQL_ThreadQuery")
L 06/12/2020 - 20:12:48: [AMXX]    [0] check_flag.inl::check_flagged (line 37)
L 06/12/2020 - 20:12:48: [AMXX]    [1] check_player.inl::check_player_ (line 104)
So I didn't find a solution anywhere, what didn't I try ...
That is why I want to ask you most politely if anyone knows or can help me. Thank you from now on.

amxbans_main.sma:

Code: Select all

/*

	AMXBans, managing bans for Half-Life modifications
	Copyright (C) 2003, 2004  Ronald Renes / Jeroen de Rover
	
	Copyright (C) 2009, 2010  Thomas Kurz

	Amxbans Main Plugin
*/

new const AUTHOR[] = "GmStaff, xPaw, ~Val~"
new const PLUGIN_NAME[] = "AMXBans Main"
new const VERSION[] = "Gm 1.5.1" // This is used in the plugins name
new const DATE[] = "20:31 07.03.2011"

new const amxbans_version[] = "1.5.1" // This is for the DB
//#define UNBAN_GAME_DEL

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <sqlx>
#include <time>

// Amxbans Core natives
#include "include/amxbans_core.inc"

// Amxbans .inl files
#include "include/amxbans/global_vars.inl"
#include "include/amxbans/color_chat.inl"
#include "include/amxbans/init_functions.inl"
#include "include/amxbans/check_player.inl"
#include "include/amxbans/check_flag.inl"
#include "include/amxbans/menu_stocks.inl"
#include "include/amxbans/menu_ban.inl"
#include "include/amxbans/menu_disconnected.inl"
#include "include/amxbans/menu_history.inl"
#include "include/amxbans/menu_flag.inl"
#include "include/amxbans/cmdBan.inl"
#include "include/amxbans/cmdUnBan.inl"
#include "include/amxbans/web_handshake.inl"


// 16k * 4 = 64k stack size
#pragma dynamic 16384 		// Give the plugin some extra memory to use


public plugin_init() {
	register_plugin(PLUGIN_NAME, VERSION, AUTHOR)
	register_cvar("amxbans_version", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
	
	register_dictionary("amxbans.txt")
	register_dictionary("common.txt")
	register_dictionary("time.txt")
	
	new szGame[20];
	get_modname(szGame, charsmax(szGame));
	
	register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN, "- displays ban menu")
	register_clcmd("amxbans_custombanreason", "setCustomBanReason", ADMIN_BAN, "- configures custom ban message")
	register_clcmd("amx_banhistorymenu", "cmdBanhistoryMenu", ADMIN_BAN, "- displays banhistorymenu")
	register_clcmd("amx_bandisconnectedmenu", "cmdBanDisconnectedMenu", ADMIN_BAN, "- displays bandisconnectedmenu")
	register_clcmd("amx_flaggingmenu","cmdFlaggingMenu",ADMIN_BAN,"- displays flagging menu")
	
	register_srvcmd("amx_sethighbantimes", "setHighBantimes")
	register_srvcmd("amx_setlowbantimes", "setLowBantimes")
	register_srvcmd("amx_setflagtimes","setFlagTimes")
	
	register_concmd("amx_reloadreasons", "cmdFetchReasons", ADMIN_CFG)
	
	pcvar_serverip		=	register_cvar("amxbans_server_address","")
	pcvar_server_nick 	= 	register_cvar("amxbans_servernick", "")
	pcvar_discon_in_banlist	=	register_cvar("amxbans_discon_players_saved","10")
	pcvar_complainurl	= 	register_cvar("amxbans_complain_url", "www.cs-bulgaria.com") // Dont use http:// then the url will not show
	pcvar_debug 		= 	register_cvar("amxbans_debug", "1") // Set this to 1 to enable debug
	pcvar_add_mapname	=	register_cvar("amxbans_add_mapname_in_servername", "0")
	pcvar_flagged_all	=	register_cvar("amxbans_flagged_all_server","1")
	pcvar_show_in_hlsw 	= 	register_cvar("amxbans_show_in_hlsw", "1")
	pcvar_show_hud_messages	= 	register_cvar("amxbans_show_hud_messages", "1")
	pcvar_higher_ban_time_admin = 	register_cvar("amxbans_higher_ban_time_admin", "n")
	pcvar_admin_mole_access = 	register_cvar("amxbans_admin_mole_access", "r")
	pcvar_show_name_evenif_mole = 	register_cvar("amxbans_show_name_evenif_mole", "1")
	pcvar_custom_statictime =	register_cvar("amxbans_custom_statictime","1440")
	pcvar_show_prebanned 	=	register_cvar("amxbans_show_prebanned","1")
	pcvar_show_prebanned_num =	register_cvar("amxbans_show_prebanned_num","2")
	pcvar_default_banreason	=	register_cvar("amxbans_default_ban_reason","unknown")
	pcvar_extendedbanmenu	=	register_cvar("amxbans_extendedbanmenu","0")
	
	register_concmd("amx_ban", "cmdBan", ADMIN_BAN, "<time in mins> <steamID or nickname or #authid or IP> <reason>")
	register_concmd("amx_banip", "cmdBan", ADMIN_BAN, "<time in mins> <steamID or nickname or #authid or IP> <reason>")
	register_concmd("amx_unban", "cmdUnBan", ADMIN_BAN, "<steamID or IP>")
	
	register_srvcmd("amx_list", "cmdLst", ADMIN_RCON, "sends playerinfos to web")
	
	g_coloredMenus 		= 	colored_menus()
	g_MyMsgSync 		= 	CreateHudSyncObj()
	
	g_banReasons		=	ArrayCreate(128,7)
	g_banReasons_Bantime 	=	ArrayCreate(1,7)
	
	g_disconPLname		=	ArrayCreate(32,1)
	g_disconPLauthid	=	ArrayCreate(35,1)
	g_disconPLip		=	ArrayCreate(22,1)
	
	plnum = get_maxplayers()

	new configsDir[64]
	get_configsdir(configsDir, 63)
	
	server_cmd("exec %s/amxbans.cfg", configsDir)
	
}
create_forwards() {
	MFHandle[Ban_MotdOpen]=CreateMultiForward("amxbans_ban_motdopen",ET_IGNORE,FP_CELL)
	MFHandle[Player_Flagged]=CreateMultiForward("amxbans_player_flagged",ET_IGNORE,FP_CELL,FP_CELL,FP_STRING)
	MFHandle[Player_UnFlagged]=CreateMultiForward("amxbans_player_unflagged",ET_IGNORE,FP_CELL)
}
public addMenus() {
	new szKey[64]
	format(szKey,charsmax(szKey),"%L",LANG_SERVER,"ADMMENU_FLAGGING")
	//AddMenuItem(szKey,"amx_flaggingmenu",ADMIN_BAN,PLUGIN_NAME)
	format(szKey,charsmax(szKey),"%L",LANG_SERVER,"ADMMENU_DISCONNECTED")
	//AddMenuItem(szKey,"amx_bandisconnectedmenu",ADMIN_BAN,PLUGIN_NAME)
	format(szKey,charsmax(szKey),"%L",LANG_SERVER,"ADMMENU_HISTORY")
	//AddMenuItem(szKey,"amx_banhistorymenu",ADMIN_BAN,PLUGIN_NAME)

	//AddMenuItem ( "AMXBans: Screens", "amx_ssbanmenu", ADMIN_BAN, "AMXBans: Screens" );
}
//forward from amxbans_core
public amxbans_sql_initialized(Handle:sqlTuple,dbPrefix[]) {
	
	copy(g_dbPrefix,charsmax(g_dbPrefix),dbPrefix)
	//db was already initialized, second init can be caused by a second forward from main plugin
	//this should never happen!!
	if(g_SqlX != Empty_Handle) {
		log_amx("[CS-BULGARIA Error] DB Info Tuple from amxbans_core initialized twice!!")
		return PLUGIN_HANDLED
	}

	g_SqlX=sqlTuple
	if ( get_pcvar_num(pcvar_debug) >= 1 )
		log_amx("[CS-BULGARIA] Received DB Info Tuple from amxbans_core: %d | %s", sqlTuple,g_dbPrefix)
	if(g_SqlX==Empty_Handle) {
		log_amx("[CS-BULGARIA Error] DB Info Tuple from amxbans_main is empty! Trying to get a valid one")
		new host[64], user[64], pass[64], db[64]

		get_cvar_string("amx_sql_host", host, 63)
		get_cvar_string("amx_sql_user", user, 63)
		get_cvar_string("amx_sql_pass", pass, 63)
		get_cvar_string("amx_sql_db", db, 63)
		
		g_SqlX = SQL_MakeDbTuple(host, user, pass, db)
		
		get_cvar_string("amx_sql_prefix",g_dbPrefix,charsmax(g_dbPrefix))
	}
	create_forwards()
	set_task(0.1, "banmod_online")
	set_task(0.2, "fetchReasons")
	set_task(2.0, "addMenus")
	
	return PLUGIN_HANDLED
}

//////////////////////////////////////////////////////////////////
public get_higher_ban_time_admin_flag() {
	new flags[24]
	get_pcvar_string(pcvar_higher_ban_time_admin, flags, 23)
	
	return(read_flags(flags))
}
public get_admin_mole_access_flag() {
	new flags[24]
	get_pcvar_string(pcvar_admin_mole_access, flags, 23)
	
	return(read_flags(flags))
}
public delayed_kick(player_id) {
	
	player_id-=200
	new userid = get_user_userid(player_id)
	new kick_message[128]
	
	format(kick_message,127,"%L", player_id,"KICK_MESSAGE")

	if ( get_pcvar_num(pcvar_debug) >= 1 )
		log_amx("[CS-BULGARIA DEBUG] Delayed Kick ID: <%d>", player_id)

	server_cmd("kick #%d  %s",userid, kick_message)
	
	g_kicked_by_amxbans[player_id]=true
	g_being_banned[player_id] = false
	
	return PLUGIN_CONTINUE
}

/*********  Error handler  ***************/
MySqlX_ThreadError(szQuery[], error[], errnum, failstate, id) {
	if (failstate == TQUERY_CONNECT_FAILED) {
		log_amx("%L", LANG_SERVER, "TCONNECTION_FAILED")
	} else if (failstate == TQUERY_QUERY_FAILED) {
		log_amx("%L", LANG_SERVER, "TQUERY_FAILED")
	}
	log_amx("%L", LANG_SERVER, "TQUERY_ERROR", id)
	log_amx("%L", LANG_SERVER, "TQUERY_MSG", error, errnum)
	log_amx("%L", LANG_SERVER, "TQUERY_STATEMENT", szQuery)
}
/*********    client functions     ************/
public client_authorized(id) {
	//fix for the invalid tuple error at mapchange, only a fast fix now
	if(g_SqlX==Empty_Handle) {
		set_task(2.0,"client_authorized",id)
		return PLUGIN_HANDLED
	}
	//check if an activ ban exists
	check_player(id)
	return PLUGIN_CONTINUE
}
public client_putinserver(id) {
	//fix for the invalid tuple error at mapchange, only a fast fix now
	if(g_SqlX==Empty_Handle) {
		set_task(5.0,"client_putinserver",id)
		return PLUGIN_HANDLED
	}
	//check if the player was banned before
	prebanned_check(id)
	//remove the player from the disconnect player list because he is already connected ;-)
	disconnect_remove_player(id)
	return PLUGIN_CONTINUE
}
public client_disconnected(id) {
	
	g_being_banned[id]=false
	
	if(!g_kicked_by_amxbans[id]) {
		//only add players to disconnect list if not kicked by amxbans
		disconnected_add_player(id)
	} else if(g_being_flagged[id]) {
		// if kicked by amxbans maybe remove the flagged, not added yet
		/*****///remove_flagged_by_steam(0,id,0)
	}
	//reset some vars
	g_kicked_by_amxbans[id]=false
	g_being_flagged[id]=false
	g_nextround_kick[id]=false
}
/*********    timecmd functions     ************/
public setHighBantimes() {
	new arg[32]
	new argc = read_argc() - 1
	g_highbantimesnum = argc

	if(argc < 1 || argc > 14) {
		log_amx("[CS-BULGARIA] You have more than 14 or less than 1 bantimes set in amx_sethighbantimes")
		log_amx("[CS-BULGARIA] Loading default bantimes")
		loadDefaultBantimes(1)

		return PLUGIN_HANDLED
	}

	new i = 0
	new num[32], flag[32]
	while (i < argc)	{
		read_argv(i + 1, arg, 31)
		parse(arg, num, 31, flag, 31)

		if(equali(flag, "m")) { 
			g_HighBanMenuValues[i] = str_to_num(num)
		} else if(equali(flag, "h")) {
			g_HighBanMenuValues[i] = (str_to_num(num) * 60)
		} else if(equali(flag, "d")) {
			g_HighBanMenuValues[i] = (str_to_num(num) * 1440)
		} else if(equali(flag, "w")) {
			g_HighBanMenuValues[i] = (str_to_num(num) * 10080)
		}
		i++
	}
	return PLUGIN_HANDLED
}
public setLowBantimes() {
	new arg[32]
	new argc = read_argc() - 1
	g_lowbantimesnum = argc
	
	if(argc < 1 || argc > 14) {
		log_amx("[CS-BULGARIA] You have more than 14 or less than 1 bantimes set in amx_setlowbantimes")
		log_amx("[CS-BULGARIA] Loading default bantimes")
		loadDefaultBantimes(2)
		
		return PLUGIN_HANDLED
	}

	new i = 0
	new num[32], flag[32]
	while (i < argc) {
		read_argv(i + 1, arg, 31)
		parse(arg, num, 31, flag, 31)

		if(equali(flag, "m")) { 
			g_LowBanMenuValues[i] = str_to_num(num)
		} else if(equali(flag, "h")) {
			g_LowBanMenuValues[i] = (str_to_num(num) * 60)
		} else if(equali(flag, "d")) {
			g_LowBanMenuValues[i] = (str_to_num(num) * 1440)
		} else if(equali(flag, "w")) {
			g_LowBanMenuValues[i] = (str_to_num(num) * 10080)
		}
		i++
	}
	return PLUGIN_HANDLED
}
public setFlagTimes() {
	new arg[32]
	new argc = read_argc() - 1
	g_flagtimesnum = argc
	if(argc < 1 || argc > 14) {
		log_amx("[CS-BULGARIA] You have more than 14 or less than 1 flagtimes set in amx_setflagtimes")
		log_amx("[CS-BULGARIA] Loading default flagtimes")
		loadDefaultBantimes(3)
		
		return PLUGIN_HANDLED
	}
	
	new i = 0
	new num[32], flag[32]
	while (i < argc) {
		read_argv(i + 1, arg, 31)
		parse(arg, num, 31, flag, 31)

		if(equali(flag, "m")) { 
			g_FlagMenuValues[i] = str_to_num(num)
		} else if(equali(flag, "h")) {
			g_FlagMenuValues[i] = (str_to_num(num) * 60)
		} else if(equali(flag, "d")) {
			g_FlagMenuValues[i] = (str_to_num(num) * 1440)
		} else if(equali(flag, "w")) {
			g_FlagMenuValues[i] = (str_to_num(num) * 10080)
		}
		i++
	}
	return PLUGIN_HANDLED
}
loadDefaultBantimes(num) {
	if(num == 1 || num == 0)
		server_cmd("amx_sethighbantimes 5 60 240 600 6000 0")
	if(num == 2 || num == 0)
		server_cmd("amx_setlowbantimes 5 30 60 480 600 1440")
	if(num == 3 || num == 0)
		server_cmd("amx_setflagtimes 60 240 600 1440 10080 40320 90720 0")
}
/*********    mysql escape functions     ************/
mysql_escape_string(const source[],dest[],len)
{
	copy(dest, len, source);
	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,"^"","\^"");
}
mysql_get_username_safe(id,dest[],len) {
	new name[128]
	get_user_name(id,name,127)
	mysql_escape_string(name,dest,len)
}
mysql_get_servername_safe(dest[],len) {
	new server_name[256]
	get_cvar_string("hostname", server_name, charsmax(server_name))
	mysql_escape_string(server_name,dest,len)
}
check_flag.inl:

Code: Select all

/*

	AMXBans, managing bans for Half-Life modifications
	Copyright (C) 2003, 2004  Ronald Renes / Jeroen de Rover
	
	Copyright (C) 2009, 2010  Thomas Kurz

*/

#if defined _check_flag_included
    #endinput
#endif
#define _check_flag_included


#include <amxmodx>
#include <amxmisc>
#include <sqlx>

check_flagged(id)
{
	if(g_being_flagged[id])
		return PLUGIN_HANDLED;
	
	new authid[35], ip[22], pquery[1024];
	get_user_authid(id, authid, charsmax(authid));
	get_user_ip(id, ip, charsmax(ip), 1);
	
	if(get_pcvar_num(pcvar_flagged_all))
		formatex(pquery, charsmax(pquery), "SELECT `fid`,`reason`,`created`,`length` FROM `%s%s` WHERE player_id='%s' OR player_ip='%s' ORDER BY `length` ASC", g_dbPrefix, tbl_flagged, authid, ip);
	else
		formatex(pquery, charsmax(pquery), "SELECT `fid`,`reason`,`created`,`length` FROM `%s%s` WHERE (player_id='%s' OR player_ip='%s') AND `server_ip`='%s:%s' ORDER BY `length` ASC", g_dbPrefix, tbl_flagged, authid,ip, g_ip, g_port);
	
	new data[1];
	data[0] = id;
	if(g_SqlX) 
	SQL_ThreadQuery(g_SqlX, "_check_flagged", pquery, data, 1);
	
	return PLUGIN_HANDLED;
}

public _check_flagged(failstate, Handle:query, error[], errnum, data[], size)
{
	new id = data[0];
	
	if(failstate)
	{
		new szQuery[256];
		MySqlX_ThreadError(szQuery, error, errnum, failstate, 40);
		return PLUGIN_HANDLED;
	}
	
	if(!SQL_NumResults(query))
		return PLUGIN_HANDLED;
	
	new length, reason[128], created, fid, bool:flagged;
	new cur_time = get_systime();
	
	while(SQL_MoreResults(query))
	{
		fid = SQL_ReadResult(query, 0);
		SQL_ReadResult(query, 1, reason, charsmax(reason));
		created = SQL_ReadResult(query, 2);
		length = SQL_ReadResult(query, 3);
		
		if(created + length * 60 > cur_time)
		{
			flagged = true;
		}
		else
		{
			remove_flagged(fid);
		}
		
		SQL_NextRow(query);
	}
	
	if(!flagged)
		return PLUGIN_HANDLED;
	
	//the last result contains the longest flagg time, using this of course
	
	g_flaggedTime[id] = length;
	copy(g_flaggedReason[id], charsmax(g_flaggedReason[]), reason);
	
	if(!g_being_flagged[id])
	{
		new ret;
		ExecuteForward(MFHandle[Player_Flagged], ret, id, (g_flaggedTime[id] * 60), g_flaggedReason[id]);
	}
	g_being_flagged[id] = true;
	return PLUGIN_HANDLED;
}

remove_flagged(fid)
{
	new pquery[1024];
	formatex(pquery, charsmax(pquery), "DELETE FROM `%s%s` WHERE `fid`=%d", g_dbPrefix, tbl_flagged, fid);
	if(g_SqlX)
	SQL_ThreadQuery(g_SqlX, "_remove_flagged", pquery);
	
	return PLUGIN_CONTINUE;
}

public _remove_flagged(failstate, Handle:query, error[], errnum, data[], size)
{
	if(failstate)
	{
		new szQuery[256];
		MySqlX_ThreadError(szQuery, error, errnum, failstate, 41);
	}
	
	return PLUGIN_HANDLED;
}
check_player.inl:

Code: Select all

/*

	AMXBans, managing bans for Half-Life modifications
	Copyright (C) 2003, 2004  Ronald Renes / Jeroen de Rover
	
	Copyright (C) 2009, 2010  Thomas Kurz

*/

#if defined _check_player_included
    #endinput
#endif
#define _check_player_included

#include <amxmodx>
#include <amxmisc>
#include <sqlx>

public prebanned_check(id) {
	if(is_user_bot(id) || id==0)
		return PLUGIN_HANDLED
	
	if(!get_pcvar_num(pcvar_show_prebanned))
		return PLUGIN_HANDLED
	
	if(get_user_flags(id) & ADMIN_IMMUNITY)
		return PLUGIN_HANDLED
	
	new player_steamid[35], player_ip[22], pquery[1024]
	get_user_authid(id, player_steamid, 34)
	get_user_ip(id, player_ip, 21, 1)

	//formatex(pquery, charsmax(pquery), "SELECT ban_created,admin_nick FROM `%s%s` WHERE ( (player_id='%s' AND ban_type='S') OR (player_ip='%s' AND ban_type='SI') ) AND expired=1",g_dbPrefix, tbl_bans, player_steamid, player_ip)
	formatex(pquery, charsmax(pquery), "SELECT COUNT(*) FROM `%s%s` WHERE ( (player_id='%s' AND ban_type='S') OR (player_ip='%s' AND ban_type='SI') ) AND expired=1",g_dbPrefix, tbl_bans, player_steamid, player_ip)
	
	new data[1]
	data[0] = id
	if(g_SqlX)
	SQL_ThreadQuery(g_SqlX, "prebanned_check_", pquery, data, 1)
	
	return PLUGIN_HANDLED
}
public prebanned_check_(failstate, Handle:query, error[], errnum, data[], size) {
	new id = data[0]
	
	if (failstate) {
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 16 )
		return PLUGIN_HANDLED
	}
	
	new ban_count=SQL_ReadResult(query, 0)
	
	if(ban_count < get_pcvar_num(pcvar_show_prebanned_num))
		return PLUGIN_HANDLED
		
	new name[32], player_steamid[35]
	get_user_authid(id, player_steamid, 34)
	get_user_name(id, name, 31)
	
	for(new i=1;i<=plnum;i++) {
		if(is_user_bot(i) || is_user_hltv(i) || !is_user_connected(i) || i==id)
			continue
		if(get_user_flags(i) & ADMIN_CHAT) 
                {
			set_hudmessage(7, 223, 43, 0.01, 0.27, 0, 6.0, 10.0 , 0.5, 0.15, -1)
                        ShowSyncHudMsg(i, g_MyMsgSync, "[Cs-Bulgaria.Com # Bans Info]^n'%s' E bil Bannat '%i' puti predi tova !!!", name, ban_count)
		}
	}
	log_amx("[CS-BULGARIA] %L",LANG_SERVER, "PLAYER_BANNED_BEFORE", name, player_steamid, ban_count)
	
	return PLUGIN_HANDLED
}

/*************************************************************************/

public check_player(id) {
	new player_steamid[32], player_ip[20]
	get_user_authid(id, player_steamid, 31)
	get_user_ip(id, player_ip, 19, 1)

	new data[1], pquery[1024]
	formatex(pquery, charsmax(pquery), "SELECT bid,ban_created,ban_length,ban_reason,admin_nick,admin_id,admin_ip,player_nick,player_id,player_ip,server_name,server_ip,ban_type \
		FROM `%s%s` WHERE ( (player_id='%s' AND ban_type='S') OR (player_ip='%s' AND ban_type='SI') ) AND expired=0",g_dbPrefix, tbl_bans, player_steamid, player_ip)
	
	data[0] = id
	if(g_SqlX)
	SQL_ThreadQuery(g_SqlX, "check_player_", pquery, data, 1)
	
	return PLUGIN_HANDLED
}

public check_player_(failstate, Handle:query, error[], errnum, data[], size) {
	new id = data[0]

	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 17 )
		return PLUGIN_HANDLED
	}
	
	if(!SQL_NumResults(query)) {
		check_flagged(id)
		return PLUGIN_HANDLED
	}
	
	new ban_reason[128], admin_nick[100],admin_steamid[50],admin_ip[30],ban_type[4]
	new player_nick[50],player_steamid[50],player_ip[30],server_name[100],server_ip[30]
	
	new bid = SQL_ReadResult(query, 0)
	new ban_created = SQL_ReadResult(query, 1)
	new ban_length_int = SQL_ReadResult(query, 2)*60 //min to sec
	SQL_ReadResult(query, 3, ban_reason, 127)
	SQL_ReadResult(query, 4, admin_nick, 99)
	SQL_ReadResult(query, 5, admin_steamid, 49)
	SQL_ReadResult(query, 6, admin_ip, 29)
	SQL_ReadResult(query, 7, player_nick, 49)
	SQL_ReadResult(query, 8, player_steamid, 49)
	SQL_ReadResult(query, 9, player_ip, 29)
	SQL_ReadResult(query, 10, server_name, 99)
	SQL_ReadResult(query, 11, server_ip, 29)
	SQL_ReadResult(query, 12, ban_type, 3)

	if ( get_pcvar_num(pcvar_debug) >= 1 )
		log_amx("[CS-BULGARIA] Player Check on Connect:^nbid: %d ^nwhen: %d ^nlenght: %d ^nreason: %s ^nadmin: %s ^nadminsteamID: %s ^nPlayername %s ^nserver: %s ^nserverip: %s ^nbantype: %s",\
		bid,ban_created,ban_length_int,ban_reason,admin_nick,admin_steamid,player_nick,server_name,server_ip,ban_type)

	new current_time_int = get_systime(0)
	//new ban_length_int = str_to_num(ban_length) * 60 // in secs

	// A ban was found for the connecting player!! Lets see how long it is or if it has expired
	if ((ban_length_int == 0) || (ban_created ==0) || ((ban_created+ban_length_int) > current_time_int)) {
		new complain_url[256]
		get_pcvar_string(pcvar_complainurl ,complain_url,255)
		
		client_cmd(id, "echo [CS-BULGARIA] ===============================================")
		
		new show_activity = get_cvar_num("amx_show_activity")
		
		if(get_user_flags(id)&get_admin_mole_access_flag() || id == 0)
		show_activity = 1
		
		switch(show_activity)
		{
			case 1:
			{
				client_cmd(id, "echo [CS-BULGARIA] %L",id,"MSG_9")
			}
			case 2:
			{
				client_cmd(id, "echo [CS-BULGARIA] %L",id,"MSG_8", admin_nick)
			}
			case 3:
			{
				if (is_user_admin(id))
					client_cmd(id, "echo [CS-BULGARIA] %L",id,"MSG_8", admin_nick)
				else
					client_cmd(id, "echo [CS-BULGARIA] %L",id,"MSG_9")
			}
			case 4:
			{
				if (is_user_admin(id))
					client_cmd(id, "echo [CS-BULGARIA] %L",id,"MSG_8", admin_nick)
			}
			case 5:
			{
				if (is_user_admin(id))
					client_cmd(id, "echo [CS-BULGARIA] %L",id,"MSG_9")
			}
		}
		
		if (ban_length_int==0) {
			client_cmd(id, "echo [CS-BULGARIA] %L",id,"MSG_10")
		} else {
			new cTimeLength[128]
			new iSecondsLeft = (ban_created + ban_length_int - current_time_int)
			get_time_length(id, iSecondsLeft, timeunit_seconds, cTimeLength, 127)
			client_cmd(id, "echo [CS-BULGARIA] %L" ,id, "MSG_12", cTimeLength)
		}
		
		replace_all(complain_url,charsmax(complain_url),"http://","")
		
		client_cmd(id, "echo [CS-BULGARIA] %L", id, "MSG_13", player_nick)
		client_cmd(id, "echo [CS-BULGARIA] %L", id, "MSG_2", ban_reason)
		client_cmd(id, "echo [CS-BULGARIA] %L", id, "MSG_7", complain_url)
		client_cmd(id, "echo [CS-BULGARIA] %L", id, "MSG_4", player_steamid)
		client_cmd(id, "echo [CS-BULGARIA] %L", id, "MSG_5", player_ip)
		client_cmd(id, "echo [CS-BULGARIA] ===============================================")

		if ( get_pcvar_num(pcvar_debug) >= 1 )
			log_amx("[CS-BULGARIA] BID:<%d> Player:<%s> <%s> connected and got kicked, because of an active ban", bid, player_nick, player_steamid)

		new id_str[3]
		num_to_str(id,id_str,3)

		if ( get_pcvar_num(pcvar_debug) >= 1 )
			log_amx("[CS-BULGARIA] Delayed Kick-TASK ID1: <%d>  ID2: <%s>", id, id_str)
		
		add_kick_to_db(bid)
		
		id+=200
		set_task(3.5,"delayed_kick",id)

		return PLUGIN_HANDLED
	} else {
		// The ban has expired
		client_cmd(id, "echo [CS-BULGARIA] %L",LANG_PLAYER,"MSG_11")
		
		new pquery[1024]
		formatex(pquery,charsmax(pquery),"UPDATE `%s%s` SET expired=1 WHERE bid=%d",g_dbPrefix, tbl_bans, bid)
		if(g_SqlX)
		SQL_ThreadQuery(g_SqlX, "insert_to_banhistory", pquery)
		
		if ( get_pcvar_num(pcvar_debug) >= 1 )
			log_amx("[CS-BULGARIA] PRUNE BAN: %s",pquery)
			
		check_flagged(id)
	}
	return PLUGIN_HANDLED
}

public insert_to_banhistory(failstate, Handle:query, error[], errnum, data[], size) {
	if (failstate) {
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 19 )
	}
	return PLUGIN_HANDLED
}
/*************************************************************************/
public add_kick_to_db(bid) {
	new pquery[1024]
	formatex(pquery,charsmax(pquery),"UPDATE `%s%s` SET `ban_kicks`=`ban_kicks`+1 WHERE `bid`=%d",g_dbPrefix, tbl_bans, bid)
	
	if(g_SqlX)
	SQL_ThreadQuery(g_SqlX, "_add_kick_to_db", pquery)
	return PLUGIN_HANDLED
}
public _add_kick_to_db(failstate, Handle:query, error[], errnum, data[], size) {
	if (failstate) {
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 19 )
	}
	return PLUGIN_HANDLED
}

I apologize to the moderators if my topic is in the wrong section, or with a confused title.
User avatar
indianiso1
Posts: 180
Joined: 16 Oct 2015, 01:59
Contact:

Re: error with gm bans 1.5.1, chek_player.inl and check_flag.inl

Post by indianiso1 »

Firstly, Game Modifications aka GM's are not supported by officials of AMXBans.
Secondly, I doubt anyone is so keen in this programming language anymore, especially in here. You can try Your luck on amxmodx forum.
Also You can see authors of modification, so can try to search for them. And idk where did You get this mod, try that place too.
Post Reply