Add natives to get chat triggers (#1816)
This commit is contained in:
parent
f90b7ade76
commit
3b4a343274
@ -461,3 +461,23 @@ bool ChatTriggers::WasFloodedMessage()
|
||||
{
|
||||
return m_bWasFloodedMessage;
|
||||
}
|
||||
|
||||
const char *ChatTriggers::GetPublicChatTrigger()
|
||||
{
|
||||
if (!m_PubTrigger.length())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m_PubTrigger.c_str();
|
||||
}
|
||||
|
||||
const char *ChatTriggers::GetPrivateChatTrigger()
|
||||
{
|
||||
if (!m_PrivTrigger.length())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m_PrivTrigger.c_str();
|
||||
}
|
||||
|
@ -63,6 +63,8 @@ public:
|
||||
unsigned int SetReplyTo(unsigned int reply);
|
||||
bool IsChatTrigger();
|
||||
bool WasFloodedMessage();
|
||||
const char *GetPublicChatTrigger();
|
||||
const char *GetPrivateChatTrigger();
|
||||
private:
|
||||
enum ChatTriggerType {
|
||||
ChatTrigger_Public,
|
||||
|
@ -1091,6 +1091,26 @@ static cell_t IsChatTrigger(IPluginContext *pContext, const cell_t *params)
|
||||
return g_ChatTriggers.IsChatTrigger() ? 1 : 0;
|
||||
}
|
||||
|
||||
static cell_t GetPublicChatTriggers(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
size_t length;
|
||||
|
||||
const char *triggers = g_ChatTriggers.GetPublicChatTrigger();
|
||||
pContext->StringToLocalUTF8(params[1], params[2], triggers ? triggers : "", &length);
|
||||
|
||||
return static_cast<cell_t>(length);
|
||||
}
|
||||
|
||||
static cell_t GetSilentChatTriggers(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
size_t length;
|
||||
|
||||
const char *triggers = g_ChatTriggers.GetPrivateChatTrigger();
|
||||
pContext->StringToLocalUTF8(params[1], params[2], triggers ? triggers : "", &length);
|
||||
|
||||
return static_cast<cell_t>(length);
|
||||
}
|
||||
|
||||
static cell_t SetCommandFlags(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *name;
|
||||
@ -1514,6 +1534,8 @@ REGISTER_NATIVES(consoleNatives)
|
||||
{"ReadCommandIterator", ReadCommandIterator},
|
||||
{"FakeClientCommandEx", FakeClientCommandEx},
|
||||
{"IsChatTrigger", IsChatTrigger},
|
||||
{"GetPublicChatTriggers", GetPublicChatTriggers},
|
||||
{"GetSilentChatTriggers", GetSilentChatTriggers},
|
||||
{"SetCommandFlags", SetCommandFlags},
|
||||
{"GetCommandFlags", GetCommandFlags},
|
||||
{"FindFirstConCommand", FindFirstConCommand},
|
||||
|
@ -273,6 +273,24 @@ native ReplySource SetCmdReplySource(ReplySource source);
|
||||
*/
|
||||
native bool IsChatTrigger();
|
||||
|
||||
/**
|
||||
* Get the list of characters used for public chat triggers.
|
||||
*
|
||||
* @param buffer Buffer to use for storing the string.
|
||||
* @param maxlength Maximum length of the buffer.
|
||||
* @return Length of string written to buffer.
|
||||
*/
|
||||
native int GetPublicChatTriggers(char[] buffer, int maxlength);
|
||||
|
||||
/**
|
||||
* Get the list of characters used for silent chat triggers.
|
||||
*
|
||||
* @param buffer Buffer to use for storing the string.
|
||||
* @param maxlength Maximum length of the buffer.
|
||||
* @return Length of string written to buffer.
|
||||
*/
|
||||
native int GetSilentChatTriggers(char[] buffer, int maxlength);
|
||||
|
||||
/**
|
||||
* Displays usage of an admin command to users depending on the
|
||||
* setting of the sm_show_activity cvar. All users receive a message
|
||||
|
Loading…
Reference in New Issue
Block a user