added chat trigger detection
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401475
This commit is contained in:
parent
e4728b0413
commit
a8aa9d2d7f
@ -52,6 +52,7 @@ ChatTriggers::ChatTriggers() : m_pSayCmd(NULL), m_bWillProcessInPost(false),
|
|||||||
m_PrivTrigger = sm_strdup("/");
|
m_PrivTrigger = sm_strdup("/");
|
||||||
m_PubTriggerSize = 1;
|
m_PubTriggerSize = 1;
|
||||||
m_PrivTriggerSize = 1;
|
m_PrivTriggerSize = 1;
|
||||||
|
m_bIsChatTrigger = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatTriggers::~ChatTriggers()
|
ChatTriggers::~ChatTriggers()
|
||||||
@ -141,6 +142,7 @@ void ChatTriggers::OnSourceModShutdown()
|
|||||||
void ChatTriggers::OnSayCommand_Pre()
|
void ChatTriggers::OnSayCommand_Pre()
|
||||||
{
|
{
|
||||||
int client = g_ConCmds.GetCommandClient();
|
int client = g_ConCmds.GetCommandClient();
|
||||||
|
m_bIsChatTrigger = false;
|
||||||
|
|
||||||
/* The server console cannot do this */
|
/* The server console cannot do this */
|
||||||
if (client == 0)
|
if (client == 0)
|
||||||
@ -190,6 +192,8 @@ void ChatTriggers::OnSayCommand_Pre()
|
|||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_bIsChatTrigger = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We'll execute it in post.
|
* We'll execute it in post.
|
||||||
*/
|
*/
|
||||||
@ -208,6 +212,7 @@ void ChatTriggers::OnSayCommand_Pre()
|
|||||||
|
|
||||||
void ChatTriggers::OnSayCommand_Post()
|
void ChatTriggers::OnSayCommand_Post()
|
||||||
{
|
{
|
||||||
|
m_bIsChatTrigger = false;
|
||||||
if (m_bWillProcessInPost)
|
if (m_bWillProcessInPost)
|
||||||
{
|
{
|
||||||
/* Reset this for re-entrancy */
|
/* Reset this for re-entrancy */
|
||||||
@ -308,3 +313,8 @@ unsigned int ChatTriggers::GetReplyTo()
|
|||||||
{
|
{
|
||||||
return m_ReplyTo;
|
return m_ReplyTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChatTriggers::IsChatTrigger()
|
||||||
|
{
|
||||||
|
return m_bIsChatTrigger;
|
||||||
|
}
|
||||||
|
@ -57,6 +57,7 @@ private: //ConCommand
|
|||||||
public:
|
public:
|
||||||
unsigned int GetReplyTo();
|
unsigned int GetReplyTo();
|
||||||
unsigned int SetReplyTo(unsigned int reply);
|
unsigned int SetReplyTo(unsigned int reply);
|
||||||
|
bool IsChatTrigger();
|
||||||
private:
|
private:
|
||||||
bool PreProcessTrigger(edict_t *pEdict, const char *args, bool is_quoted);
|
bool PreProcessTrigger(edict_t *pEdict, const char *args, bool is_quoted);
|
||||||
private:
|
private:
|
||||||
@ -68,6 +69,7 @@ private:
|
|||||||
size_t m_PrivTriggerSize;
|
size_t m_PrivTriggerSize;
|
||||||
bool m_bWillProcessInPost;
|
bool m_bWillProcessInPost;
|
||||||
bool m_bTriggerWasSilent;
|
bool m_bTriggerWasSilent;
|
||||||
|
bool m_bIsChatTrigger;
|
||||||
unsigned int m_ReplyTo;
|
unsigned int m_ReplyTo;
|
||||||
char m_ToExecute[300];
|
char m_ToExecute[300];
|
||||||
};
|
};
|
||||||
|
@ -996,6 +996,11 @@ static cell_t CheckCommandAccess(IPluginContext *pContext, const cell_t *params)
|
|||||||
return g_ConCmds.CheckCommandAccess(params[1], cmd, bits) ? 1 : 0;
|
return g_ConCmds.CheckCommandAccess(params[1], cmd, bits) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t IsChatTrigger(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
return g_ChatTriggers.IsChatTrigger() ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_NATIVES(consoleNatives)
|
REGISTER_NATIVES(consoleNatives)
|
||||||
{
|
{
|
||||||
{"CreateConVar", sm_CreateConVar},
|
{"CreateConVar", sm_CreateConVar},
|
||||||
@ -1037,5 +1042,6 @@ REGISTER_NATIVES(consoleNatives)
|
|||||||
{"ReadCommandIterator", ReadCommandIterator},
|
{"ReadCommandIterator", ReadCommandIterator},
|
||||||
{"CheckCommandAccess", CheckCommandAccess},
|
{"CheckCommandAccess", CheckCommandAccess},
|
||||||
{"FakeClientCommandEx", FakeClientCommandEx},
|
{"FakeClientCommandEx", FakeClientCommandEx},
|
||||||
|
{"IsChatTrigger", IsChatTrigger},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -81,7 +81,7 @@ public OnPluginStart()
|
|||||||
public Action:Command_SayChat(client, args)
|
public Action:Command_SayChat(client, args)
|
||||||
{
|
{
|
||||||
decl String:text[192];
|
decl String:text[192];
|
||||||
if (GetCmdArgString(text, sizeof(text)) < 1)
|
if (IsChatTrigger() || GetCmdArgString(text, sizeof(text)) < 1)
|
||||||
{
|
{
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
@ -230,6 +230,15 @@ native ReplySource:GetCmdReplySource();
|
|||||||
*/
|
*/
|
||||||
native ReplySource:SetCmdReplySource(ReplySource:source);
|
native ReplySource:SetCmdReplySource(ReplySource:source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the current say hook is a chat trigger.
|
||||||
|
*
|
||||||
|
* This function is only meaningful inside say or say_team hooks.
|
||||||
|
*
|
||||||
|
* @return True if a chat trigger, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool:IsChatTrigger();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays usage of an admin command to users depending on the
|
* Displays usage of an admin command to users depending on the
|
||||||
* setting of the sm_show_activity cvar. Additionally, the client
|
* setting of the sm_show_activity cvar. Additionally, the client
|
||||||
|
Loading…
Reference in New Issue
Block a user