ff_i_message
Colored feedback message functions.
Sends floating text, chat messages, and examine text to players with color applied via the ff_i_color token system.
-
STRING_COLOR_NONE
Default color.
-
STRING_COLOR_GREY
Common grey.
-
STRING_COLOR_ORANGE
Orange.
-
STRING_COLOR_CINNABAR
Red-ish.
-
STRING_COLOR_YELLOW
Yellow.
-
STRING_COLOR_COMBAT
cf. STRING_COLOR_YELLOW
-
STRING_COLOR_CYAN
Cyan.
-
MESSAGE_COLOR_DEBUG
cf. STRING_COLOR_CYAN
-
MESSAGE_COLOR_SERVER
Grey.
-
MESSAGE_COLOR_SUCCESS
Green.
-
MESSAGE_COLOR_FAILURE
Red-ish.
-
CHAT_COLOR_DEBUG
cf. MESSAGE_COLOR_DEBUG
-
CHAT_COLOR_SERVER
cf. MESSAGE_COLOR_SERVER
-
void SendMessage(object oObject, string sMessage, string sColor = STRING_COLOR_GREY, string sCategory = "")
- Parameters:
oObject – PC recipient.
sMessage – Message text.
sColor – A STRING_COLOR_* value. Defaults to STRING_COLOR_GREY.
sCategory – If non-empty, prepended as “[sCategory] “. Defaults to “”.
Sends a message via SendMessageToPC with defaults to grey color, and with “[sCategory]” prefixed.
-
void SendServerMessage(object oPC, string sMessage, string sColor = MESSAGE_COLOR_SERVER)
- Parameters:
oPC – PC recipient.
sMessage – Message text.
sColor – Color. Defaults to MESSAGE_COLOR_SERVER.
Sends a message via SendMessageToPC in Grey with “Server” prefixed.
-
void SendSuccessMessage(object oPC, string sMessage, string sColor = MESSAGE_COLOR_SUCCESS)
- Parameters:
oPC – PC recipient.
sMessage – Message text.
sColor – Color. Defaults to MESSAGE_COLOR_SUCCESS.
Sends a message via SendMessageToPC in Green with nothing prefixed.
-
void SendFailureMessage(object oPC, string sMessage, string sColor = MESSAGE_COLOR_FAILURE)
- Parameters:
oPC – PC recipient.
sMessage – Message text.
sColor – Color. Defaults to MESSAGE_COLOR_FAILURE.
Sends a message via SendMessageToPC in Red with nothing prefixed.
Source code
// @code
#include "ff_i_color"
#include "ff_i_string"
#include "nwnx_util"
#include "x3_inc_string"
//! @var STRING_COLOR_NONE
//! @brief Default color
const string STRING_COLOR_NONE = "";
//! @var STRING_COLOR_GREY
//! @brief Common grey
const string STRING_COLOR_GREY = "444"; // common grey
//! @var STRING_COLOR_ORANGE
//! @brief Orange
const string STRING_COLOR_ORANGE = "720";
//! @var STRING_COLOR_CINNABAR
//! @brief Red-ish
const string STRING_COLOR_CINNABAR = "711"; // redish
//! @var STRING_COLOR_YELLOW
//! @brief Yellow
const string STRING_COLOR_YELLOW = "770";
//! @var STRING_COLOR_COMBAT
//! @brief cf. STRING_COLOR_YELLOW
const string STRING_COLOR_COMBAT = "770"; // yellow
//! @var STRING_COLOR_CYAN
//! @brief Cyan
const string STRING_COLOR_CYAN = "077";
//! @var MESSAGE_COLOR_DEBUG
//! @brief cf. STRING_COLOR_CYAN
const string MESSAGE_COLOR_DEBUG = "077"; // Cyan
//! @var MESSAGE_COLOR_SERVER
//! @brief Grey
const string MESSAGE_COLOR_SERVER = "444"; // Grey
//! @var MESSAGE_COLOR_SUCCESS
//! @brief Green
const string MESSAGE_COLOR_SUCCESS = "070"; // Green
//! @var MESSAGE_COLOR_FAILURE
//! @brief Red-ish
const string MESSAGE_COLOR_FAILURE = "711"; // Redish, cinnabar
//! @var CHAT_COLOR_DEBUG
//! @brief cf. MESSAGE_COLOR_DEBUG
const string CHAT_COLOR_DEBUG = MESSAGE_COLOR_DEBUG;
//! @var CHAT_COLOR_SERVER
//! @brief cf. MESSAGE_COLOR_SERVER
const string CHAT_COLOR_SERVER = MESSAGE_COLOR_SERVER;
// -----------------------------------------------------------------------------
//! @brief Shorthand for StringToRGBString.
//! @param sString The string to colorize.
//! @param sRGB A STRING_COLOR_* RGB value.
string _RGB(string sString, string sRGB);
string _RGB(string sString, string sRGB)
{
return StringToRGBString(sString, sRGB);
}
// -----------------------------------------------------------------------------
//! @brief Sends a message via SendMessageToPC with defaults to grey color, and with "[sCategory]" prefixed.
//! @param oObject PC recipient.
//! @param sMessage Message text.
//! @param sColor A STRING_COLOR_* value. Defaults to STRING_COLOR_GREY.
//! @param sCategory If non-empty, prepended as "[sCategory] ". Defaults to "".
void SendMessage(object oObject, string sMessage, string sColor = STRING_COLOR_GREY, string sCategory = "");
void SendMessage(object oObject, string sMessage, string sColor = STRING_COLOR_GREY, string sCategory = "")
{
string sLine = "";
if (GetStringLength(sCategory))
sCategory = "[" + GetStringTrim(sCategory) + "] ";
if (GetStringLength(sColor))
sMessage = StringToRGBString(NWNX_Util_StripColors(sCategory + sMessage), sColor);
else
sMessage = NWNX_Util_StripColors(sCategory + sMessage);
SendMessageToPC(oObject, sMessage);
}
// -----------------------------------------------------------------------------
//! @brief Sends a message via SendMessageToPC in Grey with "Server" prefixed.
//! @param oPC PC recipient.
//! @param sMessage Message text.
//! @param sColor Color. Defaults to MESSAGE_COLOR_SERVER.
void SendServerMessage(object oPC, string sMessage, string sColor = MESSAGE_COLOR_SERVER);
void SendServerMessage(object oPC, string sMessage, string sColor = MESSAGE_COLOR_SERVER)
{
SendMessage(oPC, sMessage, sColor, "Server");
}
// -----------------------------------------------------------------------------
//! @brief Sends a message via SendMessageToPC in Green with nothing prefixed.
//! @param oPC PC recipient.
//! @param sMessage Message text.
//! @param sColor Color. Defaults to MESSAGE_COLOR_SUCCESS.
void SendSuccessMessage(object oPC, string sMessage, string sColor = MESSAGE_COLOR_SUCCESS);
void SendSuccessMessage(object oPC, string sMessage, string sColor = MESSAGE_COLOR_SUCCESS)
{
SendMessage(oPC, sMessage, sColor);
}
// -----------------------------------------------------------------------------
//! @brief Sends a message via SendMessageToPC in Red with nothing prefixed.
//! @param oPC PC recipient.
//! @param sMessage Message text.
//! @param sColor Color. Defaults to MESSAGE_COLOR_FAILURE.
void SendFailureMessage(object oPC, string sMessage, string sColor = MESSAGE_COLOR_FAILURE);
void SendFailureMessage(object oPC, string sMessage, string sColor = MESSAGE_COLOR_FAILURE)
{
SendMessage(oPC, sMessage, sColor);
}