[Tutorial] Using the C++ functions for PAWN
#1

This plugin will roughly cover my C++ functions for PAWN plugin and some of it's function. I will try to be as fast and effective as possibly though it's a bit late here so there may be some typos and what not.

You can find the plugin thread here: https://sampforum.blast.hk/showthread.php?tid=582117

The github: https://github.com/Abagail/C-functions-in-PAWN

Functions:
pawn Код:
native SetConsoleColor(color[]);
native systemEx(cmd[]);
native getDirectory(directory[]);
native cleanConsole();
native strcopy(string[], dest[]);
native printfEx(string[], color);
native setTextColor(color);
Function explanations:
pawn Код:
native SetConsoleColor(color[]);
This simply allows you to change the color of the console. The command itself("color") has a help parameter which will pretty much explain everything about the actual command.

The primary(the first part of the color) specifies the foreground(text color in the console), and the second specifies the background(backdrop of the console)'s color.

Colors:
// 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

pawn Код:
native systemEx(cmd[]);
This simply allows you to execute a system command on your machine. You can simply define "system" as "systemEx" to make it more like C++,

pawn Код:
#define system systemEx
pawn Код:
native getDirectory(directory[]);
This simply allows you to get the directory of the server. It sets the "directory" parameter to the directory. This uses the _getcwd function.

Example:
pawn Код:
new string[128];
getDirectory(string);

printf("The current directory of the server is: %s", string);
pawn Код:
native cleanConsole();
This simply cleans the console using the "CLS" system command.

pawn Код:
native strcopy(string[], dest[]);
This function basically does what it says. It copies one string to another destination string(namely the "dest" parameter). This function will overwrite any string already stored in the dest parameter.

pawn Код:
native setTextColor(color);
This allows you to send any upcoming messages in the specified color(see the colors below the next function).

pawn Код:
native printfEx(string[], color);
Allows you to print a singular message in the specified color(colors can be found below).

Colors
NOTE: This colors only apply to the printfEx and setTextColor functions!

Код:
#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
UPDATE: All these functions for now simply return 1.

Another note: The primary purpose of this plugin is to add C++ functions otherwise unavailable in the PAWN implementation, though I am also adding cool functions that allow you to simply fuck around or clean things up. If you have any suggestions, I'd be glad to review them and possibly add your suggestion into the plugin.


Final Note: This plugin has been mainly optimized for windows and has not been(atleast not by me) been compiled for linux, yet.
Reply
#2

Nice Tutorial.
Reply
#3

Updated:
- Added the strcopy function.
- Added the printfEx & setTextColor functions along with a color list(also available as defines in the include).
Reply
#4

Good Job ! +rep
Reply
#5

I thought this tutorial is for using stl function in pawn or something lol.
Reply
#6

Quote:
Originally Posted by RaeF
Посмотреть сообщение
I thought this tutorial is for using stl function in pawn or something lol.
Sadly not, it's for my plugin which brings some C++ functions otherwise not available through PAWN. If you have any functions not yet in the plugin that are possible to add feel free to suggest it and I will look into implementing it as soon as possible.
Reply
#7

so many plugins available for this already, there is absolutely no point in this.
Reply
#8

Quote:
Originally Posted by Calgon
Посмотреть сообщение
so many plugins available for this already, there is absolutely no point in this.
Thank you for your feedback.
Reply
#9

Can't think of any use of this plugin in my case but some people might find it useful in some way.
Good job on creating your own plugin and writing this tutorial!
Reply
#10

Why don't you just include this "tutorial" in your plugin documentation?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)