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

[EXTENSION] ConColors (v1.0 12/17/2018) (Windows only)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rachnus
Senior Member
Join Date: Jun 2016
Location: Funland
Old 12-16-2018 , 19:11   [EXTENSION] ConColors (v1.0 12/17/2018) (Windows only)
Reply With Quote #1

Manipulate the color of server console output.




concolors.inc
PHP Code:
#if defined _concolors_included
 #endinput
#endif
#define _concolors_included

#define CON_COLOR_BLACK   0
#define CON_COLOR_BLUE    1
#define CON_COLOR_GREEN   2
#define CON_COLOR_CYAN    3
#define CON_COLOR_RED     4
#define CON_COLOR_MAGENTA 5
#define CON_COLOR_BROWN   6
#define CON_COLOR_WHITE   7

#define FOREGROUND_CON_COLOR_GRAY            8
#define FOREGROUND_CON_COLOR_INTENSE_BLUE    9
#define FOREGROUND_CON_COLOR_INTENSE_GREEN   10
#define FOREGROUND_CON_COLOR_INTENSE_CYAN    11
#define FOREGROUND_CON_COLOR_INTENSE_RED     12
#define FOREGROUND_CON_COLOR_INTENSE_MAGENTA 13
#define FOREGROUND_CON_COLOR_YELLOW          14
#define FOREGROUND_CON_COLOR_INTENSE_WHITE   15

/*
bit 0 - foreground blue
bit 1 - foreground green
bit 2 - foreground red
bit 3 - foreground intensity

bit 4 - background blue
bit 5 - background green
bit 6 - background red
bit 7 - background intensity
*/

/**
 * Sets the color of all future console output
 *
 * @param background    text background color
 * @param foreground    text foreground color
 * @return void
 */
native void SetConsolePrintColor(int backgroundint foreground);

/**
 * Sets the color of all future console output with custom attributes
 *
 * @param attributes    text attributes
 * @return void
 */
native void SetConsolePrintColorEx(int attributes);

/**
 * Resets the console print color to default (white)
 *
 * @return void
 */
native void ResetConsolePrintColor();

/**
 * Resets the console print color to the previous print color
 *
 * @return void
 */
native void ResetPreviousConsolePrintColor();

/**
 * Print a colored message to the server console
 *
 * @param background    text background color
 * @param foreground    text foreground color
 * @param fmt            format
 * @param any             ...
 * @return void
 */
stock void ColorPrintToServer(int backgroundint foregroundchar[] fmtany ...)
{
    
SetConsolePrintColor(backgroundforeground);
    
char szBuffer[1024];
    
VFormat(szBuffersizeof(szBuffer), fmt4);
    
PrintToServer(szBuffer);
    
ResetPreviousConsolePrintColor();
}

/**
 * Print a colored message to the server console with custom attributes
 *
 * @param attributes    text attributes
 * @param fmt            format
 * @param any             ...
 * @return void
 */
stock void ColorPrintToServerEx(int attributeschar[] fmtany ...)
{
    
SetConsolePrintColorEx(attributes);
    
char szBuffer[1024];
    
VFormat(szBuffersizeof(szBuffer), fmt3);
    
PrintToServer(szBuffer);
    
ResetPreviousConsolePrintColor();
}

public 
Extension __ext_concolors 
{
    
name "ConColors",
    
file "concolors.ext",
#if defined AUTOLOAD_EXTENSIONS
    
autoload 1,
#else
    
autoload 0,
#endif
#if defined REQUIRE_EXTENSIONS
    
required 1,
#else
    
required 0,
#endif
}; 
SOURCE/BINARIES
__________________
Github: https://github.com/jimppan
Steam: http://steamcommunity.com/id/jimppan
_____________________________________________ _________
Taking private requests

Last edited by Rachnus; 02-21-2024 at 13:56.
Rachnus is offline
enderandrew
Senior Member
Join Date: Jun 2020
Old 07-16-2020 , 22:24   Re: [EXTENSION] ConColors (v1.0 12/17/2018) (Windows only)
Reply With Quote #2

Could you do syntax highlighting with this for connect messages in a given color, errors in another color, etc?
enderandrew is offline
DJPlaya
Senior Member
Join Date: Nov 2014
Location: Germany
Old 07-29-2020 , 12:03   Re: [EXTENSION] ConColors (v1.0 12/17/2018) (Windows only)
Reply With Quote #3

Quote:
Originally Posted by enderandrew View Post
Could you do syntax highlighting with this for connect messages in a given color, errors in another color, etc?
Hi again, idk why i always meet you in so many different Threads ^^
Ime not sure, but if i understand correctly, you do can set the Message Color of everything.
Instead of hooking out the connect message and then reprinting it, this should also do the trick(and is a bit simpler):
Code:
OnClientConnect()
{
	SetConsolePrintColor(RED IDK you know what i mean)
	RequestFrame(Frame)
}

public action Frame()
{
	SetConsolePrintColor(Default Color Here)
}
This isent failsafe since every message send in that frame does get colored, but yea.

The only other Way i could think of is hooking the Server Console Print, its propably possible todo this with PTAH or DHooks, here is some Pseudocode:
Code:
OnPluginStart()
{
	PTaH(PTaH_ServerConsolePrint, Hook, ServerConsolePrint);
}

public Action ServerConsolePrint(const char[] sMessage, LoggingSeverity severity)
{
	if(StrCmp(sMessage, "connected")) // Message to highlight goes here
	{
		ColorPrintToServer(BACKGROUND COLOR, FOREGROUND COLOR, sMessage)
		return Plugin_Handled;
	}

	else
		return Plugin_Continue;
}
__________________
My biggest Projects: Kigen AC Redux, Forlix Floodcheck Redux
DJPlaya is offline
Send a message via Skype™ to DJPlaya
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 14:42.


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