I've a plugin CSAY , it works like that: sm_csay2 "message {color} message {color}
i want to add 1 more command
sm_psay2 "PLAYERID" "{color} message {color} message"
i want to send a private message to a player , I just need a command which send the message to player privately
like: sm_psay2 "PLAYERID" "{color} message {color} message"
colors already explained in scripting.
CODE OF Plugin
Code:
#include <sourcemod>
#include <multicolors>
public void OnPluginStart() {
RegAdminCmd("sm_csay", cmd_csay, Admin_RCON, "sm_csay \"msg\" \"color\" . (check colors available: sm_csay_colorlist)");
RegAdminCmd("sm_csay2", cmd_csay2, Admin_RCON, "sm_csay \"msg\" . (check colors available: sm_csay2_colorlist)");
RegAdminCmd("sm_csay_colorlist", cmd_colorlist, Admin_Generic, "displays all available colors for sm_csay.");
RegAdminCmd("sm_csay2_colorlist", cmd_colorlist2, Admin_Generic, "displays all available colors for sm_csay.");
}
char g_colors[][] = {
"white",
"red",
"darkred",
"lightred",
"purple",
"green",
"lightgreen",
"lime",
"grey",
"grey2",
"grey3",
"yellow",
"lightblue",
"blue",
"pink",
"orange",
"team",
};
char g_hex[][] = {
"\x01",
"\x0F",
"\x02",
"\x07",
"\x03",
"\x04",
"\x05",
"\x06",
"\x08",
"\x0A",
"\x0D",
"\x09",
"\x0B",
"\x0C",
"\x0E",
"\x10",
"",
};
public Action cmd_colorlist(int c, int a) {
for (int i = 0; i < sizeof(g_colors); i++) {
ReplyToCommand(c, "%s", g_colors[i]);
}
return Plugin_Handled;
}
public Action cmd_colorlist2(int c, int a) {
ReplyToCommand(c, "{default} {darkred} {green} {lightgreen} {red} {blue} {olive} {lime} {lightred} {purple} {grey} {yellow} {orange} {bluegrey} {lightblue} {darkblue} {grey2} {orchid} {lightred2}");
return Plugin_Handled;
}
public Action cmd_csay(int c, int a) {
if (a != 2) {
ReplyToCommand(c, "Error! Usage: sm_csay \"message\" \"color\"");
return Plugin_Handled;
}
char msg[194];
GetCmdArg(1, msg, sizeof(msg));
if (strlen(msg) > 192) {
ReplyToCommand(c, "Error! Max size of a chat message is 192 characters!");
return Plugin_Handled;
}
char color[32];
GetCmdArg(2, color, sizeof(color));
if (!color_exists(color)) {
ReplyToCommand(c, "Error! Color \"%s\" does not exist! Check sm_csay_colorlist", color);
return Plugin_Handled;
}
int index = get_color_index(color);
PrintToChatAll("\x01 %s %s", g_hex[index], msg);
return Plugin_Handled;
}
public Action cmd_csay2(int c, int a) {
if (a != 1) {
ReplyToCommand(c, "Error! Usage: sm_csay2 \"message\"");
return Plugin_Handled;
}
char msg[194];
GetCmdArg(1, msg, sizeof(msg));
if (strlen(msg) > 192) {
ReplyToCommand(c, "Error! Max size of a chat message is 192 characters!");
return Plugin_Handled;
}
CPrintToChat(c, "%s", msg);
//CPrintToChatAll("%s", msg);
return Plugin_Handled;
}
bool color_exists(const char[] color) {
bool r = false;
for (int i = 0; i < sizeof(g_colors); i++) {
if (!strcmp(color, g_colors[i])) {
r = true;
break;
}
}
return r;
}
int get_color_index(const char[] color) {
int r = -1;
for (int i = 0; i < sizeof(g_colors); i++) {
if (!strcmp(color, g_colors[i])) {
r = i;
}
}
if (r == -1)
LogError("something went wrong! @ get_color_index");
return r;
}