Raised This Month: $ Target: $400
 0% 

Solved [H3LP] Show Banned Users


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 04-15-2017 , 05:01   [H3LP] Show Banned Users
Reply With Quote #1

Hello. I've been working on a ban plug-in, and I have an issue with showing banned users in console.
Everything else works fine.

Code:
public cmdShowBans(id, level, cid)
{
	if (!cmd_access(id, level, cid, 1))
		return PLUGIN_HANDLED;
	
	new flags = get_user_flags(id);
	
	if ((is_user_connected(id)) && (!(flags & ADMIN_BAN)))
	{
		client_print(id,print_console,"You do not have access to use this command.");
	}
	new readdata[256]
	new cfgdir[256]
	new cfgpath[256]
	new max_bans
	
	new parsedid[33], parsedname[64], parsedadmin[64];

	get_configsdir(cfgdir, 256-1)

	format(cfgpath, charsmax(cfgpath), "%s/bans.ini", cfgdir)
	new f;
	if (!file_exists(cfgpath))
	{
			client_print(id, print_console, "Ban file is missing")
			return 0;
	}
	f=fopen(cfgpath, "rt")
	parse(readdata, parsedid, charsmax(parsedid), parsedname, charsmax(parsedname), parsedadmin, charsmax(parsedadmin));
	if (!fgets(f,readdata,sizeof(readdata)))
	{
		client_print(id, print_console, "No clients are banned.");
		return PLUGIN_HANDLED;
	}
	else while(fgets(f,readdata,sizeof(readdata)))
	{
		trim(readdata)
		if( !readdata[0] || readdata[0] == ';' || readdata[0] == '/' ) continue; 
		if (contain(readdata,parsedname))
		{
			max_bans++;
			client_print(id, print_console, "%d. %s", max_bans, readdata)
		}
		else
		{
			max_bans++;
			client_print(id, print_console, "%d. No client name found on line %d!", max_bans,  max_bans)
		}
		
	}
	fclose(f)
	return PLUGIN_HANDLED;
}

Last edited by DarthMan; 04-15-2017 at 15:08. Reason: Solved
DarthMan is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-15-2017 , 08:16   Re: [H3LP] Show Banned Users
Reply With Quote #2

Use console_print, and its max string characters are 256. So u need to triple use it or double use it or more


Remove this check its useless, u can add the access flag when you are registering the concmd
PHP Code:
    new flags get_user_flags(id);
    
    if ((
is_user_connected(id)) && (!(flags ADMIN_BAN)))
    {
        
client_print(id,print_console,"You do not have access to use this command.");
    } 
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
DarthMan
Veteran Member
Join Date: Aug 2011
Old 04-15-2017 , 08:43   Re: [H3LP] Show Banned Users
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
Use console_print, and its max string characters are 256. So u need to triple use it or double use it or more


Remove this check its useless, u can add the access flag when you are registering the concmd
PHP Code:
    new flags get_user_flags(id);
    
    if ((
is_user_connected(id)) && (!(flags ADMIN_BAN)))
    {
        
client_print(id,print_console,"You do not have access to use this command.");
    } 
Works, ty
DarthMan is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 04-15-2017 , 08:51   Re: [H3LP] Show Banned Users
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
max string characters are 256.
255* We use 256 because of the last char that is ^0.
__________________
edon1337 is offline
Reply



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 17:50.


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