[Plugin] Simple console color changer & system Executor
#1

This is a very simple plugin I made within around 15-30 minutes. It basically allows you to change the color of your console & execute commands via system. I have only compiled the plugin for windows, but if someone wants to make it work for linux that'd be cool aswell.

As of the second version(the version that starts on github; it's more of a C++ functions for PAWN than a plugin allowing you to execute system commands and change the color of the console: I have already started adding some more cool functions.

Example:


The plugin itself contains around 7 functions:
pawn Код:
native SetConsoleColor(color[]);
native systemEx(cmd[]);
native getDirectory(directory[]);
native cleanConsole();
native printfEx(string[], color);
native setTextColor(color);
Natives:
SetConsoleColor - Allows you to change the color of the console(through "color" in the system function).
systemEx - Allows you to execute a raw system function.
getDirectory - Allows you to get the directory samp-server is running in.
cleanConsole - Clears the console box.
printfEx - Allows you to print text in a specific color.

Installation:
Plugin:
1. Upload the "color.dll" file to your plugins folder.
2. Open server.cfg and add "color(or color.dll)" to the plugins line(create the line if not already there).

Include:
1. Upload the "color.inc" file to your pawno/includes folder.
2. Include "color.inc" in your script.

Example Script:
pawn Код:
#include <a_samp>
#include <color>
#include <sscanf2>

public OnRconCommand(cmd[])
{
    new operation[24], color[24];
    if(!sscanf(cmd, "s[24]s[24]", operation, color))
    {
        if(strcmp(operation, "color", true) == 0)
        {
            SetConsoleColor(color);
        }
       
        else if(strcmp(operation, "cmd", true) == 0)
        {
            systemEx(color);
        }
    }

    return 1;
}
Colors:
HINT: You can simply put "HELP" in the color parameter to view help regarding the "color" command. The same applies when an invalid color is entered.

0 = Black
1 = Blue
2 = Green
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White
8 = Gray
9 = Light Blue
A = Light Green
B = Light Aqua
C = Light Red
D = Light Purple
E = Light Yellow
F = Bright White

Bugs / Issues:
None have been reported.

Download:
Pre-compiled plugin for windows & include
Source
Github(Source + Pre-compiled plugin for windows)
Reply
#2

At a time ago I created a similar plugin with this using the library windows, I think you could add a few more things, more was cool.

If you want to take a look
Reply
#3

I remember something such as this but I wasn't really sure. Thanks, I will work on adding more C++ functions so they can be used within pawn.
Reply
#4

I remember there being a console color thing that only changed your specific line, I'll look for it now, until then you should try to add that... XD

EDIT: Here's the one I'm talking about.
Reply
#5

Good job!
Reply
#6

I also just found out that riajedA is a banned user, formerly named Adejair_Junior.
It's not a coincidence that he just said he had a plugin like this and that banned account has it here. @Adejair: Out of all of the names you could've used to evade your ban, why would you choose the same one but spell it backwards? XD
Reply
#7

Well simply I don't want to make this too complicated and I also want to make it more of a C++ function plugin that allows C++ functions to be used inside pawn. I'd love if people could give me suggestions as to what sort of functions they want to see; but do note I do not have a linux VPS so I won't be compiling the plugin for linux or optimizing the code for it, sadly.
Reply
#8

add function to clean the console. xD
Reply
#9

Because he's just using system just do systemEx("CLS"); in pawn
Reply
#10

Thanks for all the feedback guys! I am going to move the code over to github when I can get it to work, I have also added clearConsole along with getDirectory allowing you to clear the console and get the directory of the server.
Reply
#11

beautiful work.
Reply
#12

Well nice work.

But honestly why would I ever need to change the color of the console ? :P
Reply
#13

Thanks, and some people may get bored of looking at a black and white console. Also, I am expanding this plugin to be more and offer more C++ functionality within PAWN.

I finally got GitHub to work, https://github.com/Abagail/C-functions-in-PAWN

pawn Code:
#include <a_samp>
#include <color>

public OnRconCommand(cmd[])
{
       if(strcmp(cmd, "clearconsole", true) == 0)
       {
             cleanConsole();
             new string[64];
             getDirectory(string);
             printf("The current path of the server is: %s", string);
       }
       
       return 1;
}
Reply
#14

Its good plugin but there's also another way to change color but i believe temporary.
Reply
#15

nice
Reply
#16

Looks good as you can enter console cmds- will try this out.
Reply
#17

Thanks! I am looking for more C++ functions I can try to implement into the plugin if anyone has any suggestions!
Reply
#18

Implement ANSI support?
Reply
#19

Implementing SetConsoleTextAttribute function would get your plugin improved. Also as it's focused for Windows, you could support more console operations (since your main post is titled as "C++ functions for PAWN")
Reply
#20

Thanks for the great feedback! If you have any other suggestions for specific C++ functions let me know, I'd be glad to check them out!

I have implemented SetConsoleTextAttribute and have added two functions for them.

I have added printfEx allowing you to send one message in a specific color. I have also added setTextColor allowing you to send any upcoming messages in the specified color.

The color list can be found below aswell as in the include(the color parameter with these functions are an integer value):

pawn Code:
#define CONSOLE_COLOR_DARKBLUE 1
#define CONSOLE_COLOR_DARKDARKGREEN 2
#define CONSOLE_COLOR_DARKTEAL 3
#define CONSOLE_COLOR_DARKRED 4
#define CONSOLE_COLOR_DARKPINK 5
#define CONSOLE_COLOR_DARKYELLOW 6
#define CONSOLE_COLOR_GRAY 7
#define CONSOLE_COLOR_DARKGRAY 8
#define CONSOLE_COLOR_BLUE 9
#define CONSOLE_COLOR_GREEN 10
#define CONSOLE_COLOR_TEAL 11
#define CONSOLE_COLOR_RED 12
#define CONSOLE_COLOR_PINK 13
#define CONSOLE_COLOR_YELLOW 14
#define CONSOLE_COLOR_WHITE 15
On an un-related note I have also added a strcopy function allowing you to copy a string to another destination string.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)