Raised This Month: $12 Target: $400
 3% 

[help] bad player list


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ghostz0r
Senior Member
Join Date: Dec 2012
Old 12-25-2016 , 06:11   [help] bad player list
Reply With Quote #1

hello guys, i tried to make blacklist with bad players with sql database, i don't know how to make sql request to check players, help pls to

this code have black_list.ini file in configs dir, all players writed inside this file like a
;nickname
STEAMID

Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>

#define PLUGIN "Black List SQLx"
#define VERSION "0.000"
#define AUTHOR "zerz0r"

new const user_file[] = "black_list.ini"
new Array:BlackList

new Handle:SQL_Tuple
new Handle:SQL_Connection 

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
    SQL_Tuple = SQL_MakeDbTuple("host","user","password","database")
    new err, error[256]
    SQL_Connection = SQL_Connect(SQL_Tuple, err, error, charsmax(error))
     
    if(SQL_Connection != Empty_Handle)
	{
        log_amx("[SQLx connect ok]") 
        }else{
        log_amx("[SQLX sql error] %s ",error)
        pause("a")
    }
     
}

public plugin_precache()
{
	BlackList = ArrayCreate(32, 1)
	read_user_from_file()
}

public read_user_from_file()
{
	static user_file_url[64], config_dir[32]
	
	get_configsdir(config_dir, sizeof(config_dir))
	format(user_file_url, sizeof(user_file_url), "%s/%s", config_dir, user_file)
	
	if(!file_exists(user_file_url))
		return
	
	static file_handle, line_data[64], line_count
	file_handle = fopen(user_file_url, "rt")
	
	while(!feof(file_handle))
	{
		fgets(file_handle, line_data, sizeof(line_data))
		
		replace(line_data, charsmax(line_data), "^n", "")
		
		if(!line_data[0] || line_data[0] == ';') 
			continue
			
		ArrayPushString(BlackList, line_data)
		line_count++
	}
	
	fclose(file_handle)
}

public client_connect(id)
{
	check_and_handle(id)
}

public client_infochanged(id)
{
	check_and_handle(id)
}

public check_and_handle(id)
{
	static name[64], steamid[32], Data[32]
	
	get_user_name(id, name, sizeof(name))
	get_user_steamid(id, steamid, sizeof(steamid))
	
	for(new i = 0; i < ArraySize(BlackList); i++)
	{
		ArrayGetString(BlackList, i, Data, sizeof(Data))
		
		if(equal(name, Data) || equal(steamid, Data))
		{
		server_cmd("amx_kick %s kappa^n", name)
		client_printcolor(0, "!g[BL]!y !t%s!y bad PLAYER. Kick !t%s!y !!!", name, name)
		}
	}
}
stock client_printcolor(const id, const input[], any:...)
{
	new iCount = 1, iPlayers[32]
	static szMsg[191]
	
	vformat(szMsg, charsmax(szMsg), input, 3)
	replace_all(szMsg, 190, "!g", "^4")
	replace_all(szMsg, 190, "!y", "^1")
	replace_all(szMsg, 190, "!t", "^3")
	
	if(id) iPlayers[0] = id
	else get_players(iPlayers, iCount, "ch")
	
	for (new i = 0; i < iCount; i++)
	{
		if(is_user_connected(iPlayers[i]))
		{
			message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, iPlayers[i])
			write_byte(iPlayers[i])
			write_string(szMsg)
			message_end()
		}
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1066\\ f0\\ fs16 \n\\ par }
*/

Last edited by ghostz0r; 12-25-2016 at 06:13.
ghostz0r is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-25-2016 , 12:11   Re: [help] bad player list
Reply With Quote #2

I don't know with sql but i can help you with nvault if you want
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
ghostz0r
Senior Member
Join Date: Dec 2012
Old 12-25-2016 , 12:23   Re: [help] bad player list
Reply With Quote #3

i need sql coz i have 2-3 server's
ghostz0r is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-25-2016 , 12:45   Re: [help] bad player list
Reply With Quote #4

I'd recommend reading some tutorials that talk about using SQL with AMX Mod X. Also, you can look at other ban plugins that use SQL since that is exactly what you are doing. And, in that light, you should maybe consider just using an SQL-based ban plugin.
__________________
fysiks is offline
SomewhereLost
AlliedModders Donor
Join Date: Mar 2014
Location: Tomorrowland
Old 12-26-2016 , 01:27   Re: [help] bad player list
Reply With Quote #5

Is there any similar plugin but without SQL ?
__________________
SomewhereLost is offline
Send a message via Skype™ to SomewhereLost
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-26-2016 , 02:59   Re: [help] bad player list
Reply With Quote #6

Quote:
Originally Posted by SomewhereLost View Post
Is there any similar plugin but without SQL ?
https://forums.alliedmods.net/showthread.php?t=176663
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode