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

Problem with the mysql ban scripting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Stefanx
Member
Join Date: Feb 2018
Location: Romania
Old 12-14-2019 , 07:43   Problem with the mysql ban scripting
Reply With Quote #1

Hi, i use ban mysql threaded plugin and when i ban a player show this: https://prnt.sc/qaqorq and him reconnect show like this https://prnt.sc/qaqpe7
this is the database https://prnt.sc/qaqrp7

Can you help me to show like in first photo when him reconnect to the server

Code:
public T_AuthCheck(Handle:owner, Handle:hndl, const String:error[], any:data) {
	new client;
 	decl ban_length;	
	decl String:steam_id[32];
	decl String:steam_id_admin[32];
 	decl String:ban_reason[100];
 	decl String:banned_by[100];	
 	decl String:date[32];
 	decl ban_remaining;
 	decl String:source[65];
	decl String:query[255];
		
	if ((client = GetClientOfUserId(data)) == 0) {
		return;
	}
	
	GetClientAuthId(client, AuthId_Engine, steam_id, 32);
	//GetClientName(admin, source, sizeof(source));

	new buffer_len = strlen(steam_id) * 2 + 1
	new String:v_steam_id[buffer_len]
	SQL_EscapeString(hDatabase, steam_id, v_steam_id, buffer_len)
	 
	if (hndl == INVALID_HANDLE) {
		LogError("[MYBans] Query failed! %s", error);
		KickClient(client, "Error: Reattempt connection");
	}
	
	FormatTime(date, sizeof(date), "%R - %D ");

	
	if(SQL_FetchRow(hndl)) {
	
		
		ban_length = SQL_FetchInt(hndl,0);
		SQL_FetchString(hndl,1,ban_reason,sizeof(ban_reason));
	
		if (ban_length == 0) 
		{
			KickClient(client,"Ai Primit ban\nDurata Ban: Permanent\nMotiv: %s\nNume Admin: %s\nSteamID Admin: %s\nSteamID-ul tau: %s\nData si ora: %s\n StefanX1 on Steam", ban_reason, banned_by, steam_id_admin, steam_id, date);
			return;
		}

		ban_remaining = SQL_FetchInt(hndl,2);
	

		if (ban_remaining <= ban_length) 
		{

			KickClient(client,"Ai Primit ban\nDurata Ban: %d\nMotiv: %s\nNume Admin: %s\nSteamID Admin: %s\nSteamID-ul tau: %s\nData si ora: %s\n StefanX1 on Steam", ban_remaining, ban_reason, banned_by, steam_id_admin, steam_id, date);
		
		} else {

			Format(query, sizeof(query), "DELETE FROM my_bans WHERE steam_id='%s'", v_steam_id);
			SQL_TQuery(hDatabase, T_MYUnBan, query);
			LogMessage("[MYBans] User %s has been unbanned by elapse of time.", v_steam_id);
		}

	}
}
Stefanx is offline
Stefanx
Member
Join Date: Feb 2018
Location: Romania
Old 12-16-2019 , 15:32   Re: Problem with the mysql ban scripting
Reply With Quote #2

solveeed.

t/c pls
Stefanx is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 12-16-2019 , 17:15   Re: Problem with the mysql ban scripting
Reply With Quote #3

How did u solve your problem?
__________________
Neuro Toxin is offline
Stefanx
Member
Join Date: Feb 2018
Location: Romania
Old 12-17-2019 , 03:18   Re: Problem with the mysql ban scripting
Reply With Quote #4

Code:
public T_AuthCheck(Handle:owner, Handle:hndl, const String:error[], any:data) {
	new client;
 	decl ban_length;	
	decl String:steam_id[32];
	decl String:steam_id_admin[32];
 	decl String:ban_reason[100];
 	decl String:banned_by[32];
 	decl ban_remaining;
	decl String:query[255];
	decl String:timestamp[64];
		
	if ((client = GetClientOfUserId(data)) == 0) {
		return;
	}

	GetClientAuthId(client, AuthId_Engine, steam_id, 32);

	new buffer_len = strlen(steam_id) * 2 + 1
	new String:v_steam_id[buffer_len]
	SQL_EscapeString(hDatabase, steam_id, v_steam_id, buffer_len)

	if (hndl == INVALID_HANDLE) 
	{
		LogError("[MYBans] Query failed! %s", error);
		KickClient(client, "Error: Reattempt connection");
	}

	while (SQL_FetchRow(hndl)) {
		ban_length = SQL_FetchInt(hndl,0);
		SQL_FetchString(hndl,1,banned_by,sizeof(banned_by));
		SQL_FetchString(hndl,2,ban_reason,sizeof(ban_reason));
		SQL_FetchString(hndl,3,steam_id_admin,sizeof(steam_id_admin));
		SQL_FetchString(hndl,4,timestamp,sizeof(timestamp));
		ban_remaining = SQL_FetchInt(hndl,5);
		if (ban_length == 0) {
			KickClient(client,"Ai Primit ban\nDurata Ban: Permanent\nMotiv: %s\nNume Admin: %s\nSteamID Admin: %s\nSteamID-ul tau: %s\nData si ora: %s\nStefanX1 on Steam", ban_reason, banned_by, steam_id_admin, steam_id, timestamp);
			return;
		}
		
		if (ban_remaining <= ban_length) {
			KickClient(client,"Ai Primit ban\nDurata Ban: %d minute\nMotiv: %s\nNume Admin: %s\nSteamID Admin: %s\nSteamID-ul tau: %s\nData si ora: %s\nStefanX1 on Steam", ban_length, ban_reason, banned_by, steam_id_admin, steam_id, timestamp);

		} else {
			Format(query, sizeof(query), "DELETE FROM my_bans WHERE steam_id='%s'", v_steam_id);
			SQL_TQuery(hDatabase, T_MYUnBan, query);
			LogMessage("[MYBans] User %s has been unbanned by elapse of time.", v_steam_id);
		}
	}
}

public OnClientPostAdminCheck(client) {

	if(IsFakeClient(client)) {
		return;
	}
	
	decl String:steam_id[32];
	decl String:query[255];

	GetClientAuthId(client, AuthId_Engine, steam_id, 32);
	
	new buffer_len = strlen(steam_id) * 2 + 1
	new String:v_steam_id[buffer_len]
	SQL_EscapeString(hDatabase, steam_id, v_steam_id, buffer_len)

	Format(query, sizeof(query), "SELECT ban_length, banned_by, ban_reason, steam_id_admin, timestamp, (now()-timestamp)/60 FROM my_bans WHERE steam_id = '%s'", v_steam_id); // fixing this 
	SQL_TQuery(hDatabase, T_AuthCheck, query, GetClientUserId(client));
}
idk if is a clean code but work
Stefanx is offline
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 18:15.


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