Wrap ClientPrintf into IGamePlayer (bug 6021, r=asherkin).
This commit is contained in:
parent
b0ee5ce485
commit
af7b8cd9a3
@ -413,10 +413,12 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE != SE_DOTA
|
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||||
edict_t *pEdict = PEntityOfEntIndex(client);
|
if (!pPlayer)
|
||||||
#endif
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we got here, the command failed... */
|
/* If we got here, the command failed... */
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
if (!logicore.CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "No Access", &client))
|
if (!logicore.CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "No Access", &client))
|
||||||
@ -429,11 +431,7 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi
|
|||||||
{
|
{
|
||||||
char fullbuffer[192];
|
char fullbuffer[192];
|
||||||
UTIL_Format(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer);
|
UTIL_Format(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer);
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
pPlayer->PrintToConsole(fullbuffer);
|
||||||
engine->ClientPrintf(client, fullbuffer);
|
|
||||||
#else
|
|
||||||
engine->ClientPrintf(pEdict, fullbuffer);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (replyto == SM_REPLY_CHAT)
|
else if (replyto == SM_REPLY_CHAT)
|
||||||
{
|
{
|
||||||
|
@ -843,11 +843,13 @@ void ClientConsolePrint(edict_t *e, const char *fmt, ...)
|
|||||||
buffer[len] = '\0';
|
buffer[len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
CPlayer *pPlayer = g_Players.GetPlayerByIndex(IndexOfEdict(e));
|
||||||
engine->ClientPrintf(CEntityIndex(IndexOfEdict(e)), buffer);
|
if (!pPlayer)
|
||||||
#else
|
{
|
||||||
engine->ClientPrintf(e, buffer);
|
return;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
pPlayer->PrintToConsole(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
void ListExtensionsToClient(CPlayer *player, const CCommand &args)
|
||||||
@ -2323,3 +2325,23 @@ unsigned int CPlayer::GetSerial()
|
|||||||
{
|
{
|
||||||
return m_Serial.value;
|
return m_Serial.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPlayer::PrintToConsole(const char *pMsg)
|
||||||
|
{
|
||||||
|
if (m_IsConnected == false || m_bFakeClient == true)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(m_iIndex));
|
||||||
|
if (pNetChan == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE == SE_DOTA
|
||||||
|
engine->ClientPrintf(m_iIndex, pMsg);
|
||||||
|
#else
|
||||||
|
engine->ClientPrintf(m_pEdict, pMsg);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -91,6 +91,7 @@ public:
|
|||||||
void NotifyPostAdminChecks();
|
void NotifyPostAdminChecks();
|
||||||
unsigned int GetSerial();
|
unsigned int GetSerial();
|
||||||
int GetIndex() const;
|
int GetIndex() const;
|
||||||
|
void PrintToConsole(const char *pMsg);
|
||||||
public:
|
public:
|
||||||
void DoBasicAdminChecks();
|
void DoBasicAdminChecks();
|
||||||
void MarkAsBeingKicked();
|
void MarkAsBeingKicked();
|
||||||
|
@ -884,11 +884,7 @@ static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
|
|||||||
|
|
||||||
if (index != 0)
|
if (index != 0)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
pPlayer->PrintToConsole(buffer);
|
||||||
engine->ClientPrintf(pPlayer->GetIndex(), buffer);
|
|
||||||
#else
|
|
||||||
engine->ClientPrintf(pPlayer->GetEdict(), buffer);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
META_CONPRINT(buffer);
|
META_CONPRINT(buffer);
|
||||||
}
|
}
|
||||||
@ -1200,11 +1196,7 @@ static cell_t ReplyToCommand(IPluginContext *pContext, const cell_t *params)
|
|||||||
{
|
{
|
||||||
buffer[len++] = '\n';
|
buffer[len++] = '\n';
|
||||||
buffer[len] = '\0';
|
buffer[len] = '\0';
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
pPlayer->PrintToConsole(buffer);
|
||||||
engine->ClientPrintf(pPlayer->GetIndex(), buffer);
|
|
||||||
#else
|
|
||||||
engine->ClientPrintf(pPlayer->GetEdict(), buffer);
|
|
||||||
#endif
|
|
||||||
} else if (replyto == SM_REPLY_CHAT) {
|
} else if (replyto == SM_REPLY_CHAT) {
|
||||||
if (len >= 191)
|
if (len >= 191)
|
||||||
{
|
{
|
||||||
|
@ -1118,11 +1118,7 @@ static cell_t _ShowActivity(IPluginContext *pContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer);
|
UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer);
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
pPlayer->PrintToConsole(message);
|
||||||
engine->ClientPrintf(pPlayer->GetIndex(), message);
|
|
||||||
#else
|
|
||||||
engine->ClientPrintf(pPlayer->GetEdict(), message);
|
|
||||||
#endif
|
|
||||||
display_in_chat = true;
|
display_in_chat = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1248,20 +1244,8 @@ static cell_t _ShowActivity2(IPluginContext *pContext,
|
|||||||
* simply gets added to the console, so we don't want it to print
|
* simply gets added to the console, so we don't want it to print
|
||||||
* twice.
|
* twice.
|
||||||
*/
|
*/
|
||||||
if (replyto == SM_REPLY_CONSOLE)
|
UTIL_Format(message, sizeof(message), "%s%s", tag, buffer);
|
||||||
{
|
g_HL2.TextMsg(client, HUD_PRINTTALK, message);
|
||||||
#if 0
|
|
||||||
UTIL_Format(message, sizeof(message), "%s%s\n", tag, buffer);
|
|
||||||
engine->ClientPrintf(pPlayer->GetEdict(), message);
|
|
||||||
#endif
|
|
||||||
UTIL_Format(message, sizeof(message), "%s%s", tag, buffer);
|
|
||||||
g_HL2.TextMsg(client, HUD_PRINTTALK, message);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UTIL_Format(message, sizeof(message), "%s%s", tag, buffer);
|
|
||||||
g_HL2.TextMsg(client, HUD_PRINTTALK, message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include <IAdminSystem.h>
|
#include <IAdminSystem.h>
|
||||||
|
|
||||||
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
|
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
|
||||||
#define SMINTERFACE_PLAYERMANAGER_VERSION 18
|
#define SMINTERFACE_PLAYERMANAGER_VERSION 19
|
||||||
|
|
||||||
struct edict_t;
|
struct edict_t;
|
||||||
class IPlayerInfo;
|
class IPlayerInfo;
|
||||||
@ -253,6 +253,13 @@ namespace SourceMod
|
|||||||
* @return Client's index.
|
* @return Client's index.
|
||||||
*/
|
*/
|
||||||
virtual int GetIndex() const =0;
|
virtual int GetIndex() const =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints a string to the client console.
|
||||||
|
*
|
||||||
|
* @param pMsg String to print.
|
||||||
|
*/
|
||||||
|
virtual void PrintToConsole(const char *pMsg) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user