本文整理汇总了C++中CGameContext::ProcessSpamProtection方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameContext::ProcessSpamProtection方法的具体用法?C++ CGameContext::ProcessSpamProtection怎么用?C++ CGameContext::ProcessSpamProtection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameContext
的用法示例。
在下文中一共展示了CGameContext::ProcessSpamProtection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConPrivMsg
void CGameContext::ConPrivMsg(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
int to = pResult->GetVictim();
if(!CheckClientID(to))
return;
if(CheckClientID(pResult->m_ClientID) && pSelf->ProcessSpamProtection(pResult->m_ClientID))
return;
char message[512];
str_format(message, sizeof(message), "PM -> %s: ", pSelf->Server()->ClientName(to));
str_append(message, pResult->GetString(0), sizeof(message));
CNetMsg_Sv_Chat Msg;
Msg.m_Team = 1;
Msg.m_ClientID = CheckClientID(pResult->m_ClientID) ? pResult->m_ClientID : -1;
Msg.m_pMessage = message;
pSelf->Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, to);
if(CheckClientID(pResult->m_ClientID))
{
pSelf->Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, pResult->m_ClientID);
str_format(message, sizeof(message), "\"%s\" -> \"%s\" : %s",
pSelf->Server()->ClientName(pResult->m_ClientID),
pSelf->Server()->ClientName(to),
pResult->GetString(0));
}
else
{
str_format(message, sizeof(message), "%d -> \"%s\" : %s",
pResult->m_ClientID,
pSelf->Server()->ClientName(to),
pResult->GetString(0));
}
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "pmchat", message);
}
示例2: ConSwap
void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
const int ClientID = pResult->m_ClientID;
if(!g_Config.m_SvSwap)
{
pSelf->SendChatTarget(ClientID, "Swap is not activated");
return;
}
int ToSwap = pResult->GetVictim();
if(!CheckClientID(ToSwap) || ClientID == ToSwap)
ToSwap = -1;
if(!CheckClientID(ClientID))
return;
pSelf->m_aSwapRequest[ClientID] = ToSwap;
if(ToSwap == -1)
return;
if(pSelf->ProcessSpamProtection(ClientID)) // dont flood
return;
// check if ToSwap agrees
char aBuf[128];
if(pSelf->m_aSwapRequest[ToSwap] != ClientID)
{
// send notification to ToSwap
str_format(aBuf, sizeof(aBuf), "%s wants to swap places with you. Type \'/swap %d\' to accept.",
pSelf->Server()->ClientName(ClientID), ClientID);
pSelf->SendChatTarget(ToSwap, aBuf);
str_format(aBuf, sizeof(aBuf), "Requst sent to %s.",
pSelf->Server()->ClientName(ToSwap));
pSelf->SendChatTarget(ClientID, aBuf);
}
else
{
// ToSwap agreed
CCharacter * pChar1 = pSelf->GetPlayerChar(ClientID);
CCharacter * pChar2 = pSelf->GetPlayerChar(ToSwap);
if(!pChar1 || !pChar2 || pChar1->Team() != pChar2->Team())
{
// one is not alive or not in the same team
const char * pStr = "Can\'t swap!";
pSelf->SendChatTarget(ToSwap, pStr);
pSelf->SendChatTarget(ClientID, pStr);
return;
}
CPlayerRescueState state1 = GetPlayerState(pChar1),
state2 = GetPlayerState(pChar2);
// swap
ApplyPlayerState(state2, pChar1);
ApplyPlayerState(state1, pChar2);
str_format(aBuf, sizeof(aBuf), "%s swapped with %s.",
pSelf->Server()->ClientName(ToSwap),
pSelf->Server()->ClientName(ClientID));
pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
// reset swap requests
pSelf->m_aSwapRequest[ToSwap] = -1;
pSelf->m_aSwapRequest[ClientID] = -1;
}
}